From 372d090a6723800e74d3b553fd305ed1a2eca5f6 Mon Sep 17 00:00:00 2001 From: SirSengir Date: Fri, 20 Jul 2012 16:02:04 +0200 Subject: [PATCH] Fixed addition to generic inventories. --- .../src/buildcraft/core/StackUtil.java | 30 +++++++++++-------- .../transport/pipes/PipeItemsWood.java | 3 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/common/net/minecraft/src/buildcraft/core/StackUtil.java b/common/net/minecraft/src/buildcraft/core/StackUtil.java index 4215d6f0..1d8bff53 100644 --- a/common/net/minecraft/src/buildcraft/core/StackUtil.java +++ b/common/net/minecraft/src/buildcraft/core/StackUtil.java @@ -93,7 +93,8 @@ public class StackUtil { if(used <= 0) return false; - items.stackSize -= used; + if(add) + items.stackSize -= used; return true; } @@ -132,7 +133,7 @@ public class StackUtil { } else { // This is a generic inventory IInventory inv = Utils.getInventory(inventory); - + for (int j = 0; j < inv.getSizeInventory(); ++j) if (tryAdding(inv, j, add, false)) { added = true; @@ -143,12 +144,14 @@ public class StackUtil { if (added) if (!add) return true; - else if (items.stackSize - itemsAdded == 0) - return true; else { - checkAvailableSlot(inventory, added, from); - - return true; + items.stackSize -= itemsAdded; + itemsAdded = 0; + if (items.stackSize == 0) + return true; + else + checkAvailableSlot(inventory, added, from); + return true; } // If none, then create a new thing @@ -186,6 +189,7 @@ public class StackUtil { } else { // This is a generic inventory IInventory inv = Utils.getInventory(inventory); + System.out.println("Adding to generic inventory."); for (int j = 0; j < inv.getSizeInventory(); ++j) if (tryAdding(inv, j, add, true)) { @@ -195,15 +199,17 @@ public class StackUtil { } // If the inventory if full, return false - if (added) { if (!add) return true; - else if (items.stackSize - itemsAdded == 0) - return true; else { - checkAvailableSlot(inventory, added, from); - return true; + items.stackSize -= itemsAdded; + itemsAdded = 0; + if (items.stackSize == 0) + return true; + else + checkAvailableSlot(inventory, added, from); + return true; } } else return false; diff --git a/common/net/minecraft/src/buildcraft/transport/pipes/PipeItemsWood.java b/common/net/minecraft/src/buildcraft/transport/pipes/PipeItemsWood.java index 66a9f1c6..00ff41b1 100644 --- a/common/net/minecraft/src/buildcraft/transport/pipes/PipeItemsWood.java +++ b/common/net/minecraft/src/buildcraft/transport/pipes/PipeItemsWood.java @@ -128,8 +128,9 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor { * on the position of the pipe. */ public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, Orientations from) { + + /// ISPECIALINVENTORY if (inventory instanceof ISpecialInventory) - // TAKE INTO ACCOUNT SPECIAL INVENTORIES!!! return ((ISpecialInventory) inventory).extractItem(doRemove, from, 1); if (inventory instanceof ISidedInventory) {