From ad6511d765261a3ec8c0a617fb7eb36e1613a4f2 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Sat, 20 Sep 2014 01:44:50 -0400 Subject: [PATCH] Comp drawers "mostly" ore dictionary compatible. Tiers not guaranteed to be found if mod uses custom IRecipes. I'M LOOKING AT YOU MEKANISM! --- .../storagedrawers/block/tile/DrawerData.java | 31 +++++++++++++++++++ .../block/tile/TileEntityCompDrawers.java | 6 ++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/DrawerData.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/DrawerData.java index fa021c4..42a9444 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/DrawerData.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/DrawerData.java @@ -165,4 +165,35 @@ public class DrawerData return ItemStack.areItemStackTagsEqual(protoStack, stack); } + + public static boolean areItemsEqual (ItemStack stack1, ItemStack stack2) { + if (stack1 == null || stack2 == null) + return false; + if (stack1.getItem() == null || stack2.getItem() == null) + return false; + + if (!stack1.isItemEqual(stack2)) { + int[] ids1 = OreDictionary.getOreIDs(stack1); + int[] ids2 = OreDictionary.getOreIDs(stack2); + if (ids1.length == 0 || ids2.length == 0) + return false; + + boolean oreMatch = false; + + BRK_ORE_MATCH: + for (int i = 0; i < ids1.length; i++) { + for (int j = 0; j < ids2.length; j++) { + if (ids1[i] == ids2[j]) { + oreMatch = true; + break BRK_ORE_MATCH; + } + } + } + + if (!oreMatch) + return false; + } + + return ItemStack.areItemStackTagsEqual(stack1, stack2); + } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityCompDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityCompDrawers.java index a84bb82..4c610c2 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityCompDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityCompDrawers.java @@ -330,7 +330,7 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto setupLookup(lookup1, match); ItemStack comp = cm.findMatchingRecipe(lookup1, worldObj); - if (comp == null || !comp.isItemEqual(stack) || !ItemStack.areItemStackTagsEqual(comp, stack) || comp.stackSize != size) + if (!DrawerData.areItemsEqual(comp, stack) || comp.stackSize != size) return null; lookupSizeResult = size; @@ -354,7 +354,7 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto ItemStack match = null; ItemStack output = recipe.getRecipeOutput(); - if (output == null || !stack.isItemEqual(recipe.getRecipeOutput())) + if (!DrawerData.areItemsEqual(stack, output)) continue; if (recipe instanceof ShapelessOreRecipe) @@ -369,7 +369,7 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto if (match != null) { setupLookup(lookup1, stack); ItemStack comp = cm.findMatchingRecipe(lookup1, worldObj); - if (comp != null && comp.isItemEqual(match) && ItemStack.areItemStackTagsEqual(comp, match) && comp.stackSize == recipe.getRecipeSize()) { + if (DrawerData.areItemsEqual(match, comp) && comp.stackSize == recipe.getRecipeSize()) { lookupSizeResult = recipe.getRecipeSize(); return match; }