Render pass sensitive version of Item.hasEffect, Closes #517
This commit is contained in:
parent
2b588ebce6
commit
98aab2083b
|
@ -33,6 +33,7 @@ import net.minecraft.client.renderer.Tessellator;
|
|||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
|
@ -43,6 +44,7 @@ import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*;
|
|||
|
||||
public class ForgeHooksClient
|
||||
{
|
||||
private static final ResourceLocation ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
||||
static TextureManager engine()
|
||||
{
|
||||
return FMLClientHandler.instance().getClient().renderEngine;
|
||||
|
@ -166,9 +168,14 @@ public class ForgeHooksClient
|
|||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void renderEffectOverlay(TextureManager manager, RenderItem render)
|
||||
{
|
||||
}
|
||||
|
||||
public static void renderEquippedItem(ItemRenderType type, IItemRenderer customRenderer, RenderBlocks renderBlocks, EntityLivingBase entity, ItemStack item)
|
||||
{
|
||||
if (customRenderer.shouldUseRenderHelper(type, item, EQUIPPED_BLOCK))
|
||||
|
|
|
@ -58,6 +58,15 @@
|
|||
{
|
||||
texturemanager.func_110577_a(texturemanager.func_130087_a(0));
|
||||
this.renderBlocksInstance.renderBlockAsItem(Block.blocksList[par2ItemStack.itemID], par2ItemStack.getItemDamage(), 1.0F);
|
||||
@@ -94,7 +120,7 @@
|
||||
GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
|
||||
renderItemIn2D(tessellator, f1, f2, f, f3, icon.getOriginX(), icon.getOriginY(), 0.0625F);
|
||||
|
||||
- if (par2ItemStack.hasEffect() && par3 == 0)
|
||||
+ if (par2ItemStack.hasEffect(par3))
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
@@ -266,7 +292,7 @@
|
||||
Render render;
|
||||
RenderPlayer renderplayer;
|
||||
|
|
|
@ -76,7 +76,32 @@
|
|||
f8 = 1.0F;
|
||||
|
||||
if (this.renderWithColor)
|
||||
@@ -240,32 +231,26 @@
|
||||
@@ -152,11 +143,11 @@
|
||||
f4 = (float)(i >> 8 & 255) / 255.0F;
|
||||
f6 = (float)(i & 255) / 255.0F;
|
||||
GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F);
|
||||
- this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8);
|
||||
+ this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k);
|
||||
}
|
||||
else
|
||||
{
|
||||
- this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F);
|
||||
+ this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,6 +195,10 @@
|
||||
* Renders a dropped item
|
||||
*/
|
||||
private void renderDroppedItem(EntityItem par1EntityItem, Icon par2Icon, int par3, float par4, float par5, float par6, float par7)
|
||||
+ {
|
||||
+ renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0);
|
||||
+ }
|
||||
+ private void renderDroppedItem(EntityItem par1EntityItem, Icon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
@@ -240,32 +235,26 @@
|
||||
f11 = 0.021875F;
|
||||
ItemStack itemstack = par1EntityItem.getEntityItem();
|
||||
int j = itemstack.stackSize;
|
||||
|
@ -124,7 +149,27 @@
|
|||
{
|
||||
this.func_110776_a(TextureMap.field_110575_b);
|
||||
}
|
||||
@@ -356,10 +341,10 @@
|
||||
@@ -277,7 +266,7 @@
|
||||
GL11.glColor4f(par5, par6, par7, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((Icon)par2Icon).getOriginX(), ((Icon)par2Icon).getOriginY(), f12);
|
||||
|
||||
- if (itemstack.hasEffect())
|
||||
+ if (itemstack.hasEffect(pass))
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
@@ -348,6 +337,10 @@
|
||||
*/
|
||||
public void renderItemIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
|
||||
{
|
||||
+ renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false);
|
||||
+ }
|
||||
+ public void renderItemIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect)
|
||||
+ {
|
||||
int k = par3ItemStack.itemID;
|
||||
int l = par3ItemStack.getItemDamage();
|
||||
Object object = par3ItemStack.getIconIndex();
|
||||
@@ -356,10 +349,10 @@
|
||||
float f1;
|
||||
float f2;
|
||||
|
||||
|
@ -137,7 +182,7 @@
|
|||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)(par4 - 2), (float)(par5 + 3), -3.0F + this.zLevel);
|
||||
GL11.glScalef(10.0F, 10.0F, 10.0F);
|
||||
@@ -386,11 +371,11 @@
|
||||
@@ -386,11 +379,11 @@
|
||||
else if (Item.itemsList[k].requiresMultipleRenderPasses())
|
||||
{
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
@ -146,27 +191,63 @@
|
|||
- for (int j1 = 0; j1 <= 1; ++j1)
|
||||
- {
|
||||
- Icon icon = Item.itemsList[k].getIconFromDamageForRenderPass(l, j1);
|
||||
+ par2TextureManager.func_110577_a(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.field_110575_b : TextureMap.field_110576_c);
|
||||
+
|
||||
+ for (int j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1)
|
||||
+ {
|
||||
+ par2TextureManager.func_110577_a(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.field_110575_b : TextureMap.field_110576_c);
|
||||
+ Icon icon = Item.itemsList[k].getIcon(par3ItemStack, j1);
|
||||
int k1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, j1);
|
||||
f1 = (float)(k1 >> 16 & 255) / 255.0F;
|
||||
f2 = (float)(k1 >> 8 & 255) / 255.0F;
|
||||
@@ -441,7 +426,10 @@
|
||||
@@ -402,6 +395,24 @@
|
||||
}
|
||||
|
||||
this.renderIcon(par4, par5, icon, 16, 16);
|
||||
+
|
||||
+ if (par3ItemStack.hasEffect(j1))
|
||||
+ {
|
||||
+ GL11.glDepthFunc(GL11.GL_GREATER);
|
||||
+ GL11.glDisable(GL11.GL_LIGHTING);
|
||||
+ GL11.glDepthMask(false);
|
||||
+ par2TextureManager.func_110577_a(field_110798_h);
|
||||
+ this.zLevel -= 50.0F;
|
||||
+ GL11.glEnable(GL11.GL_BLEND);
|
||||
+ GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
|
||||
+ GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
|
||||
+ this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
|
||||
+ GL11.glDisable(GL11.GL_BLEND);
|
||||
+ GL11.glDepthMask(true);
|
||||
+ this.zLevel += 50.0F;
|
||||
+ GL11.glEnable(GL11.GL_LIGHTING);
|
||||
+ GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
+ }
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
@@ -441,8 +452,12 @@
|
||||
{
|
||||
if (par3ItemStack != null)
|
||||
{
|
||||
- this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5);
|
||||
-
|
||||
+ if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float)par4, (float)par5))
|
||||
+ {
|
||||
+ this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5);
|
||||
+ this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true);
|
||||
+ }
|
||||
|
||||
+
|
||||
+ /* Modders must handle this themselves if they use custom renderers!
|
||||
if (par3ItemStack.hasEffect())
|
||||
{
|
||||
@@ -583,4 +571,47 @@
|
||||
GL11.glDepthFunc(GL11.GL_GREATER);
|
||||
@@ -460,6 +475,7 @@
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
+ */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -583,4 +599,47 @@
|
||||
{
|
||||
this.doRenderItem((EntityItem)par1Entity, par2, par4, par6, par8, par9);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,15 @@
|
|||
}
|
||||
|
||||
itemsList[256 + par1] = this;
|
||||
@@ -639,6 +649,10 @@
|
||||
@@ -600,6 +610,7 @@
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
+ @Deprecated //Render pass sensitive version below.
|
||||
public boolean hasEffect(ItemStack par1ItemStack)
|
||||
{
|
||||
return par1ItemStack.isItemEnchanted();
|
||||
@@ -639,6 +650,10 @@
|
||||
float f7 = f4 * f5;
|
||||
float f8 = f3 * f5;
|
||||
double d3 = 5.0D;
|
||||
|
@ -58,7 +66,7 @@
|
|||
Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3);
|
||||
return par1World.rayTraceBlocks_do_do(vec3, vec31, par3, !par3);
|
||||
}
|
||||
@@ -736,4 +750,504 @@
|
||||
@@ -736,4 +751,514 @@
|
||||
{
|
||||
StatList.initStats();
|
||||
}
|
||||
|
@ -561,5 +569,15 @@
|
|||
+ public boolean canHarvestBlock(Block par1Block, ItemStack itemStack)
|
||||
+ {
|
||||
+ return canHarvestBlock(par1Block);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ /**
|
||||
+ * Render Pass sensitive version of hasEffect()
|
||||
+ */
|
||||
+ @SideOnly(Side.CLIENT)
|
||||
+ public boolean hasEffect(ItemStack par1ItemStack, int pass)
|
||||
+ {
|
||||
+ return hasEffect(par1ItemStack) && (pass == 0 || itemID != Item.potion.itemID);
|
||||
+ }
|
||||
}
|
||||
|
|
|
@ -75,3 +75,21 @@
|
|||
}
|
||||
|
||||
public boolean func_111282_a(EntityPlayer par1EntityPlayer, EntityLivingBase par2EntityLivingBase)
|
||||
@@ -737,10 +753,16 @@
|
||||
return arraylist;
|
||||
}
|
||||
|
||||
+ @Deprecated
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect()
|
||||
{
|
||||
- return this.getItem().hasEffect(this);
|
||||
+ return hasEffect(0);
|
||||
+ }
|
||||
+ @SideOnly(Side.CLIENT)
|
||||
+ public boolean hasEffect(int pass)
|
||||
+ {
|
||||
+ return this.getItem().hasEffect(this, pass);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
Loading…
Reference in New Issue