Merge pull request #630 from Dynious/calcinatorFix

Fixed #626 with stack sizes > 1
This commit is contained in:
pahimar 2014-02-11 14:18:15 -05:00
commit e6c61fbf42

View file

@ -377,27 +377,7 @@ public class TileCalcinator extends TileEE implements IInventory
if (this.canCalcinate())
{
ItemStack alchemicalDustStack = CalcinationManager.getCalcinationResult(this.inventory[INPUT_INVENTORY_INDEX]);
if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] == null)
{
this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] = alchemicalDustStack.copy();
}
else if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack)
&& this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize < getInventoryStackLimit()
&& this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize < this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].getMaxStackSize())
{
inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize += alchemicalDustStack.stackSize;
}
else if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] == null)
{
this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] = alchemicalDustStack.copy();
}
else if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack)
&& this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize < getInventoryStackLimit()
&& this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize < this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].getMaxStackSize())
{
inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize += alchemicalDustStack.stackSize;
}
addItemStackToOutput(alchemicalDustStack.copy());
this.inventory[INPUT_INVENTORY_INDEX].stackSize--;
@ -408,6 +388,40 @@ public class TileCalcinator extends TileEE implements IInventory
}
}
private void addItemStackToOutput(ItemStack alchemicalDustStack)
{
int maxStackSize = Math.min(getInventoryStackLimit(), alchemicalDustStack.getMaxStackSize());
if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] == null)
{
this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] = alchemicalDustStack;
return;
}
if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack)
&& this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize < maxStackSize)
{
int addedSize = Math.min(alchemicalDustStack.stackSize, maxStackSize - this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize);
alchemicalDustStack.stackSize -= addedSize;
this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize += addedSize;
if (alchemicalDustStack == null || alchemicalDustStack.stackSize == 0)
{
return;
}
}
if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] == null)
{
this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] = alchemicalDustStack;
return;
}
if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack)
&& this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize < maxStackSize)
{
int addedSize = Math.min(alchemicalDustStack.stackSize, maxStackSize - this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize);
alchemicalDustStack.stackSize -= addedSize;
this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize += addedSize;
}
}
@Override
public Packet getDescriptionPacket()
{