03d1e51764
Fixed player death event in SMP Added Player specific drops event Added generic EntityJoinWorldEvent
103 lines
3.3 KiB
Diff
103 lines
3.3 KiB
Diff
--- ../src_base/common/net/minecraft/src/EntityItem.java
|
|
+++ ../src_work/common/net/minecraft/src/EntityItem.java
|
|
@@ -1,6 +1,10 @@
|
|
package net.minecraft.src;
|
|
|
|
import java.util.Iterator;
|
|
+
|
|
+import net.minecraftforge.common.MinecraftForge;
|
|
+import net.minecraftforge.event.entity.item.ItemExpireEvent;
|
|
+import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
|
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
|
|
|
@@ -20,6 +24,11 @@
|
|
|
|
/** The EntityItem's random initial float height. */
|
|
public float hoverStart = (float)(Math.random() * Math.PI * 2.0D);
|
|
+
|
|
+ /**
|
|
+ * The maximum age of this EntityItem. The item is expired once this is reached.
|
|
+ */
|
|
+ public int lifespan = 6000;
|
|
|
|
public EntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
|
|
{
|
|
@@ -32,6 +41,7 @@
|
|
this.motionX = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D));
|
|
this.motionY = 0.20000000298023224D;
|
|
this.motionZ = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D));
|
|
+ this.lifespan = (par8ItemStack.getItem() == null ? 6000 : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World));
|
|
}
|
|
|
|
/**
|
|
@@ -118,7 +128,20 @@
|
|
|
|
++this.age;
|
|
|
|
- if (this.age >= 6000)
|
|
+ if (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;
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ this.setDead();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (this.item == null || this.item.stackSize <= 0)
|
|
{
|
|
this.setDead();
|
|
}
|
|
@@ -208,6 +231,7 @@
|
|
{
|
|
par1NBTTagCompound.setShort("Health", (short)((byte)this.health));
|
|
par1NBTTagCompound.setShort("Age", (short)this.age);
|
|
+ par1NBTTagCompound.setInteger("Lifespan", lifespan);
|
|
|
|
if (this.item != null)
|
|
{
|
|
@@ -225,10 +249,15 @@
|
|
NBTTagCompound var2 = par1NBTTagCompound.getCompoundTag("Item");
|
|
this.item = ItemStack.loadItemStackFromNBT(var2);
|
|
|
|
- if (this.item == null)
|
|
+ if (this.item == null || this.item.stackSize <= 0)
|
|
{
|
|
this.setDead();
|
|
}
|
|
+
|
|
+ if (par1NBTTagCompound.hasKey("Lifespan"))
|
|
+ {
|
|
+ lifespan = par1NBTTagCompound.getInteger("Lifespan");
|
|
+ }
|
|
}
|
|
|
|
/**
|
|
@@ -238,9 +267,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)
|
|
{
|