diff --git a/src/main/java/forestry/core/utils/InventoryUtil.java b/src/main/java/forestry/core/utils/InventoryUtil.java index 8b2161382..824c34340 100644 --- a/src/main/java/forestry/core/utils/InventoryUtil.java +++ b/src/main/java/forestry/core/utils/InventoryUtil.java @@ -263,7 +263,7 @@ public abstract class InventoryUtil { stackToRemove.setCount(stackToRemove.getCount() * count); // try to remove the exact stack first - ItemStack removedStack = removeStack(inventory, stackToRemove, player, stowContainer, false, false); + ItemStack removedStack = removeStack(inventory, stackToRemove, null, player, stowContainer, false); if (removedStack.isEmpty()) { // remove crafting equivalents next removedStack = removeStack(inventory, stackToRemove, oreDicts.get(i), player, stowContainer, craftingTools); diff --git a/src/main/java/forestry/core/utils/ItemStackUtil.java b/src/main/java/forestry/core/utils/ItemStackUtil.java index b74d351a9..1110890c6 100644 --- a/src/main/java/forestry/core/utils/ItemStackUtil.java +++ b/src/main/java/forestry/core/utils/ItemStackUtil.java @@ -331,68 +331,14 @@ public abstract class ItemStackUtil { } } - /** - * Compare two item stacks for crafting equivalency. - */ - public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, String oreDict, boolean craftingTools) { - if (base.isEmpty() || comparison.isEmpty()) { - return false; - } - - if (craftingTools && isCraftingToolEquivalent(base, comparison)) { - return true; - } - - if (isCraftingEquivalent(base, comparison)) { - return true; - } - - if (base.getTagCompound() != null && !base.getTagCompound().hasNoTags()) { - if (!ItemStack.areItemStacksEqual(base, comparison)) { - return false; - } - } - - if (!oreDict.isEmpty()) { - int[] idsBase = OreDictionary.getOreIDs(base); - Arrays.sort(idsBase); - int idComp = OreDictionary.getOreID(oreDict); - - int iBase = 0; - while (iBase < idsBase.length) { - if (idsBase[iBase] == idComp) { - iBase++; - } else { - return true; - } - } - } - - return false; - } - /** * Compare two item stacks for crafting equivalency. */ public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean oreDictionary, boolean craftingTools) { - if (base.isEmpty() || comparison.isEmpty()) { + if (!isCraftingEquivalent(base, comparison, craftingTools)) { return false; } - if (craftingTools && isCraftingToolEquivalent(base, comparison)) { - return true; - } - - if (isCraftingEquivalent(base, comparison)) { - return true; - } - - if (base.getTagCompound() != null && !base.getTagCompound().hasNoTags()) { - if (!ItemStack.areItemStacksEqual(base, comparison)) { - return false; - } - } - if (oreDictionary) { int[] idsBase = OreDictionary.getOreIDs(base); Arrays.sort(idsBase); @@ -415,6 +361,50 @@ public abstract class ItemStackUtil { return false; } + + /** + * Compare two item stacks for crafting equivalency. + */ + public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, String oreDict, boolean craftingTools) { + if(!isCraftingEquivalent(base, comparison, craftingTools)){ + return false; + } + + if (!oreDict.isEmpty()) { + int[] baseIds = OreDictionary.getOreIDs(base); + int validID = OreDictionary.getOreID(oreDict); + + for(int id : baseIds){ + if (id == validID) { + return true; + } + } + } + + return false; + } + + public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean craftingTools) { + if (base.isEmpty() || comparison.isEmpty()) { + return false; + } + + if (craftingTools && isCraftingToolEquivalent(base, comparison)) { + return true; + } + + if (isCraftingEquivalent(base, comparison)) { + return true; + } + + if (base.getTagCompound() != null && !base.getTagCompound().hasNoTags()) { + if (!ItemStack.areItemStacksEqual(base, comparison)) { + return false; + } + } + + return false; + } public static boolean isCraftingToolEquivalent(ItemStack base, ItemStack comparison) { if (base.isEmpty() || comparison.isEmpty()) {