Fixed an item stacking issue with crates

Manipulators were not stacking items in crates above the items max stack
limit.
This commit is contained in:
Rseifert 2013-02-22 13:16:00 -05:00
parent caf4f11c30
commit 09f5353faa
2 changed files with 15 additions and 29 deletions

View file

@ -331,7 +331,7 @@ public class BlockCrate extends BlockMachine
* @param tileEntity * @param tileEntity
* @param itemStack * @param itemStack
*/ */
private ItemStack putIn(TileEntityCrate tileEntity, ItemStack itemStack) public static ItemStack putIn(TileEntityCrate tileEntity, ItemStack itemStack)
{ {
ItemStack containingStack = tileEntity.getStackInSlot(0); ItemStack containingStack = tileEntity.getStackInSlot(0);

View file

@ -17,6 +17,8 @@ import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.multiblock.TileEntityMulti; import universalelectricity.prefab.multiblock.TileEntityMulti;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import assemblyline.api.IManipulator; import assemblyline.api.IManipulator;
import assemblyline.common.block.BlockCrate;
import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.imprinter.TileEntityFilterable; import assemblyline.common.machine.imprinter.TileEntityFilterable;
import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.PacketDispatcher;
@ -87,8 +89,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
} }
/** /**
* Find items going into the manipulator and input them into an inventory behind this * Find items going into the manipulator and input them into an inventory behind this manipulator.
* manipulator.
*/ */
@Override @Override
public void eject() public void eject()
@ -109,10 +110,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
*/ */
if (outputPosition.getTileEntity(this.worldObj) instanceof TileEntityManipulator) if (outputPosition.getTileEntity(this.worldObj) instanceof TileEntityManipulator)
{ {
if (((TileEntityManipulator) outputPosition.getTileEntity(this.worldObj)).getDirection() == this.getDirection().getOpposite()) if (((TileEntityManipulator) outputPosition.getTileEntity(this.worldObj)).getDirection() == this.getDirection().getOpposite()) { return; }
{
return;
}
} }
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(inputPosition.x, inputPosition.y, inputPosition.z, inputPosition.x + 1, inputPosition.y + 1, inputPosition.z + 1); AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(inputPosition.x, inputPosition.y, inputPosition.z, inputPosition.x + 1, inputPosition.y + 1, inputPosition.z + 1);
@ -124,8 +122,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
continue; continue;
/** /**
* Try top first, then bottom, then the sides to see if it is possible to insert the * Try top first, then bottom, then the sides to see if it is possible to insert the item into a inventory.
* item into a inventory.
*/ */
ItemStack remainingStack = entity.getEntityItem().copy(); ItemStack remainingStack = entity.getEntityItem().copy();
@ -273,6 +270,10 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
} }
} }
} }
else if (tileEntity instanceof TileEntityCrate)
{
return BlockCrate.putIn((TileEntityCrate) tileEntity, itemStack);
}
else if (tileEntity instanceof ISidedInventory) else if (tileEntity instanceof ISidedInventory)
{ {
ISidedInventory inventory = (ISidedInventory) tileEntity; ISidedInventory inventory = (ISidedInventory) tileEntity;
@ -282,10 +283,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
for (int i = startIndex; i < startIndex + inventory.getSizeInventorySide(direction); i++) for (int i = startIndex; i < startIndex + inventory.getSizeInventorySide(direction); i++)
{ {
itemStack = this.addStackToInventory(i, inventory, itemStack); itemStack = this.addStackToInventory(i, inventory, itemStack);
if (itemStack == null) if (itemStack == null) { return null; }
{
return null;
}
} }
} }
else if (tileEntity instanceof IInventory) else if (tileEntity instanceof IInventory)
@ -295,18 +293,12 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
for (int i = 0; i < inventory.getSizeInventory(); i++) for (int i = 0; i < inventory.getSizeInventory(); i++)
{ {
itemStack = this.addStackToInventory(i, inventory, itemStack); itemStack = this.addStackToInventory(i, inventory, itemStack);
if (itemStack == null) if (itemStack == null) { return null; }
{
return null;
}
} }
} }
} }
if (itemStack.stackSize <= 0) if (itemStack.stackSize <= 0) { return null; }
{
return null;
}
return itemStack; return itemStack;
} }
@ -320,10 +312,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
if (stackInInventory == null) if (stackInInventory == null)
{ {
inventory.setInventorySlotContents(slotIndex, itemStack); inventory.setInventorySlotContents(slotIndex, itemStack);
if (inventory.getStackInSlot(slotIndex) == null) if (inventory.getStackInSlot(slotIndex) == null) { return itemStack; }
{
return itemStack;
}
return null; return null;
} }
else if (stackInInventory.isItemEqual(itemStack) && stackInInventory.isStackable()) else if (stackInInventory.isItemEqual(itemStack) && stackInInventory.isStackable())
@ -337,10 +326,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IRota
} }
} }
if (itemStack.stackSize <= 0) if (itemStack.stackSize <= 0) { return null; }
{
return null;
}
return itemStack; return itemStack;
} }