From 87e0fced25932f270d83f82ebbe588c1a695eef9 Mon Sep 17 00:00:00 2001 From: LexManos Date: Sat, 18 Aug 2012 21:07:29 -0700 Subject: [PATCH] Changed order in which EntityItemPickupEvent is called, it will no longer be called if the 'delay' on the item is still active. Also EntityItems that are in the world with invalid item stacks will now kill themselves. --- .../net/minecraft/src/EntityItem.java.patch | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/patches/common/net/minecraft/src/EntityItem.java.patch b/patches/common/net/minecraft/src/EntityItem.java.patch index e3f34e2ac3..afcd936d31 100644 --- a/patches/common/net/minecraft/src/EntityItem.java.patch +++ b/patches/common/net/minecraft/src/EntityItem.java.patch @@ -10,30 +10,47 @@ public class EntityItem extends Entity { -@@ -238,6 +241,26 @@ +@@ -120,6 +123,11 @@ { - int var2 = this.item.stackSize; + this.setDead(); + } ++ ++ if (this.item == null || this.item.stackSize <= 0) ++ { ++ this.setDead(); ++ } + } + public boolean func_70289_a(EntityItem par1EntityItem) +@@ -223,7 +231,7 @@ + NBTTagCompound var2 = par1NBTTagCompound.getCompoundTag("Item"); + this.item = ItemStack.loadItemStackFromNBT(var2); + +- if (this.item == null) ++ if (this.item == null || this.item.stackSize <= 0) + { + this.setDead(); + } +@@ -236,9 +244,21 @@ + { + if (!this.worldObj.isRemote) + { ++ if (this.delayBeforeCanPickup > 0) ++ { ++ return; ++ } ++ + EntityItemPickupEvent event = new EntityItemPickupEvent(par1EntityPlayer, this); ++ + if (MinecraftForge.EVENT_BUS.post(event)) + { + return; + } + -+ if (delayBeforeCanPickup == 0 && (event.isHandled() || item.stackSize <= 0)) -+ { -+ //FML Notify pickup -+ worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); -+ par1EntityPlayer.onItemPickup(this, var2); -+ -+ if (item.stackSize <= 0) -+ { -+ setDead(); -+ } -+ } -+ -+ var2 = item.stackSize; -+ - if (this.delayBeforeCanPickup == 0 && par1EntityPlayer.inventory.addItemStackToInventory(this.item)) + int var2 = this.item.stackSize; + +- if (this.delayBeforeCanPickup == 0 && par1EntityPlayer.inventory.addItemStackToInventory(this.item)) ++ if (this.delayBeforeCanPickup <= 0 && (event.isHandled() || var2 <= 0 || par1EntityPlayer.inventory.addItemStackToInventory(this.item))) { if (this.item.itemID == Block.wood.blockID) + {