107 lines
4.1 KiB
Diff
107 lines
4.1 KiB
Diff
--- ../src-base/minecraft/net/minecraft/entity/item/EntityItem.java
|
|
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityItem.java
|
|
@@ -40,6 +40,11 @@
|
|
private String field_145802_g;
|
|
public float field_70290_d;
|
|
|
|
+ /**
|
|
+ * 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_);
|
|
@@ -57,6 +62,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_()
|
|
@@ -80,6 +86,7 @@
|
|
|
|
public void func_70071_h_()
|
|
{
|
|
+ if (func_92059_d().func_77973_b().onEntityItemUpdate(this)) return;
|
|
if (this.func_92059_d().func_190926_b())
|
|
{
|
|
this.func_70106_y();
|
|
@@ -169,8 +176,16 @@
|
|
}
|
|
}
|
|
|
|
- if (!this.field_70170_p.field_72995_K && this.field_70292_b >= 6000)
|
|
+ ItemStack item = this.func_92059_d();
|
|
+
|
|
+ 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.func_190926_b())
|
|
+ {
|
|
this.func_70106_y();
|
|
}
|
|
}
|
|
@@ -227,6 +242,10 @@
|
|
{
|
|
return false;
|
|
}
|
|
+ else if (!itemstack.areCapsCompatible(itemstack1))
|
|
+ {
|
|
+ return false;
|
|
+ }
|
|
else
|
|
{
|
|
itemstack1.func_190917_f(itemstack.func_190916_E());
|
|
@@ -316,6 +335,7 @@
|
|
p_70014_1_.func_74777_a("Health", (short)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)
|
|
{
|
|
@@ -360,17 +380,22 @@
|
|
{
|
|
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();
|
|
Item item = itemstack.func_77973_b();
|
|
int i = itemstack.func_190916_E();
|
|
|
|
- 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 (item == Item.func_150898_a(Blocks.field_150364_r))
|
|
{
|
|
@@ -407,6 +432,7 @@
|
|
}
|
|
}
|
|
|
|
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(p_70100_1_, this);
|
|
p_70100_1_.func_71001_a(this, i);
|
|
|
|
if (itemstack.func_190926_b())
|
|
@@ -513,6 +539,6 @@
|
|
public void func_174870_v()
|
|
{
|
|
this.func_174871_r();
|
|
- this.field_70292_b = 5999;
|
|
+ this.field_70292_b = func_92059_d().func_77973_b().getEntityLifespan(func_92059_d(), field_70170_p) - 1;
|
|
}
|
|
}
|