Fire playerDestroyItem event's in some cases where we were not.

This commit is contained in:
LexManos 2016-05-23 16:35:49 -07:00
parent 5415891f11
commit 6b8466778e
2 changed files with 50 additions and 20 deletions

View file

@ -223,7 +223,23 @@
ItemStack itemstack = p_184822_2_ != null ? p_184822_2_.func_77946_l() : null; ItemStack itemstack = p_184822_2_ != null ? p_184822_2_.func_77946_l() : null;
if (!p_184822_1_.func_184230_a(this, p_184822_2_, p_184822_3_)) if (!p_184822_1_.func_184230_a(this, p_184822_2_, p_184822_3_))
@@ -1127,6 +1196,7 @@ @@ -1086,6 +1155,7 @@
{
if (p_184822_2_.field_77994_a <= 0 && !this.field_71075_bZ.field_75098_d)
{
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, p_184822_2_, p_184822_3_);
this.func_184611_a(p_184822_3_, (ItemStack)null);
}
@@ -1101,6 +1171,7 @@
{
if (p_184822_2_.field_77994_a <= 0 && !this.field_71075_bZ.field_75098_d)
{
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, p_184822_2_, p_184822_3_);
this.func_184611_a(p_184822_3_, (ItemStack)null);
}
else if (p_184822_2_.field_77994_a < itemstack.field_77994_a && this.field_71075_bZ.field_75098_d)
@@ -1127,6 +1198,7 @@
public void func_71059_n(Entity p_71059_1_) public void func_71059_n(Entity p_71059_1_)
{ {
@ -231,7 +247,15 @@
if (p_71059_1_.func_70075_an()) if (p_71059_1_.func_70075_an())
{ {
if (!p_71059_1_.func_85031_j(this)) if (!p_71059_1_.func_85031_j(this))
@@ -1414,6 +1484,8 @@ @@ -1326,6 +1398,7 @@
if (itemstack1.field_77994_a <= 0)
{
this.func_184611_a(EnumHand.MAIN_HAND, (ItemStack)null);
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, itemstack1, EnumHand.MAIN_HAND);
}
}
@@ -1414,6 +1487,8 @@
public EntityPlayer.SleepResult func_180469_a(BlockPos p_180469_1_) public EntityPlayer.SleepResult func_180469_a(BlockPos p_180469_1_)
{ {
@ -240,7 +264,7 @@
if (!this.field_70170_p.field_72995_K) if (!this.field_70170_p.field_72995_K)
{ {
if (this.func_70608_bn() || !this.func_70089_S()) if (this.func_70608_bn() || !this.func_70089_S())
@@ -1453,9 +1525,10 @@ @@ -1453,9 +1528,10 @@
this.func_70105_a(0.2F, 0.2F); this.func_70105_a(0.2F, 0.2F);
@ -254,7 +278,7 @@
float f = 0.5F; float f = 0.5F;
float f1 = 0.5F; float f1 = 0.5F;
@@ -1518,13 +1591,14 @@ @@ -1518,13 +1594,14 @@
public void func_70999_a(boolean p_70999_1_, boolean p_70999_2_, boolean p_70999_3_) public void func_70999_a(boolean p_70999_1_, boolean p_70999_2_, boolean p_70999_3_)
{ {
@ -272,7 +296,7 @@
if (blockpos == null) if (blockpos == null)
{ {
@@ -1533,6 +1607,10 @@ @@ -1533,6 +1610,10 @@
this.func_70107_b((double)((float)blockpos.func_177958_n() + 0.5F), (double)((float)blockpos.func_177956_o() + 0.1F), (double)((float)blockpos.func_177952_p() + 0.5F)); this.func_70107_b((double)((float)blockpos.func_177958_n() + 0.5F), (double)((float)blockpos.func_177956_o() + 0.1F), (double)((float)blockpos.func_177952_p() + 0.5F));
} }
@ -283,7 +307,7 @@
this.field_71083_bS = false; this.field_71083_bS = false;
@@ -1551,15 +1629,16 @@ @@ -1551,15 +1632,16 @@
private boolean func_175143_p() private boolean func_175143_p()
{ {
@ -303,7 +327,7 @@
{ {
if (!p_180467_2_) if (!p_180467_2_)
{ {
@@ -1574,16 +1653,17 @@ @@ -1574,16 +1656,17 @@
} }
else else
{ {
@ -324,7 +348,7 @@
switch (enumfacing) switch (enumfacing)
{ {
@@ -1623,16 +1703,24 @@ @@ -1623,16 +1706,24 @@
public BlockPos func_180470_cg() public BlockPos func_180470_cg()
{ {
@ -351,7 +375,7 @@
if (p_180473_1_ != null) if (p_180473_1_ != null)
{ {
this.field_71077_c = p_180473_1_; this.field_71077_c = p_180473_1_;
@@ -1827,6 +1915,10 @@ @@ -1827,6 +1918,10 @@
super.func_180430_e(p_180430_1_, p_180430_2_); super.func_180430_e(p_180430_1_, p_180430_2_);
} }
@ -362,7 +386,7 @@
} }
protected void func_71061_d_() protected void func_71061_d_()
@@ -2027,6 +2119,18 @@ @@ -2027,6 +2122,18 @@
this.field_175152_f = p_71049_1_.field_175152_f; this.field_175152_f = p_71049_1_.field_175152_f;
this.field_71078_a = p_71049_1_.field_71078_a; this.field_71078_a = p_71049_1_.field_71078_a;
this.func_184212_Q().func_187227_b(field_184827_bp, p_71049_1_.func_184212_Q().func_187225_a(field_184827_bp)); this.func_184212_Q().func_187227_b(field_184827_bp, p_71049_1_.func_184212_Q().func_187225_a(field_184827_bp));
@ -381,7 +405,7 @@
} }
protected boolean func_70041_e_() protected boolean func_70041_e_()
@@ -2126,7 +2230,10 @@ @@ -2126,7 +2233,10 @@
public ITextComponent func_145748_c_() public ITextComponent func_145748_c_()
{ {
@ -393,7 +417,7 @@
itextcomponent.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.func_70005_c_() + " ")); itextcomponent.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.func_70005_c_() + " "));
itextcomponent.func_150256_b().func_150209_a(this.func_174823_aP()); itextcomponent.func_150256_b().func_150209_a(this.func_174823_aP());
itextcomponent.func_150256_b().func_179989_a(this.func_70005_c_()); itextcomponent.func_150256_b().func_179989_a(this.func_70005_c_());
@@ -2135,7 +2242,7 @@ @@ -2135,7 +2245,7 @@
public float func_70047_e() public float func_70047_e()
{ {
@ -402,7 +426,7 @@
if (this.func_70608_bn()) if (this.func_70608_bn())
{ {
@@ -2346,6 +2453,161 @@ @@ -2346,6 +2456,161 @@
return (float)this.func_110148_a(SharedMonsterAttributes.field_188792_h).func_111126_e(); return (float)this.func_110148_a(SharedMonsterAttributes.field_188792_h).func_111126_e();
} }

View file

@ -134,7 +134,7 @@
{ {
return false; return false;
} }
@@ -265,41 +300,22 @@ @@ -265,58 +300,46 @@
} }
else else
{ {
@ -181,7 +181,13 @@
if (itemstack1 != null) if (itemstack1 != null)
{ {
@@ -311,12 +327,18 @@ itemstack1.func_179548_a(this.field_73092_a, iblockstate, p_180237_1_, this.field_73090_b);
- if (itemstack1.field_77994_a == 0)
+ if (itemstack1.field_77994_a <= 0)
{
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.field_73090_b, itemstack1, EnumHand.MAIN_HAND);
this.field_73090_b.func_184611_a(EnumHand.MAIN_HAND, (ItemStack)null);
} }
} }
@ -200,7 +206,7 @@
return flag1; return flag1;
} }
} }
@@ -334,6 +356,7 @@ @@ -334,6 +357,7 @@
} }
else else
{ {
@ -208,7 +214,7 @@
int i = p_187250_3_.field_77994_a; int i = p_187250_3_.field_77994_a;
int j = p_187250_3_.func_77960_j(); int j = p_187250_3_.func_77960_j();
ActionResult<ItemStack> actionresult = p_187250_3_.func_77957_a(p_187250_2_, p_187250_1_, p_187250_4_); ActionResult<ItemStack> actionresult = p_187250_3_.func_77957_a(p_187250_2_, p_187250_1_, p_187250_4_);
@@ -360,6 +383,7 @@ @@ -360,6 +384,7 @@
if (itemstack.field_77994_a == 0) if (itemstack.field_77994_a == 0)
{ {
p_187250_1_.func_184611_a(p_187250_4_, (ItemStack)null); p_187250_1_.func_184611_a(p_187250_4_, (ItemStack)null);
@ -216,7 +222,7 @@
} }
if (!p_187250_1_.func_184587_cr()) if (!p_187250_1_.func_184587_cr())
@@ -404,13 +428,26 @@ @@ -404,13 +429,26 @@
} }
else else
{ {
@ -246,7 +252,7 @@
} }
} }
@@ -430,14 +467,21 @@ @@ -430,14 +468,21 @@
{ {
int j = p_187251_3_.func_77960_j(); int j = p_187251_3_.func_77960_j();
int i = p_187251_3_.field_77994_a; int i = p_187251_3_.field_77994_a;
@ -268,7 +274,7 @@
} }
} }
} }
@@ -446,4 +490,13 @@ @@ -446,4 +491,13 @@
{ {
this.field_73092_a = p_73080_1_; this.field_73092_a = p_73080_1_;
} }