From b1d496f24f040d8f9cdc663f61eb792854d367f7 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 29 Sep 2015 21:07:23 -0700 Subject: [PATCH] Fix #858 sometimes can't craft with multiple GregTech tools in Worktable --- .../forestry/core/utils/ItemStackUtil.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/java/forestry/core/utils/ItemStackUtil.java b/src/main/java/forestry/core/utils/ItemStackUtil.java index 9f787f077..0a7998b00 100644 --- a/src/main/java/forestry/core/utils/ItemStackUtil.java +++ b/src/main/java/forestry/core/utils/ItemStackUtil.java @@ -202,7 +202,7 @@ public abstract class ItemStackUtil { return false; } - if (craftingTools && isCraftingTool(base) && base.getItem() == comparison.getItem()) { + if (craftingTools && isCraftingToolEquivalent(base, comparison)) { return true; } @@ -235,19 +235,30 @@ public abstract class ItemStackUtil { return false; } - public static boolean isCraftingTool(ItemStack itemstack) { - Item item = itemstack.getItem(); - if (item == null) { + public static boolean isCraftingToolEquivalent(ItemStack base, ItemStack comparison) { + if (base == null || comparison == null) { return false; } - if (item.hasContainerItem(itemstack)) { - if (item.isDamageable() || itemstack.hasTagCompound()) { - return !item.doesContainerItemLeaveCraftingGrid(itemstack); - } + Item baseItem = base.getItem(); + if (baseItem.doesContainerItemLeaveCraftingGrid(base)) { + return false; } - return false; + if (baseItem != comparison.getItem()) { + return false; + } + + if (base.stackTagCompound == null || base.stackTagCompound.hasNoTags()) { + // tool uses meta for damage + return true; + } else { + // tool uses NBT for damage + if (base.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + return true; + } + return base.getItemDamage() == comparison.getItemDamage(); + } } public static void dropItemStackAsEntity(ItemStack items, World world, double x, double y, double z) {