Files
MinecraftForge/patches/common/net/minecraft/src/EntityItem.java.patch
T
Christian bea2d8599f Update FML: 46c563a
46c563a Expose more of the village construction parts for building village piece
1380c2e Allow access to the type "ComponentVillage"
71a3818 Documentation and registration for villager stuff
e3a343c Fix javadoc derp
195b1a0 Villager trading, manipulation and village enhancement. Still WIP but sh
69e66c3 Fix exception based logging to actually log the exception!
2012-08-19 11:35:22 -04:00

57 lines
1.7 KiB
Diff

--- ../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)
{