From c2108864003f8aae3395ca3815ca2c33dd7ee67d Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Thu, 5 Jan 2017 16:16:10 +0100 Subject: [PATCH] Fix #1559 --- .../forestry/api/arboriculture/IWoodProvider.java | 2 +- src/main/java/forestry/core/recipes/RecipeUtil.java | 5 +---- .../forestry/core/recipes/ShapedRecipeCustom.java | 9 ++++----- .../java/forestry/core/utils/InventoryUtil.java | 2 +- .../java/forestry/core/utils/ItemStackUtil.java | 13 +++++++------ src/main/java/forestry/core/utils/SlotUtil.java | 2 +- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/forestry/api/arboriculture/IWoodProvider.java b/src/main/java/forestry/api/arboriculture/IWoodProvider.java index d3eecd500..01a9b6d46 100644 --- a/src/main/java/forestry/api/arboriculture/IWoodProvider.java +++ b/src/main/java/forestry/api/arboriculture/IWoodProvider.java @@ -26,7 +26,7 @@ public interface IWoodProvider { * @return A stack of wood from the tree to craft wood pile's or other things. */ ItemStack getWoodStack(); - + /** * The amount of charcoal dropped from a charcoal pile of this wood. */ diff --git a/src/main/java/forestry/core/recipes/RecipeUtil.java b/src/main/java/forestry/core/recipes/RecipeUtil.java index 707f2b441..ce771e240 100644 --- a/src/main/java/forestry/core/recipes/RecipeUtil.java +++ b/src/main/java/forestry/core/recipes/RecipeUtil.java @@ -262,13 +262,10 @@ public abstract class RecipeUtil { } private static boolean checkIngredientMatch(@Nullable NonNullList recipeIngredient, ItemStack resource) { - if (recipeIngredient == null) { + if (recipeIngredient == null || recipeIngredient.isEmpty()) { return resource.isEmpty(); } for (ItemStack item : recipeIngredient) { - if(item.isEmpty() && resource.isEmpty()){ - return true; - } if (ItemStackUtil.isCraftingEquivalent(item, resource)) { return true; } diff --git a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java index 4e35907ee..6a12ff32c 100644 --- a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java @@ -119,13 +119,12 @@ public class ShapedRecipeCustom extends ShapedOreRecipe implements IDescriptiveR for (char chr : shape.toCharArray()) { NonNullList stacks = itemMap.get(chr); if (stacks != null) { - input.set(x++, stacks); + input.set(x, stacks); if(oreMap.get(chr) != null){ - oreDicts.set(x-1, oreMap.get(chr)); + oreDicts.set(x, oreMap.get(chr)); } - }else{ - input.set(x++, NonNullList.withSize(1, ItemStack.EMPTY)); } + x++; } } @@ -184,7 +183,7 @@ public class ShapedRecipeCustom extends ShapedOreRecipe implements IDescriptiveR ItemStack stackInSlot = inv.getStackInRowAndColumn(x, y); - if (target != null) { + if (target != null && !target.isEmpty()) { boolean matched = false; Iterator itr = target.iterator(); diff --git a/src/main/java/forestry/core/utils/InventoryUtil.java b/src/main/java/forestry/core/utils/InventoryUtil.java index 824c34340..2b5851893 100644 --- a/src/main/java/forestry/core/utils/InventoryUtil.java +++ b/src/main/java/forestry/core/utils/InventoryUtil.java @@ -299,7 +299,7 @@ public abstract class InventoryUtil { return ItemStack.EMPTY; } - private static ItemStack removeStack(IInventory inventory, ItemStack stackToRemove, String oreDictOfStack, @Nullable EntityPlayer player, boolean stowContainer, boolean craftingTools) { + private static ItemStack removeStack(IInventory inventory, ItemStack stackToRemove, @Nullable String oreDictOfStack, @Nullable EntityPlayer player, boolean stowContainer, boolean craftingTools) { for (int j = 0; j < inventory.getSizeInventory(); j++) { ItemStack stackInSlot = inventory.getStackInSlot(j); if (!stackInSlot.isEmpty()) { diff --git a/src/main/java/forestry/core/utils/ItemStackUtil.java b/src/main/java/forestry/core/utils/ItemStackUtil.java index 1110890c6..e9ac79eab 100644 --- a/src/main/java/forestry/core/utils/ItemStackUtil.java +++ b/src/main/java/forestry/core/utils/ItemStackUtil.java @@ -335,8 +335,8 @@ public abstract class ItemStackUtil { * Compare two item stacks for crafting equivalency. */ public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean oreDictionary, boolean craftingTools) { - if (!isCraftingEquivalent(base, comparison, craftingTools)) { - return false; + if (isCraftingEquivalent(base, comparison, craftingTools)) { + return true; } if (oreDictionary) { @@ -357,6 +357,7 @@ public abstract class ItemStackUtil { return true; } } + return false; } return false; @@ -365,12 +366,12 @@ public abstract class ItemStackUtil { /** * 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; + public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, @Nullable String oreDict, boolean craftingTools) { + if(isCraftingEquivalent(base, comparison, craftingTools)){ + return true; } - if (!oreDict.isEmpty()) { + if (oreDict != null && !oreDict.isEmpty()) { int[] baseIds = OreDictionary.getOreIDs(base); int validID = OreDictionary.getOreID(oreDict); diff --git a/src/main/java/forestry/core/utils/SlotUtil.java b/src/main/java/forestry/core/utils/SlotUtil.java index f69691277..e3e178649 100644 --- a/src/main/java/forestry/core/utils/SlotUtil.java +++ b/src/main/java/forestry/core/utils/SlotUtil.java @@ -204,7 +204,7 @@ public abstract class SlotUtil { int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit()); stackInSlot = stackToShift.copy(); stackInSlot.setCount(Math.min(stackToShift.getCount(), max)); - stackInSlot.shrink(stackInSlot.getCount()); + stackToShift.shrink(stackInSlot.getCount()); slot.putStack(stackInSlot); slot.onSlotChanged(); changed = true;