ForgePatch/patches/minecraft/net/minecraft/item/ItemStack.java.patch

150 lines
4.8 KiB
Diff

--- ../src-base/minecraft/net/minecraft/item/ItemStack.java
+++ ../src-work/minecraft/net/minecraft/item/ItemStack.java
@@ -52,6 +52,7 @@
private boolean field_179551_k;
private static final String __OBFID = "CL_00000043";
+ private net.minecraftforge.fml.common.registry.RegistryDelegate<Item> delegate;
public ItemStack(Block p_i1876_1_)
{
this(p_i1876_1_, 1);
@@ -83,7 +84,7 @@
this.field_179553_i = false;
this.field_179550_j = null;
this.field_179551_k = false;
- this.field_151002_e = p_i1881_1_;
+ this.func_150996_a(p_i1881_1_);
this.field_77994_a = p_i1881_2_;
this.field_77991_e = p_i1881_3_;
@@ -123,11 +124,12 @@
public Item func_77973_b()
{
- return this.field_151002_e;
+ return this.delegate != null ? this.delegate.get() : null;
}
public boolean func_179546_a(EntityPlayer p_179546_1_, World p_179546_2_, BlockPos p_179546_3_, EnumFacing p_179546_4_, float p_179546_5_, float p_179546_6_, float p_179546_7_)
{
+ if (!p_179546_2_.field_72995_K) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(this, p_179546_1_, p_179546_2_, p_179546_3_, p_179546_4_, p_179546_5_, p_179546_6_, p_179546_7_);
boolean flag = this.func_77973_b().func_180614_a(this, p_179546_1_, p_179546_2_, p_179546_3_, p_179546_4_, p_179546_5_, p_179546_6_, p_179546_7_);
if (flag)
@@ -172,11 +174,11 @@
{
if (p_77963_1_.func_150297_b("id", 8))
{
- this.field_151002_e = Item.func_111206_d(p_77963_1_.func_74779_i("id"));
+ this.func_150996_a(Item.func_111206_d(p_77963_1_.func_74779_i("id")));
}
else
{
- this.field_151002_e = Item.func_150899_d(p_77963_1_.func_74765_d("id"));
+ this.func_150996_a(Item.func_150899_d(p_77963_1_.func_74765_d("id")));
}
this.field_77994_a = p_77963_1_.func_74771_c("Count");
@@ -200,7 +202,7 @@
public int func_77976_d()
{
- return this.func_77973_b().func_77639_j();
+ return this.func_77973_b().getItemStackLimit(this);
}
public boolean func_77985_e()
@@ -210,7 +212,7 @@
public boolean func_77984_f()
{
- return this.field_151002_e == null ? false : (this.field_151002_e.func_77612_l() <= 0 ? false : !this.func_77942_o() || !this.func_77978_p().func_74767_n("Unbreakable"));
+ return this.field_151002_e == null ? false : (this.field_151002_e.getMaxDamage(this) <= 0 ? false : !this.func_77942_o() || !this.func_77978_p().func_74767_n("Unbreakable"));
}
public boolean func_77981_g()
@@ -220,32 +222,27 @@
public boolean func_77951_h()
{
- return this.func_77984_f() && this.field_77991_e > 0;
+ return this.func_77984_f() && func_77973_b().isDamaged(this);
}
public int func_77952_i()
{
- return this.field_77991_e;
+ return func_77973_b().getDamage(this);
}
public int func_77960_j()
{
- return this.field_77991_e;
+ return func_77973_b().getMetadata(this);
}
public void func_77964_b(int p_77964_1_)
{
- this.field_77991_e = p_77964_1_;
-
- if (this.field_77991_e < 0)
- {
- this.field_77991_e = 0;
- }
+ func_77973_b().setDamage(this, p_77964_1_);
}
public int func_77958_k()
{
- return this.field_151002_e.func_77612_l();
+ return this.field_151002_e.getMaxDamage(this);
}
public boolean func_96631_a(int p_96631_1_, Random p_96631_2_)
@@ -277,8 +274,8 @@
}
}
- this.field_77991_e += p_96631_1_;
- return this.field_77991_e > this.func_77958_k();
+ func_77964_b(func_77952_i() + p_96631_1_); //Redirect through Item's callback if applicable.
+ return func_77952_i() > func_77958_k();
}
}
@@ -337,7 +334,7 @@
public boolean func_150998_b(Block p_150998_1_)
{
- return this.field_151002_e.func_150897_b(p_150998_1_);
+ return func_77973_b().canHarvestBlock(p_150998_1_, this);
}
public boolean func_111282_a(EntityPlayer p_111282_1_, EntityLivingBase p_111282_2_)
@@ -752,6 +749,8 @@
}
}
+ net.minecraftforge.event.ForgeEventFactory.onItemTooltip(this, p_82840_1_, arraylist, p_82840_2_);
+
return arraylist;
}
@@ -862,7 +861,7 @@
}
else
{
- object = this.func_77973_b().func_111205_h();
+ object = this.func_77973_b().getAttributeModifiers(this);
}
return (Multimap)object;
@@ -870,6 +869,7 @@
public void func_150996_a(Item p_150996_1_)
{
+ this.delegate = p_150996_1_ != null ? p_150996_1_.delegate : null;
this.field_151002_e = p_150996_1_;
}