--- ../src_base/common/net/minecraft/src/EntityItem.java +++ ../src_work/common/net/minecraft/src/EntityItem.java @@ -1,6 +1,9 @@ package net.minecraft.src; import java.util.Iterator; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import cpw.mods.fml.common.registry.GameRegistry; @@ -122,6 +125,11 @@ { this.setDead(); } + + if (this.item == null || this.item.stackSize <= 0) + { + this.setDead(); + } } public boolean func_70289_a(EntityItem par1EntityItem) @@ -225,7 +233,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(); } @@ -238,9 +246,21 @@ { if (!this.worldObj.isRemote) { + if (this.delayBeforeCanPickup > 0) + { + return; + } + + EntityItemPickupEvent event = new EntityItemPickupEvent(par1EntityPlayer, this); + + if (MinecraftForge.EVENT_BUS.post(event)) + { + return; + } + 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) {