IInventory suck inventory implementation complete

This commit is contained in:
Aidan Brady 2013-08-03 18:47:34 -04:00
parent 8f54d8622c
commit e832a4ae55

View file

@ -42,12 +42,12 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
pushDelay = Math.max(0, pushDelay-1); pushDelay = Math.max(0, pushDelay-1);
if(isLatched()) if(isLatched())
{
if(!suck && pushDelay == 0)
{ {
TileEntity inventoryTile = getLatched(); TileEntity inventoryTile = getLatched();
IInventory inventory = (IInventory)inventoryTile; IInventory inventory = (IInventory)inventoryTile;
if(!suck && pushDelay == 0)
{
if(!(inventoryTile instanceof ISidedInventory)) if(!(inventoryTile instanceof ISidedInventory))
{ {
for(int i = inventory.getSizeInventory()-1; i >= 0; i--) for(int i = inventory.getSizeInventory()-1; i >= 0; i--)
@ -113,7 +113,59 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
for(EntityItem item : list) for(EntityItem item : list)
{ {
ItemStack itemStack = item.getEntityItem();
if(!(inventoryTile instanceof ISidedInventory))
{
for(int i = 0; i < inventory.getSizeInventory()-1; i++)
{
if(inventory.isItemValidForSlot(i, itemStack))
{
ItemStack inSlot = inventory.getStackInSlot(i);
if(inSlot == null)
{
inventory.setInventorySlotContents(i, itemStack);
item.setDead();
break;
}
else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize())
{
if(inSlot.stackSize+itemStack.stackSize <= inSlot.getMaxStackSize())
{
ItemStack toSet = itemStack.copy();
toSet.stackSize+=inSlot.stackSize;
inventory.setInventorySlotContents(i, toSet);
item.setDead();
break;
}
else {
int rejects = (inSlot.stackSize+itemStack.stackSize) - inSlot.getMaxStackSize();
ItemStack toSet = itemStack.copy();
toSet.stackSize = inSlot.getMaxStackSize();
ItemStack remains = itemStack.copy();
remains.stackSize = rejects;
inventory.setInventorySlotContents(i, toSet);
item.setEntityItemStack(remains);
}
}
}
}
}
else {
ISidedInventory sidedInventory = (ISidedInventory)inventoryTile;
int[] slots = sidedInventory.getAccessibleSlotsFromSide(facing.ordinal());
for(int get = 0; get < slots.length-1; get++)
{
int slotID = slots[get];
}
}
} }
} }
} }