Changed ToolMaterial's repair material to ItemStack version to allow metadata sensitive versions.

This commit is contained in:
Lex Manos 2014-12-07 04:30:10 -08:00
parent 4cc11b220a
commit 309fe700cd
3 changed files with 50 additions and 4 deletions

View File

@ -610,18 +610,22 @@
public static void func_150900_l()
{
func_179214_a(Blocks.field_150348_b, (new ItemMultiTexture(Blocks.field_150348_b, Blocks.field_150348_b, new Function()
@@ -936,6 +1495,9 @@
@@ -936,6 +1495,10 @@
private static final String __OBFID = "CL_00000042";
+ //Added by forge for custom Tool materials.
+ public Item customCraftingMaterial = null;
+ @Deprecated public Item customCraftingMaterial = null; // Remote in 1.8.1
+ private ItemStack repairMaterial = null;
+
private ToolMaterial(int p_i1874_3_, int p_i1874_4_, float p_i1874_5_, float p_i1874_6_, int p_i1874_7_)
{
this.field_78001_f = p_i1874_3_;
@@ -972,7 +1534,15 @@
@@ -970,9 +1533,36 @@
return this.field_78008_j;
}
+ @Deprecated // Use getRepairItemStack below
public Item func_150995_f()
{
- return this == WOOD ? Item.func_150898_a(Blocks.field_150344_f) : (this == STONE ? Item.func_150898_a(Blocks.field_150347_e) : (this == GOLD ? Items.field_151043_k : (this == IRON ? Items.field_151042_j : (this == EMERALD ? Items.field_151045_i : null))));
@ -635,5 +639,23 @@
+ default: return customCraftingMaterial;
+ }
}
+
+ public ToolMaterial setRepairItem(ItemStack stack)
+ {
+ if (this.repairMaterial != null || customCraftingMaterial != null) throw new RuntimeException("Can not change already set repair material");
+ if (this == WOOD || this == STONE || this == GOLD || this == IRON || this == EMERALD) throw new RuntimeException("Can not change vanilla tool repair materials");
+ this.repairMaterial = stack;
+ this.customCraftingMaterial = stack.func_77973_b();
+ return this;
+ }
+
+ public ItemStack getRepairItemStack()
+ {
+ if (repairMaterial != null) return repairMaterial;
+ Item ret = this.func_150995_f();
+ if (ret == null) return null;
+ repairMaterial = new ItemStack(ret, 1, net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE);
+ return repairMaterial;
+ }
}
}

View File

@ -0,0 +1,13 @@
--- ../src-base/minecraft/net/minecraft/item/ItemSword.java
+++ ../src-work/minecraft/net/minecraft/item/ItemSword.java
@@ -102,7 +102,9 @@
public boolean func_82789_a(ItemStack p_82789_1_, ItemStack p_82789_2_)
{
- return this.field_150933_b.func_150995_f() == p_82789_2_.func_77973_b() ? true : super.func_82789_a(p_82789_1_, p_82789_2_);
+ ItemStack mat = this.field_150933_b.getRepairItemStack();
+ if (mat != null && net.minecraftforge.oredict.OreDictionary.itemMatches(mat, p_82789_2_, false)) return true;
+ return super.func_82789_a(p_82789_1_, p_82789_2_);
}
public Multimap func_111205_h()

View File

@ -19,7 +19,18 @@
}
public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_)
@@ -84,4 +96,38 @@
@@ -75,7 +87,9 @@
public boolean func_82789_a(ItemStack p_82789_1_, ItemStack p_82789_2_)
{
- return this.field_77862_b.func_150995_f() == p_82789_2_.func_77973_b() ? true : super.func_82789_a(p_82789_1_, p_82789_2_);
+ ItemStack mat = this.field_77862_b.getRepairItemStack();
+ if (mat != null && net.minecraftforge.oredict.OreDictionary.itemMatches(mat, p_82789_2_, false)) return true;
+ return super.func_82789_a(p_82789_1_, p_82789_2_);
}
public Multimap func_111205_h()
@@ -84,4 +98,38 @@
multimap.put(SharedMonsterAttributes.field_111264_e.func_111108_a(), new AttributeModifier(field_111210_e, "Tool modifier", (double)this.field_77865_bY, 0));
return multimap;
}