From 2a9927bdc8b29a52be7f7da8a9bcde0c03cbc951 Mon Sep 17 00:00:00 2001 From: Robert S Date: Sun, 13 Apr 2014 01:09:02 -0400 Subject: [PATCH] Fixed battery box not saving due to a late init capacity set --- .../resonantinduction/electrical/battery/BlockBattery.java | 4 ++-- .../electrical/battery/RenderBattery.java | 2 +- .../resonantinduction/electrical/battery/TileBattery.java | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/electrical/src/main/scala/resonantinduction/electrical/battery/BlockBattery.java b/electrical/src/main/scala/resonantinduction/electrical/battery/BlockBattery.java index 88d14ed5a..c8d5a974e 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/battery/BlockBattery.java +++ b/electrical/src/main/scala/resonantinduction/electrical/battery/BlockBattery.java @@ -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()); } } diff --git a/electrical/src/main/scala/resonantinduction/electrical/battery/RenderBattery.java b/electrical/src/main/scala/resonantinduction/electrical/battery/RenderBattery.java index f122855de..c853b6373 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/battery/RenderBattery.java +++ b/electrical/src/main/scala/resonantinduction/electrical/battery/RenderBattery.java @@ -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 disabledParts = new ArrayList(); diff --git a/electrical/src/main/scala/resonantinduction/electrical/battery/TileBattery.java b/electrical/src/main/scala/resonantinduction/electrical/battery/TileBattery.java index 9a6102b02..46af6ad37 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/battery/TileBattery.java +++ b/electrical/src/main/scala/resonantinduction/electrical/battery/TileBattery.java @@ -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; }