ForgePatch/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch

95 lines
4.0 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/item/EntityItem.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityItem.java
@@ -31,6 +31,11 @@
public float field_70290_d;
private static final String __OBFID = "CL_00001669";
+ /**
+ * The maximum age of this EntityItem. The item is expired once this is reached.
+ */
+ public int lifespan = 6000;
+
public EntityItem(World p_i1709_1_, double p_i1709_2_, double p_i1709_4_, double p_i1709_6_)
{
super(p_i1709_1_);
@@ -48,6 +53,7 @@
{
this(p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_);
this.func_92058_a(p_i1710_8_);
+ this.lifespan = (p_i1710_8_.func_77973_b() == null ? 6000 : p_i1710_8_.func_77973_b().getEntityLifespan(p_i1710_8_, p_i1710_1_));
}
protected boolean func_70041_e_()
@@ -71,6 +77,8 @@
public void func_70071_h_()
{
+ ItemStack stack = this.func_70096_w().func_82710_f(10);
+ if (stack != null && stack.func_77973_b() != null && stack.func_77973_b().onEntityItemUpdate(this)) return;
if (this.func_92059_d() == null)
{
this.func_70106_y();
@@ -131,8 +139,16 @@
this.func_70072_I();
- if (!this.field_70170_p.field_72995_K && this.field_70292_b >= 6000)
+ ItemStack item = func_70096_w().func_82710_f(10);
+
+ if (!this.field_70170_p.field_72995_K && this.field_70292_b >= lifespan)
{
+ int hook = net.minecraftforge.event.ForgeEventFactory.onItemExpire(this, item);
+ if (hook < 0) this.func_70106_y();
+ else this.lifespan += hook;
+ }
+ if (item != null && item.field_77994_a <= 0)
+ {
this.func_70106_y();
}
}
@@ -276,6 +292,7 @@
p_70014_1_.func_74777_a("Health", (short)((byte)this.field_70291_e));
p_70014_1_.func_74777_a("Age", (short)this.field_70292_b);
p_70014_1_.func_74777_a("PickupDelay", (short)this.field_145804_b);
+ p_70014_1_.func_74768_a("Lifespan", lifespan);
if (this.func_145800_j() != null)
{
@@ -316,20 +333,23 @@
NBTTagCompound nbttagcompound1 = p_70037_1_.func_74775_l("Item");
this.func_92058_a(ItemStack.func_77949_a(nbttagcompound1));
- if (this.func_92059_d() == null)
- {
- this.func_70106_y();
- }
+ ItemStack item = func_70096_w().func_82710_f(10);
+ if (item == null || item.field_77994_a <= 0) this.func_70106_y();
+ if (p_70037_1_.func_74764_b("Lifespan")) lifespan = p_70037_1_.func_74762_e("Lifespan");
}
public void func_70100_b_(EntityPlayer p_70100_1_)
{
if (!this.field_70170_p.field_72995_K)
{
+ if (this.field_145804_b > 0) return;
ItemStack itemstack = this.func_92059_d();
int i = itemstack.field_77994_a;
- if (this.field_145804_b == 0 && (this.field_145802_g == null || 6000 - this.field_70292_b <= 200 || this.field_145802_g.equals(p_70100_1_.func_70005_c_())) && p_70100_1_.field_71071_by.func_70441_a(itemstack))
+ int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, p_70100_1_, itemstack);
+ if (hook < 0) return;
+
+ if (this.field_145804_b <= 0 && (this.field_145802_g == null || lifespan - this.field_70292_b <= 200 || this.field_145802_g.equals(p_70100_1_.func_70005_c_())) && (hook == 1 || i <= 0 || p_70100_1_.field_71071_by.func_70441_a(itemstack)))
{
if (itemstack.func_77973_b() == Item.func_150898_a(Blocks.field_150364_r))
{
@@ -366,6 +386,7 @@
}
}
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(p_70100_1_, this);
if (!this.func_174814_R())
{
this.field_70170_p.func_72956_a(p_70100_1_, "random.pop", 0.2F, ((this.field_70146_Z.nextFloat() - this.field_70146_Z.nextFloat()) * 0.7F + 1.0F) * 2.0F);