From d6c4f37eb5c8e5256b195b4f8470ec7d536e2ebb Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 18 Dec 2012 06:56:28 -0800 Subject: [PATCH] Fixed items dieing improperly due to new EntityItem sync changes, also made items render offset when rendered in 3d. --- .../client/ForgeHooksClient.java | 2 +- .../common/ForgeInternalHandler.java | 4 +-- .../renderer/entity/RenderItem.java.patch | 25 +++++++++++++------ .../entity/item/EntityItem.java.patch | 25 ++++++++++++------- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/client/net/minecraftforge/client/ForgeHooksClient.java b/client/net/minecraftforge/client/ForgeHooksClient.java index 88e027399..b9807d109 100644 --- a/client/net/minecraftforge/client/ForgeHooksClient.java +++ b/client/net/minecraftforge/client/ForgeHooksClient.java @@ -231,7 +231,7 @@ public class ForgeHooksClient IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(item, ENTITY); if (customRenderer == null) { - return false; + return false; } if (customRenderer.shouldUseRenderHelper(ENTITY, item, ENTITY_ROTATION)) diff --git a/common/net/minecraftforge/common/ForgeInternalHandler.java b/common/net/minecraftforge/common/ForgeInternalHandler.java index 663aff150..fb706b668 100644 --- a/common/net/minecraftforge/common/ForgeInternalHandler.java +++ b/common/net/minecraftforge/common/ForgeInternalHandler.java @@ -36,8 +36,8 @@ public class ForgeInternalHandler if (stack == null) { - entity.setDead(); - event.setCanceled(true); + //entity.setDead(); + //event.setCanceled(true); return; } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderItem.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderItem.java.patch index 95e0fcea9..51b2bcaf1 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RenderItem.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderItem.java.patch @@ -88,10 +88,12 @@ if (this.field_77024_a) { -@@ -257,14 +256,7 @@ - { - GL11.glTranslatef(0.0F, 0.0F, var16 + var17); +@@ -255,16 +254,16 @@ + for (int var20 = 0; var20 < var24; ++var20) + { +- GL11.glTranslatef(0.0F, 0.0F, var16 + var17); +- - if (Block.blocksList[var18.itemID] != null) - { - this.loadTexture("/terrain.png"); @@ -100,11 +102,20 @@ - { - this.loadTexture("/gui/items.png"); - } ++ // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... ++ if (var20 > 0) ++ { ++ float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; ++ float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; ++ float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; ++ GL11.glTranslatef(x, y, var16 + var17); ++ } ++ + this.loadTexture(Item.itemsList[var18.itemID].getTextureFile()); GL11.glColor4f(par5, par6, par7, 1.0F); ItemRenderer.renderItemIn2D(var8, var10, var11, var9, var12, var16); -@@ -348,10 +340,10 @@ +@@ -348,10 +347,10 @@ float var13; float var16; @@ -118,7 +129,7 @@ GL11.glPushMatrix(); GL11.glTranslatef((float)(par4 - 2), (float)(par5 + 3), -3.0F + this.zLevel); GL11.glScalef(10.0F, 10.0F, 10.0F); -@@ -382,11 +374,11 @@ +@@ -382,11 +381,11 @@ if (Item.itemsList[var6].requiresMultipleRenderPasses()) { GL11.glDisable(GL11.GL_LIGHTING); @@ -135,7 +146,7 @@ int var11 = Item.itemsList[var6].getColorFromItemStack(par3ItemStack, var9); var12 = (float)(var11 >> 16 & 255) / 255.0F; var13 = (float)(var11 >> 8 & 255) / 255.0F; -@@ -406,14 +398,7 @@ +@@ -406,14 +405,7 @@ { GL11.glDisable(GL11.GL_LIGHTING); @@ -151,7 +162,7 @@ var9 = Item.itemsList[var6].getColorFromItemStack(par3ItemStack, 0); float var17 = (float)(var9 >> 16 & 255) / 255.0F; -@@ -440,7 +425,10 @@ +@@ -440,7 +432,10 @@ { if (par3ItemStack != null) { diff --git a/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch index 98f2e235f..a9c60a15c 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch @@ -32,7 +32,7 @@ } /** -@@ -135,7 +146,22 @@ +@@ -135,7 +146,29 @@ ++this.age; @@ -41,10 +41,17 @@ + + if (!this.worldObj.isRemote && this.age >= lifespan) + { -+ ItemExpireEvent event = new ItemExpireEvent(this, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, worldObj))); -+ if (MinecraftForge.EVENT_BUS.post(event)) -+ { -+ lifespan += event.extraLife; ++ if (item != null) ++ { ++ ItemExpireEvent event = new ItemExpireEvent(this, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, worldObj))); ++ if (MinecraftForge.EVENT_BUS.post(event)) ++ { ++ lifespan += event.extraLife; ++ } ++ else ++ { ++ this.setDead(); ++ } + } + else + { @@ -52,11 +59,11 @@ + } + } + -+ if (item == null || item.stackSize <= 0) ++ if (item != null && item.stackSize <= 0) { this.setDead(); } -@@ -263,6 +289,7 @@ +@@ -263,6 +296,7 @@ { par1NBTTagCompound.setShort("Health", (short)((byte)this.health)); par1NBTTagCompound.setShort("Age", (short)this.age); @@ -64,7 +71,7 @@ if (this.func_92014_d() != null) { -@@ -280,10 +307,17 @@ +@@ -280,10 +314,17 @@ NBTTagCompound var2 = par1NBTTagCompound.getCompoundTag("Item"); this.func_92013_a(ItemStack.loadItemStackFromNBT(var2)); @@ -83,7 +90,7 @@ } /** -@@ -293,10 +327,22 @@ +@@ -293,10 +334,22 @@ { if (!this.worldObj.isRemote) {