Fixed battery getting power without cells inside
This commit is contained in:
parent
43a4d4ab4c
commit
2c023d4902
1 changed files with 230 additions and 212 deletions
|
@ -129,7 +129,8 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
{
|
||||
setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
setInventorySlotContents(slotID + 1, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +292,8 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
|
||||
return max;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return clientMaxEnergy;
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +317,8 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
|
||||
return energy;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return clientEnergy;
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +326,8 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
@Override
|
||||
public void handle(ByteArrayDataInput input)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
structure.isMultiblock = input.readBoolean();
|
||||
|
||||
clientEnergy = input.readFloat();
|
||||
|
@ -333,7 +337,10 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
structure.height = input.readInt();
|
||||
structure.length = input.readInt();
|
||||
structure.width = input.readInt();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -371,11 +378,13 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
{
|
||||
return ListUtil.getTop(structure.inventory);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return structure.tempStack;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return structure.visibleInventory[i - 1];
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +402,8 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
setInventorySlotContents(slotID, null);
|
||||
return tempStack;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
tempStack = getStackInSlot(slotID).splitStack(amount);
|
||||
|
||||
if (getStackInSlot(slotID).stackSize == 0)
|
||||
|
@ -404,7 +414,8 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
return tempStack;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -430,18 +441,21 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
{
|
||||
structure.inventory.remove(ListUtil.getTop(structure.inventory));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
structure.tempStack = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
structure.tempStack = itemstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
structure.visibleInventory[i - 1] = itemstack;
|
||||
}
|
||||
}
|
||||
|
@ -471,10 +485,14 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
}
|
||||
|
||||
@Override
|
||||
public void openChest() {}
|
||||
public void openChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest() {}
|
||||
public void closeChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
|
@ -491,6 +509,6 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
|
|||
@Override
|
||||
public boolean canReceive(TileEntity transferTile)
|
||||
{
|
||||
return true;
|
||||
return this.getMaxEnergyStored() - this.getEnergyStored() > 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue