From 446f94770d41b3515e58335e4fc66cc7902e2ffd Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Fri, 8 May 2015 21:07:59 +0100 Subject: [PATCH] Added untested OreDictionary support --- .../techreborn/api/recipe/RecipeCrafter.java | 8 ++++---- src/main/java/techreborn/util/ItemUtils.java | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/techreborn/api/recipe/RecipeCrafter.java b/src/main/java/techreborn/api/recipe/RecipeCrafter.java index 6159716d3..40d327b90 100644 --- a/src/main/java/techreborn/api/recipe/RecipeCrafter.java +++ b/src/main/java/techreborn/api/recipe/RecipeCrafter.java @@ -92,7 +92,7 @@ public class RecipeCrafter { for (IBaseRecipeType recipe : RecipeHanderer.getRecipeClassFromName(recipeName)) { boolean isFullRecipe = false; for (int i = 0; i < inputs; i++) { - if (ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), recipe.getInputs().get(i), true, true)) { + if (ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), recipe.getInputs().get(i), true, true, true)) { isFullRecipe = true; } else { isFullRecipe = false; @@ -105,7 +105,7 @@ public class RecipeCrafter { } } else { for (int i = 0; i < inputs; i++) { - if (!ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), currentRecipe.getInputs().get(i), true, true)) { + if (!ItemUtils.isItemEqual(inventory.getStackInSlot(inputSlots[i]), currentRecipe.getInputs().get(i), true, true, true)) { currentRecipe = null; currentTickTime = 0; return; @@ -150,7 +150,7 @@ public class RecipeCrafter { if (inventory.getStackInSlot(slot) == null) { return true; } - if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true)) { + if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, true)) { if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) { return true; } @@ -166,7 +166,7 @@ public class RecipeCrafter { inventory.setInventorySlotContents(slot, stack); return; } - if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true)) { + if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, true)) { if (stack.stackSize + inventory.getStackInSlot(slot).stackSize <= stack.getMaxStackSize()) { ItemStack newStack = stack.copy(); newStack.stackSize = inventory.getStackInSlot(slot).stackSize + stack.stackSize; diff --git a/src/main/java/techreborn/util/ItemUtils.java b/src/main/java/techreborn/util/ItemUtils.java index 476ed1b1d..14d2a71eb 100644 --- a/src/main/java/techreborn/util/ItemUtils.java +++ b/src/main/java/techreborn/util/ItemUtils.java @@ -6,10 +6,13 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.oredict.OreDictionary; +import java.util.List; + /** * Created by mark on 12/04/15. */ public class ItemUtils { + public static boolean isItemEqual(final ItemStack a, final ItemStack b, final boolean matchDamage, final boolean matchNBT) { @@ -29,6 +32,19 @@ public class ItemUtils { return true; } + public static boolean isItemEqual(ItemStack a, ItemStack b, + boolean matchDamage, boolean matchNBT, boolean useOreDic) + { + if(isItemEqual(a, b, matchDamage, matchNBT)){ + return true; + } + if (a == null || b == null) + return false; + + return OreDictionary.itemMatches(a, b, false); + } + + public static boolean isWildcard(ItemStack stack) { return isWildcard(stack.getItemDamage());