From c9f0ed0941781261389bb864efb6015a7e16a869 Mon Sep 17 00:00:00 2001 From: aidancbrady Date: Sat, 20 Feb 2016 11:33:45 -0500 Subject: [PATCH] Fix forestry sapling integration --- .../java/mekanism/api/util/StackUtils.java | 5 ----- .../recipe/inputs/AdvancedMachineInput.java | 2 +- .../common/recipe/inputs/InfusionInput.java | 5 ++++- .../common/recipe/inputs/ItemStackInput.java | 2 +- .../common/recipe/inputs/MachineInput.java | 18 ++++++++++++++++++ 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/mekanism/api/util/StackUtils.java b/src/main/java/mekanism/api/util/StackUtils.java index 7363c754d..567caeb20 100644 --- a/src/main/java/mekanism/api/util/StackUtils.java +++ b/src/main/java/mekanism/api/util/StackUtils.java @@ -236,11 +236,6 @@ public final class StackUtils } } - public static boolean contains(ItemStack container, ItemStack contained) - { - return equalsWildcardWithNBT(contained, container) && container.stackSize >= contained.stackSize; - } - public static int hashItemStack(ItemStack stack) { if(stack == null || stack.getItem() == null) diff --git a/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java index 0be91c476..0cba3c79a 100644 --- a/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java @@ -41,7 +41,7 @@ public class AdvancedMachineInput extends MachineInput public boolean useItem(ItemStack[] inventory, int index, boolean deplete) { - if(StackUtils.contains(inventory[index], itemStack)) + if(inputContains(inventory[index], itemStack)) { if(deplete) { diff --git a/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java index 26a57f574..840443291 100644 --- a/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java @@ -56,15 +56,17 @@ public class InfusionInput extends MachineInput public boolean use(ItemStack[] inventory, int index, InfuseStorage infuseStorage, boolean deplete) { - if(StackUtils.contains(inventory[index], inputStack) && infuseStorage.contains(infuse)) + if(inputContains(inventory[index], inputStack) && infuseStorage.contains(infuse)) { if(deplete) { inventory[index] = StackUtils.subtract(inventory[index], inputStack); infuseStorage.subtract(infuse); } + return true; } + return false; } @@ -81,6 +83,7 @@ public class InfusionInput extends MachineInput { return !other.isValid(); } + return infuse.type == other.infuse.type && StackUtils.equalsWildcardWithNBT(inputStack, other.inputStack); } diff --git a/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java index d0d5d898d..76d0a8b7f 100644 --- a/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java @@ -41,7 +41,7 @@ public class ItemStackInput extends MachineInput public boolean useItemStackFromInventory(ItemStack[] inventory, int index, boolean deplete) { - if(StackUtils.contains(inventory[index], ingredient)) + if(inputContains(inventory[index], ingredient)) { if(deplete) { diff --git a/src/main/java/mekanism/common/recipe/inputs/MachineInput.java b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java index dd6bbff71..04824923b 100644 --- a/src/main/java/mekanism/common/recipe/inputs/MachineInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java @@ -1,5 +1,8 @@ package mekanism.common.recipe.inputs; +import mekanism.api.util.StackUtils; +import mekanism.common.util.MekanismUtils; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public abstract class MachineInput> @@ -21,6 +24,21 @@ public abstract class MachineInput> * @return */ public abstract boolean testEquality(INPUT other); + + public static boolean inputContains(ItemStack container, ItemStack contained) + { + if(container.stackSize >= contained.stackSize) + { + if(MekanismUtils.getOreDictName(container).contains("treeSapling")) + { + return StackUtils.equalsWildcard(contained, container); + } + + return StackUtils.equalsWildcardWithNBT(contained, container) && container.stackSize >= contained.stackSize; + } + + return false; + } @Override public int hashCode()