diff --git a/src/resonantinduction/ClientProxy.java b/src/resonantinduction/ClientProxy.java index 1fb1407d..18f20b6d 100644 --- a/src/resonantinduction/ClientProxy.java +++ b/src/resonantinduction/ClientProxy.java @@ -5,14 +5,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import resonantinduction.battery.TileEntityBattery; import resonantinduction.contractor.TileEntityEMContractor; import resonantinduction.fx.FXElectricBolt; -import resonantinduction.gui.GuiBattery; import resonantinduction.gui.GuiMultimeter; import resonantinduction.multimeter.TileEntityMultimeter; import resonantinduction.render.BlockRenderingHandler; -import resonantinduction.render.RenderBattery; import resonantinduction.render.RenderEMContractor; import resonantinduction.render.RenderMultimeter; import resonantinduction.render.RenderTesla; @@ -41,7 +38,8 @@ public class ClientProxy extends CommonProxy ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultimeter.class, new RenderMultimeter()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEMContractor.class, new RenderEMContractor()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBattery.class, new RenderBattery()); + // ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBattery.class, new + // RenderBattery()); } @Override @@ -53,10 +51,12 @@ public class ClientProxy extends CommonProxy { return new GuiMultimeter(player.inventory, ((TileEntityMultimeter) tileEntity)); } - else if (tileEntity instanceof TileEntityBattery) - { - return new GuiBattery(player.inventory, ((TileEntityBattery) tileEntity)); - } + /* + * else if (tileEntity instanceof TileEntityBattery) + * { + * return new GuiBattery(player.inventory, ((TileEntityBattery) tileEntity)); + * } + */ return null; } diff --git a/src/resonantinduction/CommonProxy.java b/src/resonantinduction/CommonProxy.java index cadfdf0b..f3177cbc 100644 --- a/src/resonantinduction/CommonProxy.java +++ b/src/resonantinduction/CommonProxy.java @@ -6,8 +6,6 @@ package resonantinduction; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import resonantinduction.battery.ContainerBattery; -import resonantinduction.battery.TileEntityBattery; import resonantinduction.multimeter.ContainerMultimeter; import resonantinduction.multimeter.TileEntityMultimeter; import universalelectricity.api.vector.Vector3; @@ -33,10 +31,10 @@ public class CommonProxy implements IGuiHandler { return new ContainerMultimeter(player.inventory, ((TileEntityMultimeter) tileEntity)); } - else if (tileEntity instanceof TileEntityBattery) + /*else if (tileEntity instanceof TileEntityBattery) { return new ContainerBattery(player.inventory, ((TileEntityBattery) tileEntity)); - } + }*/ return null; } diff --git a/src/resonantinduction/ResonantInduction.java b/src/resonantinduction/ResonantInduction.java index c0fd2897..163e2e29 100644 --- a/src/resonantinduction/ResonantInduction.java +++ b/src/resonantinduction/ResonantInduction.java @@ -20,10 +20,6 @@ import net.minecraftforge.oredict.ShapelessOreRecipe; import org.modstats.ModstatInfo; import org.modstats.Modstats; -import resonantinduction.battery.BlockBattery; -import resonantinduction.battery.ItemCapacitor; -import resonantinduction.battery.ItemInfiniteCapacitor; -import resonantinduction.battery.TileEntityBattery; import resonantinduction.contractor.BlockEMContractor; import resonantinduction.contractor.ItemBlockContractor; import resonantinduction.contractor.TileEntityEMContractor; @@ -185,16 +181,14 @@ public class ResonantInduction // Items itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID()); - itemCapacitor = new ItemCapacitor(getNextItemID()); itemLinker = new ItemLinker(getNextItemID()); - itemInfiniteCapacitor = new ItemInfiniteCapacitor(getNextItemID()); itemPartWire = new ItemPartWire(getNextItemID()); // Blocks blockTesla = new BlockTesla(getNextBlockID()); blockMultimeter = new BlockMultimeter(getNextBlockID()); blockEMContractor = new BlockEMContractor(getNextBlockID()); - blockBattery = new BlockBattery(getNextBlockID()); + //blockBattery = new BlockBattery(getNextBlockID()); if (REPLACE_FURNACE) { @@ -219,7 +213,7 @@ public class ResonantInduction GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName()); GameRegistry.registerTileEntity(TileEntityMultimeter.class, blockMultimeter.getUnlocalizedName()); GameRegistry.registerTileEntity(TileEntityEMContractor.class, blockEMContractor.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileEntityBattery.class, blockBattery.getUnlocalizedName()); + //GameRegistry.registerTileEntity(TileEntityBattery.class, blockBattery.getUnlocalizedName()); ResonantInduction.proxy.registerRenderers(); diff --git a/src/resonantinduction/api/ITesla.java b/src/resonantinduction/api/ITesla.java index 755baf35..a9d44d7c 100644 --- a/src/resonantinduction/api/ITesla.java +++ b/src/resonantinduction/api/ITesla.java @@ -16,8 +16,8 @@ public interface ITesla * @param doTransfer - Actually transfer * @return Energy actually transfered. */ - public float transfer(float transferEnergy, boolean doTransfer); + public long teslaTransfer(long transferEnergy, boolean doTransfer); - public boolean canReceive(TileEntity transferTile); + public boolean canTeslaTransfer(TileEntity transferTile); } diff --git a/src/resonantinduction/contractor/TileEntityEMContractor.java b/src/resonantinduction/contractor/TileEntityEMContractor.java index 32cdc729..8b06ad72 100644 --- a/src/resonantinduction/contractor/TileEntityEMContractor.java +++ b/src/resonantinduction/contractor/TileEntityEMContractor.java @@ -27,7 +27,7 @@ import universalelectricity.api.vector.Vector3; import calclavia.lib.InventoryHelper; import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketSender; -import calclavia.lib.prefab.tile.TileEntityAdvanced; +import calclavia.lib.tile.TileEntityAdvanced; import com.google.common.io.ByteArrayDataInput; diff --git a/src/resonantinduction/gui/GuiBattery.java b/src/resonantinduction/gui/GuiBattery.java deleted file mode 100644 index 0172a175..00000000 --- a/src/resonantinduction/gui/GuiBattery.java +++ /dev/null @@ -1,59 +0,0 @@ -package resonantinduction.gui; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; - -import resonantinduction.ResonantInduction; -import resonantinduction.battery.ContainerBattery; -import resonantinduction.battery.TileEntityBattery; -import universalelectricity.api.energy.UnitDisplay; -import universalelectricity.api.energy.UnitDisplay.Unit; - -public class GuiBattery extends GuiContainer -{ - private static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.GUI_DIRECTORY + "batterybox_gui.png"); - public TileEntityBattery tileEntity; - - public GuiBattery(InventoryPlayer inventory, TileEntityBattery tentity) - { - super(new ContainerBattery(inventory, tentity)); - tileEntity = tentity; - ySize += 41; - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString("Battery", 43, 6, 0x404040); - fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x404040); - fontRenderer.drawString("Cells: " + tileEntity.clientCells + " / " + tileEntity.structure.getMaxCells(), 62, 23, 0x404040); - fontRenderer.drawString("Energy: ", 62, 33, 0x404040); - fontRenderer.drawString(UnitDisplay.getDisplay(this.tileEntity.getEnergyStored(), Unit.JOULES, 4, true), 62, 43, 0x404040); - fontRenderer.drawString("Max: " + UnitDisplay.getDisplayShort(this.tileEntity.getMaxEnergyStored(), Unit.JOULES), 62, 53, 0x404040); - fontRenderer.drawString("Percentage: " + (int) (this.tileEntity.getEnergyStored() / this.tileEntity.getMaxEnergyStored() * 100) + "%", 62, 63, 0x404040); - fontRenderer.drawString("Volume: " + tileEntity.structure.getVolume(), 62, 73, 0x404040); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(TEXTURE); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - int scale = (int) ((tileEntity.getEnergyStored() / tileEntity.getMaxEnergyStored()) * 105); - drawTexturedModalRect(guiWidth + 61, guiHeight + 102, 0, 207, scale, 12); - } -} diff --git a/src/resonantinduction/gui/GuiMultimeter.java b/src/resonantinduction/gui/GuiMultimeter.java index e2adac99..4b8cd112 100644 --- a/src/resonantinduction/gui/GuiMultimeter.java +++ b/src/resonantinduction/gui/GuiMultimeter.java @@ -5,7 +5,6 @@ package resonantinduction.gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; @@ -14,6 +13,7 @@ import org.lwjgl.opengl.GL11; import resonantinduction.ResonantInduction; import resonantinduction.multimeter.ContainerMultimeter; import resonantinduction.multimeter.TileEntityMultimeter; +import calclavia.lib.gui.GuiContainerBase; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -25,9 +25,8 @@ import cpw.mods.fml.relauncher.SideOnly; * */ @SideOnly(Side.CLIENT) -public class GuiMultimeter extends GuiContainer +public class GuiMultimeter extends GuiContainerBase { - private static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.GUI_DIRECTORY + "gui_multimeter.png"); TileEntityMultimeter tileEntity; private int containerWidth; @@ -39,6 +38,7 @@ public class GuiMultimeter extends GuiContainer super(new ContainerMultimeter(inventoryPlayer, tileEntity)); this.tileEntity = tileEntity; this.ySize = 217; + this.baseTexture = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.GUI_DIRECTORY + "gui_multimeter.png"); } @Override @@ -90,13 +90,7 @@ public class GuiMultimeter extends GuiContainer @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - this.containerWidth = (this.width - this.xSize) / 2; - this.containerHeight = (this.height - this.ySize) / 2; - - this.mc.renderEngine.bindTexture(TEXTURE); - GL11.glColor4f(1, 1, 1, 1); - this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0, this.xSize, this.ySize); - + super.drawGuiContainerBackgroundLayer(f, x, y); int length = Math.min((int) (this.tileEntity.getDetectedEnergy() / this.tileEntity.getPeak()) * 115, 115); this.drawTexturedModalRect(this.containerWidth + 14, this.containerHeight + 126 - length, 176, 115 - length, 6, length); } diff --git a/src/resonantinduction/multimeter/TileEntityMultimeter.java b/src/resonantinduction/multimeter/TileEntityMultimeter.java index c322307d..1b2436a3 100644 --- a/src/resonantinduction/multimeter/TileEntityMultimeter.java +++ b/src/resonantinduction/multimeter/TileEntityMultimeter.java @@ -15,13 +15,14 @@ import net.minecraft.network.packet.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import resonantinduction.ResonantInduction; -import universalelectricity.api.IConnector; import universalelectricity.api.energy.IConductor; +import universalelectricity.api.energy.IEnergyContainer; +import universalelectricity.api.energy.IEnergyNetwork; import buildcraft.api.power.IPowerReceptor; import calclavia.lib.IRotatable; import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketSender; -import calclavia.lib.prefab.tile.TileEntityAdvanced; +import calclavia.lib.tile.TileEntityAdvanced; import cofh.api.energy.TileEnergyHandler; import com.google.common.io.ByteArrayDataInput; @@ -35,7 +36,7 @@ import cpw.mods.fml.common.network.Player; * @author Calclavia * */ -public class TileEntityMultimeter extends TileEntityAdvanced implements IConnector, IRotatable, IPacketReceiver, IPacketSender +public class TileEntityMultimeter extends TileEntityAdvanced implements IRotatable, IPacketReceiver, IPacketSender { public Set playersUsing = new HashSet(); @@ -159,19 +160,16 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements IConnect return getDetectedEnergy(direction.getOpposite(), tileEntity); } + // TODO: Check if side is correct. public static float getDetectedEnergy(ForgeDirection side, TileEntity tileEntity) { - if (tileEntity instanceof TileEntityElectrical) + if (tileEntity instanceof IEnergyContainer) { - return ((TileEntityElectrical) tileEntity).getEnergy(); - } - else if (tileEntity instanceof IElectricalStorage) - { - return ((IElectricalStorage) tileEntity).getEnergy(); + return ((IEnergyContainer) tileEntity).getEnergy(side); } else if (tileEntity instanceof IConductor) { - IElectricityNetwork network = ((IConductor) tileEntity).getNetwork(); + IEnergyNetwork network = ((IConductor) tileEntity).getNetwork(); if (MultimeterEventHandler.getCache(tileEntity.worldObj).containsKey(network) && MultimeterEventHandler.getCache(tileEntity.worldObj).get(network) instanceof Long) { @@ -250,7 +248,7 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements IConnect return peakDetection; } - @Override + //@Override public boolean canConnect(ForgeDirection direction) { return direction == getDirection(); diff --git a/src/resonantinduction/render/BlockRenderingHandler.java b/src/resonantinduction/render/BlockRenderingHandler.java index 80033205..4167ce8a 100644 --- a/src/resonantinduction/render/BlockRenderingHandler.java +++ b/src/resonantinduction/render/BlockRenderingHandler.java @@ -9,7 +9,6 @@ import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; -import resonantinduction.battery.BlockBattery; import resonantinduction.contractor.BlockEMContractor; import resonantinduction.multimeter.BlockMultimeter; import resonantinduction.tesla.BlockTesla; @@ -50,7 +49,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler RenderEMContractor.MODEL.render(0.0625f); GL11.glPopMatrix(); } - else if (block instanceof BlockBattery) + /*else if (block instanceof BlockBattery) { GL11.glPushMatrix(); GL11.glTranslated(0.5, 1.42, 0.5); @@ -58,7 +57,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderBattery.TEXTURE); RenderBattery.MODEL.render(0.0625f); GL11.glPopMatrix(); - } + }*/ else if (block instanceof BlockMultimeter) { GL11.glPushMatrix(); @@ -73,13 +72,6 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - if (block instanceof BlockBattery) - { - // FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderBattery.TEXTURE); - - return true; - } - return false; } diff --git a/src/resonantinduction/render/RenderBattery.java b/src/resonantinduction/render/RenderBattery.java index 6c649f41..e375e2d5 100644 --- a/src/resonantinduction/render/RenderBattery.java +++ b/src/resonantinduction/render/RenderBattery.java @@ -23,7 +23,6 @@ import net.minecraftforge.common.ForgeDirection; import org.lwjgl.opengl.GL11; import resonantinduction.ResonantInduction; -import resonantinduction.battery.TileEntityBattery; import resonantinduction.model.ModelBattery; import universalelectricity.api.vector.Vector3; import cpw.mods.fml.relauncher.Side; @@ -55,14 +54,14 @@ public class RenderBattery extends TileEntitySpecialRenderer GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - if (((TileEntityBattery) t).structure.isMultiblock) + /*if (((TileEntityBattery) t).structure.isMultiblock) { this.bindTexture(TEXTURE_MULTI); } else { this.bindTexture(TEXTURE); - } + }*/ MODEL.render(0.0625f); /* @@ -83,7 +82,7 @@ public class RenderBattery extends TileEntitySpecialRenderer this.renderManager = RenderManager.instance; } - int renderAmount = Math.min(((TileEntityBattery) t).clientCells, 16); + int renderAmount = 0;//Math.min(((TileEntityBattery) t).clientCells, 16); if (renderAmount == 0) { diff --git a/src/resonantinduction/tesla/TileEntityTesla.java b/src/resonantinduction/tesla/TileEntityTesla.java index fca0335b..316d30c2 100644 --- a/src/resonantinduction/tesla/TileEntityTesla.java +++ b/src/resonantinduction/tesla/TileEntityTesla.java @@ -27,6 +27,8 @@ import universalelectricity.api.electricity.ElectricityPack; import universalelectricity.api.vector.Vector3; import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketSender; +import calclavia.lib.tile.EnergyStorage; +import calclavia.lib.tile.TileEntityElectrical; import com.google.common.io.ByteArrayDataInput; @@ -40,10 +42,10 @@ import cpw.mods.fml.common.network.PacketDispatcher; * @author Calclavia * */ -public class TileEntityTesla extends TileEntityUniversalElectrical implements ITesla, IPacketSender, IPacketReceiver +public class TileEntityTesla extends TileEntityElectrical implements ITesla, IPacketSender, IPacketReceiver { public final static int DEFAULT_COLOR = 12; - public final float TRANSFER_CAP = 10; + public final long TRANSFER_CAP = 10000; private int dyeID = DEFAULT_COLOR; private boolean canReceive = true; @@ -74,6 +76,11 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT private int zapCounter = 0; private boolean isLinkedClient; + public TileEntityTesla() + { + this.energyStorage = new EnergyStorage(TRANSFER_CAP); + } + @Override public void initiate() { @@ -86,16 +93,16 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT { super.updateEntity(); - boolean doPacketUpdate = this.getEnergy() > 0; + boolean doPacketUpdate = this.energyStorage.getEnergy() > 0; /** * Only transfer if it is the bottom controlling Tesla tower. */ if (this.isController()) { - this.produce(); + // this.produce(); - if (this.ticks % (5 + this.worldObj.rand.nextInt(2)) == 0 && ((this.worldObj.isRemote && this.doTransfer) || (this.getEnergy() > 0 && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)))) + if (this.ticks % (5 + this.worldObj.rand.nextInt(2)) == 0 && ((this.worldObj.isRemote && this.doTransfer) || (this.energyStorage.getEnergy() > 0 && !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)))) { final TileEntityTesla topTesla = this.getTopTelsa(); final Vector3 topTeslaVector = new Vector3(topTesla); @@ -115,11 +122,11 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT if (transferTile instanceof TileEntityTesla && !transferTile.isInvalid()) { - this.transfer(((TileEntityTesla) transferTile), Math.min(this.getProvide(ForgeDirection.UNKNOWN), TRANSFER_CAP)); + this.transfer(((TileEntityTesla) transferTile), Math.min(this.energyStorage.getEmptySpace(), TRANSFER_CAP)); if (this.zapCounter % 5 == 0 && ResonantInduction.SOUND_FXS) { - this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.getEnergy() / 25, 1.3f - 0.5f * (this.dyeID / 16f)); + this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.energyStorage.getEnergy() / 25, 1.3f - 0.5f * (this.dyeID / 16f)); } } } @@ -141,7 +148,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT /** * Make sure Tesla is not part of this tower. */ - if (!this.connectedTeslas.contains(tesla) && tesla.canReceive(this)) + if (!this.connectedTeslas.contains(tesla) && tesla.canTeslaTransfer(this)) { if (tesla instanceof TileEntityTesla) { @@ -189,14 +196,14 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT if (transferTeslaCoils.size() > 0) { - float transferEnergy = this.getEnergy() / transferTeslaCoils.size(); + long transferEnergy = this.energyStorage.getEnergy() / transferTeslaCoils.size(); int count = 0; boolean sentPacket = false; for (ITesla tesla : transferTeslaCoils) { if (this.zapCounter % 5 == 0 && ResonantInduction.SOUND_FXS) { - this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.getEnergy() / 25, 1.3f - 0.5f * (this.dyeID / 16f)); + this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.energyStorage.getEnergy() / 25, 1.3f - 0.5f * (this.dyeID / 16f)); } Vector3 targetVector = new Vector3((TileEntity) tesla); @@ -245,7 +252,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT this.doTransfer = false; } - if (!this.worldObj.isRemote && this.getEnergy() > 0 != doPacketUpdate) + if (!this.worldObj.isRemote && this.energyStorage.getEnergy() > 0 != doPacketUpdate) { this.sendPacket(2); } @@ -254,25 +261,19 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT this.clearCache(); } - private void transfer(ITesla tesla, float transferEnergy) + private void transfer(ITesla tesla, long transferEnergy) { if (transferEnergy > 0) { - tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)), true); - this.transfer(-transferEnergy, true); + tesla.teslaTransfer((long) (transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f))), true); + this.teslaTransfer(-transferEnergy, true); } } @Override - public float receiveElectricity(ElectricityPack receive, boolean doReceive) + public boolean canTeslaTransfer(TileEntity tileEntity) { - return super.receiveElectricity(receive, doReceive); - } - - @Override - public boolean canReceive(TileEntity tileEntity) - { - return this.canReceive && !this.outputBlacklist.contains(tileEntity) && this.getRequest(ForgeDirection.UNKNOWN) > 0; + return this.canReceive && !this.outputBlacklist.contains(tileEntity); } @Override @@ -296,7 +297,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT { case 1: { - data.add(this.getEnergy()); + data.add(this.energyStorage.getEnergy()); data.add(this.dyeID); data.add(this.canReceive); data.add(this.attackEntities); @@ -305,7 +306,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT } case 2: { - data.add(this.getEnergy()); + data.add(this.energyStorage.getEnergy()); } } @@ -331,14 +332,14 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT switch (data.readByte()) { case 1: - this.setEnergy(data.readFloat()); + this.energyStorage.setEnergy(data.readLong()); this.dyeID = data.readInt(); this.canReceive = data.readBoolean(); this.attackEntities = data.readBoolean(); this.isLinkedClient = data.readBoolean(); break; case 2: - this.setEnergy(data.readFloat()); + this.energyStorage.setEnergy(data.readLong()); break; case 3: this.doTransfer = true; @@ -362,13 +363,13 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT } @Override - public float transfer(float transferEnergy, boolean doTransfer) + public long teslaTransfer(long transferEnergy, boolean doTransfer) { if (isController() || this.getControllingTelsa() == this) { if (doTransfer) { - this.receiveElectricity(transferEnergy, true); + this.energyStorage.receiveEnergy(transferEnergy, true); } this.sendPacket(2); @@ -376,13 +377,13 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT } else { - if (this.getEnergy() > 0) + if (this.energyStorage.getEnergy() > 0) { - transferEnergy += this.getEnergy(); - this.setEnergy(0); + transferEnergy += this.energyStorage.getEnergy(); + this.energyStorage.setEnergy(0); } - return this.getControllingTelsa().transfer(transferEnergy, doTransfer); + return this.getControllingTelsa().teslaTransfer(transferEnergy, doTransfer); } } @@ -608,34 +609,6 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT } } - @Override - public float getRequest(ForgeDirection direction) - { - if (direction != ForgeDirection.DOWN) - { - return this.getMaxEnergyStored() - this.getEnergy(); - } - - return 0; - } - - @Override - public float getProvide(ForgeDirection direction) - { - if (this.isController() && direction == ForgeDirection.DOWN) - { - return this.getEnergy(); - } - - return 0; - } - - @Override - public float getMaxEnergyStored() - { - return TRANSFER_CAP; - } - @Override public EnumSet getInputDirections() {