Fixed right clicking more cells than max
This commit is contained in:
parent
d84e3c812a
commit
c083670b55
2 changed files with 18 additions and 4 deletions
|
@ -70,10 +70,12 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
if (!world.isRemote)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
tileEntity.structure.inventory.add(entityPlayer.getCurrentEquippedItem());
|
||||
tileEntity.structure.sortInventory();
|
||||
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
|
||||
tileEntity.updateAllClients();
|
||||
|
||||
if (tileEntity.structure.addCell(entityPlayer.getCurrentEquippedItem()))
|
||||
{
|
||||
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
|
||||
tileEntity.updateAllClients();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,18 @@ public class SynchronizedBatteryData
|
|||
return getVolume() * BatteryManager.CELLS_PER_BATTERY;
|
||||
}
|
||||
|
||||
public boolean addCell(ItemStack cell)
|
||||
{
|
||||
if (this.inventory.size() < this.getMaxCells())
|
||||
{
|
||||
this.inventory.add(cell);
|
||||
this.sortInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void sortInventory()
|
||||
{
|
||||
Object[] array = ListUtil.copy(inventory).toArray();
|
||||
|
|
Loading…
Reference in a new issue