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

This commit is contained in:
Lex Manos 2014-12-07 04:29:55 -08:00
parent 83bcebf3b1
commit 35fac1f691
3 changed files with 89 additions and 34 deletions

View file

@ -43,6 +43,15 @@
public class Item
{
@@ -64,7 +74,7 @@
protected String field_111218_cA;
private static final String __OBFID = "CL_00000041";
- public final cpw.mods.fml.common.registry.RegistryDelegate<Item> delegate =
+ public final cpw.mods.fml.common.registry.RegistryDelegate<Item> delegate =
((cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry)field_150901_e).getDelegate(this, Item.class);
public static int func_150891_b(Item p_150891_0_)
{
@@ -450,6 +460,7 @@
return p_77654_1_;
}
@ -696,18 +705,22 @@
public static enum ToolMaterial
{
WOOD(0, 59, 2.0F, 0.0F, 15),
@@ -743,6 +1346,9 @@
@@ -743,6 +1346,10 @@
private static final String __OBFID = "CL_00000042";
+ //Added by forge for custom Tool materials.
+ public Item customCraftingMaterial = null;
+ @Deprecated public Item customCraftingMaterial = null;
+ 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_;
@@ -779,7 +1385,15 @@
@@ -777,9 +1384,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))));
@ -721,5 +734,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
@@ -101,7 +101,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

@ -34,7 +34,18 @@
}
public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_)
@@ -83,4 +97,37 @@
@@ -74,7 +88,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()
@@ -83,4 +99,37 @@
multimap.put(SharedMonsterAttributes.field_111264_e.func_111108_a(), new AttributeModifier(field_111210_e, "Tool modifier", (double)this.field_77865_bY, 0));
return multimap;
}