From ab87cc706eeedf14bad1d44372f02b3fcf3de0a7 Mon Sep 17 00:00:00 2001 From: Vexatos Date: Sun, 21 Sep 2014 11:43:53 +0200 Subject: [PATCH] Reverted Tool Recipe changes, made colorizing use NBT --- .../library/crafting/ToolBuilder.java | 26 ++++++------- .../library/crafting/ToolRecipe.java | 39 +++++++++---------- .../tconstruct/library/tools/ToolCore.java | 19 ++++----- src/main/java/tconstruct/tools/BowRecipe.java | 7 ++-- 4 files changed, 43 insertions(+), 48 deletions(-) diff --git a/src/main/java/tconstruct/library/crafting/ToolBuilder.java b/src/main/java/tconstruct/library/crafting/ToolBuilder.java index 12592bf44b5..f36790e35ed 100644 --- a/src/main/java/tconstruct/library/crafting/ToolBuilder.java +++ b/src/main/java/tconstruct/library/crafting/ToolBuilder.java @@ -29,8 +29,8 @@ public static void addNormalToolRecipe (ToolCore output, Item head, Item handle) ToolRecipe recipe = instance.recipeList.get(output.getToolName()); if (recipe != null) { - recipe.addHeadItem(new ItemStack(head)); - recipe.addHandleItem(new ItemStack(handle)); + recipe.addHeadItem(head); + recipe.addHandleItem(handle); } else { @@ -46,9 +46,9 @@ public static void addNormalToolRecipe (ToolCore output, Item head, Item handle, ToolRecipe recipe = instance.recipeList.get(output.getToolName()); if (recipe != null) { - recipe.addHeadItem(new ItemStack(head)); - recipe.addHandleItem(new ItemStack(handle)); - recipe.addAccessoryItem(new ItemStack(accessory)); + recipe.addHeadItem(head); + recipe.addHandleItem(handle); + recipe.addAccessoryItem(accessory); } else { @@ -63,10 +63,10 @@ public static void addNormalToolRecipe (ToolCore output, Item head, Item handle, ToolRecipe recipe = instance.recipeList.get(output.getToolName()); if (recipe != null) { - recipe.addHeadItem(new ItemStack(head)); - recipe.addHandleItem(new ItemStack(handle)); - recipe.addAccessoryItem(new ItemStack(accessory)); - recipe.addExtraItem(new ItemStack(extra)); + recipe.addHeadItem(head); + recipe.addHandleItem(handle); + recipe.addAccessoryItem(accessory); + recipe.addExtraItem(extra); } else { @@ -91,7 +91,7 @@ public static void addToolRecipe (ToolCore output, Item... items) addNormalToolRecipe(output, items[0], items[1], items[2], items[3]); } - public ToolCore getMatchingRecipe (ItemStack head, ItemStack handle, ItemStack accessory, ItemStack extra) + public ToolCore getMatchingRecipe (Item head, Item handle, Item accessory, Item extra) { for (ToolRecipe recipe : combos) { @@ -156,7 +156,7 @@ public ItemStack buildTool (ItemStack headStack, ItemStack handleStack, ItemStac if (accessoryStack == null) { - item = getMatchingRecipe(headStack, handleStack, null, null); + item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), null, null); } else { @@ -172,11 +172,11 @@ public ItemStack buildTool (ItemStack headStack, ItemStack handleStack, ItemStac if (extra == -1) return null; - item = getMatchingRecipe(headStack, handleStack, accessoryStack, extraStack); + item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), extraStack.getItem()); } else { - item = getMatchingRecipe(headStack, handleStack, accessoryStack, null); + item = getMatchingRecipe(headStack.getItem(), handleStack.getItem(), accessoryStack.getItem(), null); } } diff --git a/src/main/java/tconstruct/library/crafting/ToolRecipe.java b/src/main/java/tconstruct/library/crafting/ToolRecipe.java index 10413ebd86d..8466fb9e1d9 100644 --- a/src/main/java/tconstruct/library/crafting/ToolRecipe.java +++ b/src/main/java/tconstruct/library/crafting/ToolRecipe.java @@ -3,7 +3,6 @@ import java.util.LinkedList; import net.minecraft.init.Items; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import tconstruct.library.TConstructRegistry; import tconstruct.library.tools.ToolCore; @@ -46,49 +45,49 @@ public ToolRecipe(Item head, Item handle, Item accessory, Item extra, ToolCore t result = tool; } - public void addHeadItem (ItemStack head) + public void addHeadItem (Item head) { - this.headList.add(head.getItem()); + this.headList.add(head); } - public void addHandleItem (ItemStack handle) + public void addHandleItem (Item head) { - this.handleList.add(handle.getItem()); + this.handleList.add(head); } - public void addAccessoryItem (ItemStack accessory) + public void addAccessoryItem (Item head) { - this.accessoryList.add(accessory.getItem()); + this.accessoryList.add(head); } - public void addExtraItem (ItemStack extra) + public void addExtraItem (Item head) { - this.extraList.add(extra.getItem()); + this.extraList.add(head); } - public boolean validHead (ItemStack input) + public boolean validHead (Item input) { for (Item part : headList) { - if (part == input.getItem()) + if (part == input) return true; } return false; } - public boolean validHandle (ItemStack input) + public boolean validHandle (Item input) { for (Item part : handleList) { - if (part == input.getItem()) + if (part == input) return true; - if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone)) + if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone)) return true; } return false; } - public boolean validAccessory (ItemStack input) + public boolean validAccessory (Item input) { if (input == null) { @@ -98,15 +97,15 @@ public boolean validAccessory (ItemStack input) } for (Item part : accessoryList) { - if (part == input.getItem()) + if (part == input) return true; - if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone)) + if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone)) return true; } return false; } - public boolean validExtra (ItemStack input) + public boolean validExtra (Item input) { if (input == null) { @@ -116,9 +115,9 @@ public boolean validExtra (ItemStack input) } for (Item part : extraList) { - if (part == input.getItem()) + if (part == input) return true; - if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone)) + if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone)) return true; } return false; diff --git a/src/main/java/tconstruct/library/tools/ToolCore.java b/src/main/java/tconstruct/library/tools/ToolCore.java index 9a72c99086f..e8d6d77399f 100644 --- a/src/main/java/tconstruct/library/tools/ToolCore.java +++ b/src/main/java/tconstruct/library/tools/ToolCore.java @@ -662,9 +662,6 @@ public float getDamageModifier () return 1.0f; } - - public static HashMap materialColorMap = new HashMap(); - @Override public int getColorFromItemStack(ItemStack stack, int renderPass) { @@ -675,24 +672,24 @@ public int getColorFromItemStack(ItemStack stack, int renderPass) { tags = stack.getTagCompound().getCompoundTag("InfiTool"); if (renderPass < getPartAmount()) { - if (renderPass == 0 && materialColorMap.containsKey(tags.getInteger("Handle"))) // Handle + if (renderPass == 0 && tags.hasKey("HandleColor")) // Handle { - return materialColorMap.get(tags.getInteger("Handle")); + return tags.getInteger("HandleColor"); } - else if (renderPass == 1 && materialColorMap.containsKey(tags.getInteger("Head"))) // Head + else if (renderPass == 1 && tags.hasKey("HeadColor")) // Head { - return materialColorMap.get(tags.getInteger("Head")); + return tags.getInteger("HeadColor"); } - else if (renderPass == 2 && materialColorMap.containsKey(tags.getInteger("Accessory"))) // Accessory + else if (renderPass == 2 && tags.hasKey("AccessoryColor")) // Accessory { - return materialColorMap.get(tags.getInteger("Accessory")); + return tags.getInteger("AccessoryColor"); } - else if (renderPass == 3 && materialColorMap.containsKey(tags.getInteger("Extra"))) // Extra + else if (renderPass == 3 && tags.hasKey("ExtraColor")) // Extra { - return materialColorMap.get(tags.getInteger("Extra")); + return tags.getInteger("ExtraColor"); } } } diff --git a/src/main/java/tconstruct/tools/BowRecipe.java b/src/main/java/tconstruct/tools/BowRecipe.java index 8202f1b606d..cffcb74477f 100644 --- a/src/main/java/tconstruct/tools/BowRecipe.java +++ b/src/main/java/tconstruct/tools/BowRecipe.java @@ -2,7 +2,6 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import tconstruct.library.crafting.ToolRecipe; import tconstruct.library.tools.ToolCore; @@ -25,13 +24,13 @@ public BowRecipe(Item head, Item handle, Item accessory, Item extra, ToolCore to } @Override - public boolean validHead (ItemStack input) + public boolean validHead (Item input) { for (Item part : headList) { - if (part == input.getItem()) + if (part == input) return true; - if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone)) + if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone)) return true; } return false;