Fixed battery box not saving due to a late init capacity set

This commit is contained in:
Robert S 2014-04-13 01:09:02 -04:00
parent 99cfdc7fdb
commit 2a9927bdc8
3 changed files with 6 additions and 7 deletions

View file

@ -99,7 +99,7 @@ public class BlockBattery extends BlockSidedIO implements ITileEntityProvider
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
ItemBlockBattery itemBlock = (ItemBlockBattery) itemStack.getItem();
ItemBlockBattery.setTier(itemStack, (byte) world.getBlockMetadata(x, y, z));
itemBlock.setEnergy(itemStack, battery.getEnergy(ForgeDirection.UNKNOWN));
itemBlock.setEnergy(itemStack, battery.getEnergyHandler().getEnergy());
}
ret.add(itemStack);
return ret;
@ -147,6 +147,6 @@ public class BlockBattery extends BlockSidedIO implements ITileEntityProvider
}
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
return CompatibilityModule.getItemWithCharge(ItemBlockBattery.setTier(new ItemStack(id, 1, 0), (byte) world.getBlockMetadata(x, y, z)), battery.getEnergy(ForgeDirection.UNKNOWN));
return CompatibilityModule.getItemWithCharge(ItemBlockBattery.setTier(new ItemStack(id, 1, 0), (byte) world.getBlockMetadata(x, y, z)), battery.getEnergyHandler().getEnergy());
}
}

View file

@ -80,7 +80,7 @@ public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleI
TileBattery tile = (TileBattery) t;
int energyLevel = (int) Math.round(((double) tile.getEnergy(ForgeDirection.UNKNOWN) / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 8);
int energyLevel = (int) Math.round(((double) tile.getEnergyHandler().getEnergy() / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 8);
RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery.png");
List<String> disabledParts = new ArrayList<String>();

View file

@ -35,6 +35,7 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
public TileBattery()
{
this.setEnergyHandler(new EnergyStorageHandler(0));
this.getEnergyHandler().setCapacity(Long.MAX_VALUE);
this.ioMap = 0;
this.saveIOMap = true;
}
@ -53,16 +54,14 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
{
super.initiate();
getEnergyHandler().setCapacity(getEnergyForTier(getBlockMetadata()));
getEnergyHandler().setMaxTransfer(getEnergyHandler().getEnergyCapacity());
}
@Override
public void updateEntity()
{
if (!this.worldObj.isRemote)
{
// energy.setMaxTransfer((long) Math.min(Math.pow(10000,
// this.getNetwork().getConnectors().size()), energy.getEnergyCapacity()));
getEnergyHandler().setMaxTransfer(getEnergyHandler().getEnergyCapacity());
{
markDistributionUpdate |= produce() > 0;
}