From 6fb07b9d40d3973bcb906b0d0ac1b2575c04545f Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 11 Nov 2014 19:07:27 -0800 Subject: [PATCH 1/3] Fix #325 Centrifuge dupe bug --- .../java/forestry/factory/gadgets/MachineCentrifuge.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index 587f62f8a..e213978bd 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -446,13 +446,14 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I @Override public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - if (inventory.getStackInSlot(SLOT_RESOURCE) == null) { + ItemStack resource = inventory.getStackInSlot(SLOT_RESOURCE); + if (resource == null) { if (doAdd) inventory.setInventorySlotContents(SLOT_RESOURCE, stack.copy()); return stack.stackSize; } - if (!inventory.getStackInSlot(SLOT_RESOURCE).isItemEqual(stack)) + if (!StackUtils.isIdenticalItem(resource, stack)) return 0; int space = inventory.getStackInSlot(SLOT_RESOURCE).getMaxStackSize() - inventory.getStackInSlot(SLOT_RESOURCE).stackSize; From e5286092128733012f7d1e9885a6797a6e72db36 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 11 Nov 2014 19:07:47 -0800 Subject: [PATCH 2/3] Minor code cleanup --- .../forestry/core/utils/ShapedRecipeCustom.java | 2 +- .../factory/gadgets/MachineCentrifuge.java | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java index bb1460a45..5ca111b38 100755 --- a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java @@ -135,7 +135,7 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { if (resource == null && compare == null) return true; - if (resource == null && compare != null || resource != null && compare == null) + if (resource == null || compare == null) return false; if (compare.getItem() != resource.getItem()) diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index e213978bd..dbf8f03f2 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -64,9 +64,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I public boolean matches(ItemStack res) { if (res == null && resource == null) return true; - else if (res == null && resource != null) - return false; - else if (res != null && resource == null) + else if (res == null || resource == null) return false; else return resource.isItemEqual(res); @@ -428,10 +426,11 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I ItemStack product = null; for (int i = SLOT_PRODUCT_1; i < inventory.getSizeInventory(); i++) { - if (inventory.getStackInSlot(i) == null) + ItemStack stack = inventory.getStackInSlot(i); + if (stack == null) continue; - product = new ItemStack(inventory.getStackInSlot(i).getItem(), 1, inventory.getStackInSlot(i).getItemDamage()); + product = StackUtils.createSplitStack(stack, 1); if (doRemove) decrStackSize(i, 1); @@ -456,15 +455,15 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I if (!StackUtils.isIdenticalItem(resource, stack)) return 0; - int space = inventory.getStackInSlot(SLOT_RESOURCE).getMaxStackSize() - inventory.getStackInSlot(SLOT_RESOURCE).stackSize; + int space = resource.getMaxStackSize() - resource.stackSize; if (space <= 0) return 0; if (doAdd) if (stack.stackSize <= space) - inventory.getStackInSlot(SLOT_RESOURCE).stackSize += stack.stackSize; + resource.stackSize += stack.stackSize; else - inventory.getStackInSlot(SLOT_RESOURCE).stackSize += space; + resource.stackSize += space; return Math.min(stack.stackSize, space); } From 267905ef3f901bde1db4c1402ddca2e5b5ef5cbe Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 11 Nov 2014 19:54:34 -0800 Subject: [PATCH 3/3] Fix #326 decorative leaves should not pollinate --- src/main/java/forestry/arboriculture/gadgets/TileLeaves.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 43aa22912..13078037a 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -96,7 +96,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru maturationTime = nbttagcompound.getInteger("CATMAT"); caterpillar = (IButterfly)AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies").getMember(nbttagcompound.getCompoundTag("CATER")); } - + isDecorative = nbttagcompound.getBoolean("Decorative"); } @Override @@ -114,7 +114,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru caterpillar.writeToNBT(subcompound); nbttagcompound.setTag("CATER", subcompound); } - + nbttagcompound.setBoolean("Decorative", isDecorative); } @Override