Fixed addition to generic inventories.

This commit is contained in:
SirSengir 2012-07-20 16:02:04 +02:00
parent b8ed333b73
commit 372d090a67
2 changed files with 20 additions and 13 deletions

View file

@ -93,7 +93,8 @@ public class StackUtil {
if(used <= 0) if(used <= 0)
return false; return false;
items.stackSize -= used; if(add)
items.stackSize -= used;
return true; return true;
} }
@ -143,12 +144,14 @@ public class StackUtil {
if (added) if (added)
if (!add) if (!add)
return true; return true;
else if (items.stackSize - itemsAdded == 0)
return true;
else { else {
checkAvailableSlot(inventory, added, from); items.stackSize -= itemsAdded;
itemsAdded = 0;
return true; if (items.stackSize == 0)
return true;
else
checkAvailableSlot(inventory, added, from);
return true;
} }
// If none, then create a new thing // If none, then create a new thing
@ -186,6 +189,7 @@ public class StackUtil {
} else { } else {
// This is a generic inventory // This is a generic inventory
IInventory inv = Utils.getInventory(inventory); IInventory inv = Utils.getInventory(inventory);
System.out.println("Adding to generic inventory.");
for (int j = 0; j < inv.getSizeInventory(); ++j) for (int j = 0; j < inv.getSizeInventory(); ++j)
if (tryAdding(inv, j, add, true)) { if (tryAdding(inv, j, add, true)) {
@ -195,15 +199,17 @@ public class StackUtil {
} }
// If the inventory if full, return false // If the inventory if full, return false
if (added) { if (added) {
if (!add) if (!add)
return true; return true;
else if (items.stackSize - itemsAdded == 0)
return true;
else { else {
checkAvailableSlot(inventory, added, from); items.stackSize -= itemsAdded;
return true; itemsAdded = 0;
if (items.stackSize == 0)
return true;
else
checkAvailableSlot(inventory, added, from);
return true;
} }
} else } else
return false; return false;

View file

@ -128,8 +128,9 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
* on the position of the pipe. * on the position of the pipe.
*/ */
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, Orientations from) { public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, Orientations from) {
/// ISPECIALINVENTORY
if (inventory instanceof ISpecialInventory) if (inventory instanceof ISpecialInventory)
// TAKE INTO ACCOUNT SPECIAL INVENTORIES!!!
return ((ISpecialInventory) inventory).extractItem(doRemove, from, 1); return ((ISpecialInventory) inventory).extractItem(doRemove, from, 1);
if (inventory instanceof ISidedInventory) { if (inventory instanceof ISidedInventory) {