mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-21 12:42:24 +00:00
Comp drawers "mostly" ore dictionary compatible. Tiers not guaranteed to be found if mod uses custom IRecipes. I'M LOOKING AT YOU MEKANISM!
This commit is contained in:
1 parent
a90825101f
commit
ad6511d765
2 files changed
+34
-3
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user