From fc964ad8dbd098e04c7cb7eaf6da5f09a2292177 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Wed, 31 Jul 2013 16:44:53 -0400 Subject: [PATCH] Cleanups, fixed UE ratios --- .../client/GuiAdvancedElectricMachine.java | 2 +- .../mekanism/client/GuiElectricMachine.java | 2 +- common/mekanism/client/GuiElectricPump.java | 4 ++-- common/mekanism/client/GuiEnergyCube.java | 11 +++++----- common/mekanism/client/GuiRobitMain.java | 4 ++-- common/mekanism/client/GuiTeleporter.java | 2 +- common/mekanism/common/ChargeUtils.java | 4 ++-- common/mekanism/common/EnergyNetwork.java | 9 +++++++-- .../common/EnergyNetworkRegistry.java | 3 ++- .../mekanism/common/ItemBlockEnergyCube.java | 20 +++++++++---------- common/mekanism/common/ItemBlockMachine.java | 20 +++++++++---------- common/mekanism/common/ItemEnergized.java | 20 +++++++++---------- common/mekanism/common/Mekanism.java | 2 ++ .../common/TileEntityElectricBlock.java | 12 +++++------ .../generators/client/GuiBioGenerator.java | 4 ++-- .../generators/client/GuiHeatGenerator.java | 4 ++-- .../client/GuiHydrogenGenerator.java | 4 ++-- .../generators/client/GuiSolarGenerator.java | 4 ++-- .../generators/client/GuiWindTurbine.java | 4 ++-- .../generators/common/ItemBlockGenerator.java | 20 +++++++++---------- 20 files changed, 81 insertions(+), 74 deletions(-) diff --git a/common/mekanism/client/GuiAdvancedElectricMachine.java b/common/mekanism/client/GuiAdvancedElectricMachine.java index bb53c7f4f..8412a799c 100644 --- a/common/mekanism/client/GuiAdvancedElectricMachine.java +++ b/common/mekanism/client/GuiAdvancedElectricMachine.java @@ -41,7 +41,7 @@ public class GuiAdvancedElectricMachine extends GuiContainer if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); } if(xAxis >= 179 && xAxis <= 198 && yAxis >= 47 && yAxis <= 54) diff --git a/common/mekanism/client/GuiElectricMachine.java b/common/mekanism/client/GuiElectricMachine.java index d3257b0c1..e7ac61502 100644 --- a/common/mekanism/client/GuiElectricMachine.java +++ b/common/mekanism/client/GuiElectricMachine.java @@ -41,7 +41,7 @@ public class GuiElectricMachine extends GuiContainer if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); } if(xAxis >= 179 && xAxis <= 198 && yAxis >= 47 && yAxis <= 54) diff --git a/common/mekanism/client/GuiElectricPump.java b/common/mekanism/client/GuiElectricPump.java index 2a4162d3d..d6f1e8d80 100644 --- a/common/mekanism/client/GuiElectricPump.java +++ b/common/mekanism/client/GuiElectricPump.java @@ -39,7 +39,7 @@ public class GuiElectricPump extends GuiContainer fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 94) + 2, 0x404040); - fontRenderer.drawString(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00); + fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), 51, 26, 0x00CD00); fontRenderer.drawString(tileEntity.fluidTank.getFluid() != null ? FluidRegistry.getFluidName(tileEntity.fluidTank.getFluid()) + ": " + tileEntity.fluidTank.getFluid().amount : "No fluid.", 51, 35, 0x00CD00); fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00); @@ -50,7 +50,7 @@ public class GuiElectricPump extends GuiContainer if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); } } diff --git a/common/mekanism/client/GuiEnergyCube.java b/common/mekanism/client/GuiEnergyCube.java index 510fc93c3..fd7511619 100644 --- a/common/mekanism/client/GuiEnergyCube.java +++ b/common/mekanism/client/GuiEnergyCube.java @@ -1,21 +1,20 @@ package mekanism.client; import mekanism.common.ContainerEnergyCube; +import mekanism.common.Mekanism; import mekanism.common.MekanismUtils; -import mekanism.common.TileEntityEnergyCube; import mekanism.common.MekanismUtils.ResourceType; +import mekanism.common.TileEntityEnergyCube; 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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import universalelectricity.core.electricity.ElectricityDisplay; import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiEnergyCube extends GuiContainer @@ -34,7 +33,7 @@ public class GuiEnergyCube extends GuiContainer @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - String capacityInfo = ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES) + "/" + ElectricityDisplay.getDisplayShort((float)tileEntity.tier.MAX_ELECTRICITY, ElectricUnit.JOULES); + String capacityInfo = ElectricityDisplay.getDisplayShort((float)(tileEntity.getEnergyStored()), ElectricUnit.JOULES) + "/" + ElectricityDisplay.getDisplayShort((float)(tileEntity.getMaxEnergyStored()), ElectricUnit.JOULES); String outputInfo = "Voltage: " + tileEntity.getVoltage() + "v"; fontRenderer.drawString(tileEntity.tier.name + " Energy Cube", 43, 6, 0x404040); fontRenderer.drawString(capacityInfo, 45, 40, 0x00CD00); diff --git a/common/mekanism/client/GuiRobitMain.java b/common/mekanism/client/GuiRobitMain.java index 6fd0179b7..ebe56a035 100644 --- a/common/mekanism/client/GuiRobitMain.java +++ b/common/mekanism/client/GuiRobitMain.java @@ -112,7 +112,7 @@ public class GuiRobitMain extends GuiContainer if(!displayNameChange) { fontRenderer.drawString("Hi, I'm " + robit.getTranslatedEntityName() + "!", 29, 18, 0x00CD00); - fontRenderer.drawString("Energy: " + ElectricityDisplay.getDisplayShort((float)robit.getEnergy(), ElectricUnit.JOULES), 29, 36-4, 0x00CD00); + fontRenderer.drawString("Energy: " + ElectricityDisplay.getDisplayShort((float)(robit.getEnergy()*Mekanism.TO_UE), ElectricUnit.JOULES), 29, 36-4, 0x00CD00); fontRenderer.drawString("Following: " + robit.getFollowing(), 29, 45-4, 0x00CD00); fontRenderer.drawString("Drop pickup: " + robit.getDropPickup(), 29, 54-4, 0x00CD00); fontRenderer.drawString("Owner: " + robit.getOwnerName(), 29, 63-4, 0x00CD00); @@ -123,7 +123,7 @@ public class GuiRobitMain extends GuiContainer if(xAxis >= 28 && xAxis <= 148 && yAxis >= 75 && yAxis <= 79) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)robit.getEnergy(), ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)(robit.getEnergy()*Mekanism.TO_UE), ElectricUnit.JOULES), xAxis, yAxis); } else if(xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) { diff --git a/common/mekanism/client/GuiTeleporter.java b/common/mekanism/client/GuiTeleporter.java index c1de3221e..5a226ed16 100644 --- a/common/mekanism/client/GuiTeleporter.java +++ b/common/mekanism/client/GuiTeleporter.java @@ -45,7 +45,7 @@ public class GuiTeleporter extends GuiContainer if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); } } diff --git a/common/mekanism/common/ChargeUtils.java b/common/mekanism/common/ChargeUtils.java index 6e200f3ee..1f6dba2da 100644 --- a/common/mekanism/common/ChargeUtils.java +++ b/common/mekanism/common/ChargeUtils.java @@ -27,7 +27,7 @@ public final class ChargeUtils } else if(storer.inventory[slotID].getItem() instanceof IItemElectric) { - storer.setEnergy(storer.getEnergy() + ElectricItemHelper.dischargeItem(storer.inventory[slotID], (float)(storer.getMaxEnergy() - storer.getEnergy()))); + storer.setEnergy(storer.getEnergy() + ElectricItemHelper.dischargeItem(storer.inventory[slotID], (float)((storer.getMaxEnergy() - storer.getEnergy())*Mekanism.TO_UE))); } else if(Mekanism.hooks.IC2Loaded && storer.inventory[slotID].getItem() instanceof IElectricItem) { @@ -78,7 +78,7 @@ public final class ChargeUtils } else if(storer.inventory[slotID].getItem() instanceof IItemElectric) { - storer.setEnergy(storer.getEnergy() - ElectricItemHelper.chargeItem(storer.inventory[slotID], (float)storer.getEnergy())); + storer.setEnergy(storer.getEnergy() - ElectricItemHelper.chargeItem(storer.inventory[slotID], (float)(storer.getEnergy()*Mekanism.TO_UE))); } else if(Mekanism.hooks.IC2Loaded && storer.inventory[slotID].getItem() instanceof IElectricItem) { diff --git a/common/mekanism/common/EnergyNetwork.java b/common/mekanism/common/EnergyNetwork.java index d02f126f1..d3fc9648a 100644 --- a/common/mekanism/common/EnergyNetwork.java +++ b/common/mekanism/common/EnergyNetwork.java @@ -43,7 +43,7 @@ public class EnergyNetwork public EnergyNetwork(Set networks) { - for (EnergyNetwork net : networks) + for(EnergyNetwork net : networks) { if(net != null) { @@ -51,6 +51,7 @@ public class EnergyNetwork net.deregister(); } } + refresh(); EnergyNetworkRegistry.getInstance().registerNetwork(this); } @@ -123,6 +124,7 @@ public class EnergyNetwork } } } + sent = energyAvailable - energyToSend; joulesTransmitted += sent; } @@ -293,9 +295,10 @@ public class EnergyNetwork { if(cable instanceof TileEntity) { - NetworkFinder finder = new NetworkFinder(((TileEntity) cable).getWorldObj(), Object3D.get((TileEntity)cable), null); + NetworkFinder finder = new NetworkFinder(((TileEntity)cable).getWorldObj(), Object3D.get((TileEntity)cable), null); List partNetwork = finder.exploreNetwork(); Set newCables = new HashSet(); + for(Object3D node : partNetwork) { TileEntity nodeTile = node.getTileEntity(((TileEntity)cable).worldObj); @@ -306,6 +309,7 @@ public class EnergyNetwork newCables.add((IUniversalCable)nodeTile); } } + EnergyNetwork newNetwork = new EnergyNetwork(newCables.toArray(new IUniversalCable[0])); newNetwork.refresh(); newNetwork.fixed = true; @@ -411,6 +415,7 @@ public class EnergyNetwork public void tick() { clearJoulesTransmitted(); + //Fix weird behaviour periodically. if(!fixed) { diff --git a/common/mekanism/common/EnergyNetworkRegistry.java b/common/mekanism/common/EnergyNetworkRegistry.java index de562173c..5f88967dc 100644 --- a/common/mekanism/common/EnergyNetworkRegistry.java +++ b/common/mekanism/common/EnergyNetworkRegistry.java @@ -38,7 +38,8 @@ public class EnergyNetworkRegistry implements ITickHandler } } - public void pruneEmptyNetworks() { + public void pruneEmptyNetworks() + { for(EnergyNetwork e : networks) { if(e.cables.size() == 0) diff --git a/common/mekanism/common/ItemBlockEnergyCube.java b/common/mekanism/common/ItemBlockEnergyCube.java index 67839439f..bb575a109 100644 --- a/common/mekanism/common/ItemBlockEnergyCube.java +++ b/common/mekanism/common/ItemBlockEnergyCube.java @@ -303,13 +303,13 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, II @Override public float receiveEnergy(ItemStack theItem, float energy, boolean doReceive) { - return (float)(recharge(theItem, (float)(energy*Mekanism.FROM_BC), doReceive)*Mekanism.TO_BC); + return (float)(recharge(theItem, (float)((energy*Mekanism.FROM_BC)*Mekanism.TO_UE), doReceive)*Mekanism.TO_BC); } @Override public float transferEnergy(ItemStack theItem, float energy, boolean doTransfer) { - return (float)(discharge(theItem, (float)(energy*Mekanism.FROM_BC), doTransfer)*Mekanism.TO_BC); + return (float)(discharge(theItem, (float)((energy*Mekanism.FROM_BC)*Mekanism.TO_UE), doTransfer)*Mekanism.TO_BC); } @Override @@ -336,14 +336,14 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, II if(canReceive(itemStack)) { double energyNeeded = getMaxEnergy(itemStack)-getEnergy(itemStack); - double toReceive = Math.min(energy, energyNeeded); + double toReceive = Math.min(energy*Mekanism.FROM_UE, energyNeeded); if(doRecharge) { setEnergy(itemStack, getEnergy(itemStack) + toReceive); } - return (float)toReceive; + return (float)(toReceive*Mekanism.TO_UE); } return 0; @@ -355,14 +355,14 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, II if(canSend(itemStack)) { double energyRemaining = getEnergy(itemStack); - double toSend = Math.min(energy, energyRemaining); + double toSend = Math.min((energy*Mekanism.FROM_UE), energyRemaining); if(doDischarge) { setEnergy(itemStack, getEnergy(itemStack) - toSend); } - return (float)toSend; + return (float)(toSend*Mekanism.TO_UE); } return 0; @@ -371,24 +371,24 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, II @Override public float getElectricityStored(ItemStack theItem) { - return (float)getEnergy(theItem); + return (float)(getEnergy(theItem)*Mekanism.TO_UE); } @Override public float getMaxElectricityStored(ItemStack theItem) { - return (float)getMaxEnergy(theItem); + return (float)(getMaxEnergy(theItem)*Mekanism.TO_UE); } @Override public void setElectricity(ItemStack itemStack, float joules) { - setEnergy(itemStack, joules); + setEnergy(itemStack, joules*Mekanism.TO_UE); } @Override public float getTransfer(ItemStack itemStack) { - return (float)getMaxTransfer(itemStack); + return (float)(getMaxTransfer(itemStack)*Mekanism.TO_UE); } } diff --git a/common/mekanism/common/ItemBlockMachine.java b/common/mekanism/common/ItemBlockMachine.java index 07e11d083..c6fa57e15 100644 --- a/common/mekanism/common/ItemBlockMachine.java +++ b/common/mekanism/common/ItemBlockMachine.java @@ -744,13 +744,13 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem @Override public float receiveEnergy(ItemStack theItem, float energy, boolean doReceive) { - return (float)(recharge(theItem, (float)(energy*Mekanism.FROM_BC), doReceive)*Mekanism.TO_BC); + return (float)(recharge(theItem, (float)((energy*Mekanism.FROM_BC)*Mekanism.TO_UE), doReceive)*Mekanism.TO_BC); } @Override public float transferEnergy(ItemStack theItem, float energy, boolean doTransfer) { - return (float)(discharge(theItem, (float)(energy*Mekanism.FROM_BC), doTransfer)*Mekanism.TO_BC); + return (float)(discharge(theItem, (float)((energy*Mekanism.FROM_BC)*Mekanism.TO_UE), doTransfer)*Mekanism.TO_BC); } @Override @@ -777,14 +777,14 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem if(canReceive(itemStack)) { double energyNeeded = getMaxEnergy(itemStack)-getEnergy(itemStack); - double toReceive = Math.min(energy, energyNeeded); + double toReceive = Math.min(energy*Mekanism.FROM_UE, energyNeeded); if(doRecharge) { setEnergy(itemStack, getEnergy(itemStack) + toReceive); } - return (float)toReceive; + return (float)(toReceive*Mekanism.TO_UE); } return 0; @@ -796,14 +796,14 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem if(canSend(itemStack)) { double energyRemaining = getEnergy(itemStack); - double toSend = Math.min(energy, energyRemaining); + double toSend = Math.min((energy*Mekanism.FROM_UE), energyRemaining); if(doDischarge) { setEnergy(itemStack, getEnergy(itemStack) - toSend); } - return (float)toSend; + return (float)(toSend*Mekanism.TO_UE); } return 0; @@ -812,24 +812,24 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem @Override public float getElectricityStored(ItemStack theItem) { - return (float)getEnergy(theItem); + return (float)(getEnergy(theItem)*Mekanism.TO_UE); } @Override public float getMaxElectricityStored(ItemStack theItem) { - return (float)getMaxEnergy(theItem); + return (float)(getMaxEnergy(theItem)*Mekanism.TO_UE); } @Override public void setElectricity(ItemStack itemStack, float joules) { - setEnergy(itemStack, joules); + setEnergy(itemStack, joules*Mekanism.TO_UE); } @Override public float getTransfer(ItemStack itemStack) { - return (float)getMaxTransfer(itemStack); + return (float)(getMaxTransfer(itemStack)*Mekanism.TO_UE); } } diff --git a/common/mekanism/common/ItemEnergized.java b/common/mekanism/common/ItemEnergized.java index be2b0891e..b0caad826 100644 --- a/common/mekanism/common/ItemEnergized.java +++ b/common/mekanism/common/ItemEnergized.java @@ -213,13 +213,13 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem @Override public float receiveEnergy(ItemStack theItem, float energy, boolean doReceive) { - return (float)(recharge(theItem, (float)(energy*Mekanism.FROM_BC), doReceive)*Mekanism.TO_BC); + return (float)(recharge(theItem, (float)((energy*Mekanism.FROM_BC)*Mekanism.TO_UE), doReceive)*Mekanism.TO_BC); } @Override public float transferEnergy(ItemStack theItem, float energy, boolean doTransfer) { - return (float)(discharge(theItem, (float)(energy*Mekanism.FROM_BC), doTransfer)*Mekanism.TO_BC); + return (float)(discharge(theItem, (float)((energy*Mekanism.FROM_BC)*Mekanism.TO_UE), doTransfer)*Mekanism.TO_BC); } @Override @@ -246,14 +246,14 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem if(canReceive(itemStack)) { double energyNeeded = getMaxEnergy(itemStack)-getEnergy(itemStack); - double toReceive = Math.min(energy, energyNeeded); + double toReceive = Math.min(energy*Mekanism.FROM_UE, energyNeeded); if(doRecharge) { setEnergy(itemStack, getEnergy(itemStack) + toReceive); } - return (float)toReceive; + return (float)(toReceive*Mekanism.TO_UE); } return 0; @@ -265,14 +265,14 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem if(canSend(itemStack)) { double energyRemaining = getEnergy(itemStack); - double toSend = Math.min(energy, energyRemaining); + double toSend = Math.min((energy*Mekanism.FROM_UE), energyRemaining); if(doDischarge) { setEnergy(itemStack, getEnergy(itemStack) - toSend); } - return (float)toSend; + return (float)(toSend*Mekanism.TO_UE); } return 0; @@ -281,24 +281,24 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem @Override public float getElectricityStored(ItemStack theItem) { - return (float)getEnergy(theItem); + return (float)(getEnergy(theItem)*Mekanism.TO_UE); } @Override public float getMaxElectricityStored(ItemStack theItem) { - return (float)getMaxEnergy(theItem); + return (float)(getMaxEnergy(theItem)*Mekanism.TO_UE); } @Override public void setElectricity(ItemStack itemStack, float joules) { - setEnergy(itemStack, joules); + setEnergy(itemStack, joules*Mekanism.TO_UE); } @Override public float getTransfer(ItemStack itemStack) { - return (float)getMaxTransfer(itemStack); + return (float)(getMaxTransfer(itemStack)*Mekanism.TO_UE); } } diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 1228bd790..a3c26a19e 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -189,6 +189,8 @@ public class Mekanism public static double TO_BC; public static double FROM_IC2; public static double FROM_BC; + public static double TO_UE = .001; + public static double FROM_UE = 1000; public static double ENERGY_PER_REDSTONE = 10000; //Usage Configuration diff --git a/common/mekanism/common/TileEntityElectricBlock.java b/common/mekanism/common/TileEntityElectricBlock.java index 8ef91ad50..7c72c7901 100644 --- a/common/mekanism/common/TileEntityElectricBlock.java +++ b/common/mekanism/common/TileEntityElectricBlock.java @@ -182,14 +182,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i { if(getConsumingSides().contains(from)) { - float toAdd = (float)Math.min(getMaxEnergy()-getEnergy(), receive.getWatts()); + double toAdd = (float)Math.min(getMaxEnergy()-getEnergy(), receive.getWatts()*Mekanism.FROM_UE); if(doReceive) { setEnergy(getEnergy() + toAdd); } - return toAdd; + return (float)(toAdd*Mekanism.TO_UE); } return 0; @@ -206,7 +206,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i { if(getConsumingSides().contains(direction)) { - return (float)(getMaxEnergy()-getEnergy()); + return (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_UE); } return 0; @@ -221,18 +221,18 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public void setEnergyStored(float energy) { - setEnergy(energy); + setEnergy(energy*Mekanism.FROM_UE); } @Override public float getEnergyStored() { - return (float)getEnergy(); + return (float)(getEnergy()*Mekanism.TO_UE); } @Override public float getMaxEnergyStored() { - return (float)getMaxEnergy(); + return (float)(getMaxEnergy()*Mekanism.TO_UE); } } diff --git a/common/mekanism/generators/client/GuiBioGenerator.java b/common/mekanism/generators/client/GuiBioGenerator.java index a1e541836..5cb4ddf1e 100644 --- a/common/mekanism/generators/client/GuiBioGenerator.java +++ b/common/mekanism/generators/client/GuiBioGenerator.java @@ -37,13 +37,13 @@ public class GuiBioGenerator extends GuiContainer fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00); + fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), 51, 26, 0x00CD00); fontRenderer.drawString("BioFuel: " + tileEntity.bioFuelSlot.fluidStored, 51, 35, 0x00CD00); fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00); if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); } } diff --git a/common/mekanism/generators/client/GuiHeatGenerator.java b/common/mekanism/generators/client/GuiHeatGenerator.java index abf35f876..0e9480003 100644 --- a/common/mekanism/generators/client/GuiHeatGenerator.java +++ b/common/mekanism/generators/client/GuiHeatGenerator.java @@ -38,13 +38,13 @@ public class GuiHeatGenerator extends GuiContainer fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00); + fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), 51, 26, 0x00CD00); fontRenderer.drawString("Fuel: " + (tileEntity.lavaTank.getFluid() != null ? tileEntity.lavaTank.getFluid().amount : 0), 51, 35, 0x00CD00); fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00); if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); } } diff --git a/common/mekanism/generators/client/GuiHydrogenGenerator.java b/common/mekanism/generators/client/GuiHydrogenGenerator.java index 22f817292..155a13146 100644 --- a/common/mekanism/generators/client/GuiHydrogenGenerator.java +++ b/common/mekanism/generators/client/GuiHydrogenGenerator.java @@ -38,13 +38,13 @@ public class GuiHydrogenGenerator extends GuiContainer fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00); + fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), 51, 26, 0x00CD00); fontRenderer.drawString("H: " + tileEntity.hydrogenStored, 51, 35, 0x00CD00); fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00); if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); } } diff --git a/common/mekanism/generators/client/GuiSolarGenerator.java b/common/mekanism/generators/client/GuiSolarGenerator.java index bdf7d392a..82458fd36 100644 --- a/common/mekanism/generators/client/GuiSolarGenerator.java +++ b/common/mekanism/generators/client/GuiSolarGenerator.java @@ -38,13 +38,13 @@ public class GuiSolarGenerator extends GuiContainer fontRenderer.drawString(tileEntity.fullName, tileEntity.fullName != "Advanced Solar Generator" ? 45 : 30, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00); + fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), 51, 26, 0x00CD00); fontRenderer.drawString("Sun: " + tileEntity.seesSun, 51, 35, 0x00CD00); fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00); if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); } } diff --git a/common/mekanism/generators/client/GuiWindTurbine.java b/common/mekanism/generators/client/GuiWindTurbine.java index ea77c8cad..c5c81d879 100644 --- a/common/mekanism/generators/client/GuiWindTurbine.java +++ b/common/mekanism/generators/client/GuiWindTurbine.java @@ -39,7 +39,7 @@ public class GuiWindTurbine extends GuiContainer fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00); + fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), 51, 26, 0x00CD00); fontRenderer.drawString("Power: " + MekanismGenerators.windGeneration*tileEntity.getMultiplier(), 51, 35, 0x00CD00); fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00); @@ -53,7 +53,7 @@ public class GuiWindTurbine extends GuiContainer if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort((float)tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis); + drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES), xAxis, yAxis); } } diff --git a/common/mekanism/generators/common/ItemBlockGenerator.java b/common/mekanism/generators/common/ItemBlockGenerator.java index 370f1b2a1..e2d9654f5 100644 --- a/common/mekanism/generators/common/ItemBlockGenerator.java +++ b/common/mekanism/generators/common/ItemBlockGenerator.java @@ -414,13 +414,13 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt @Override public float receiveEnergy(ItemStack theItem, float energy, boolean doReceive) { - return (float)(recharge(theItem, (float)(energy*Mekanism.FROM_BC), doReceive)*Mekanism.TO_BC); + return (float)(recharge(theItem, (float)((energy*Mekanism.FROM_BC)*Mekanism.TO_UE), doReceive)*Mekanism.TO_BC); } @Override public float transferEnergy(ItemStack theItem, float energy, boolean doTransfer) { - return (float)(discharge(theItem, (float)(energy*Mekanism.FROM_BC), doTransfer)*Mekanism.TO_BC); + return (float)(discharge(theItem, (float)((energy*Mekanism.FROM_BC)*Mekanism.TO_UE), doTransfer)*Mekanism.TO_BC); } @Override @@ -447,14 +447,14 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt if(canReceive(itemStack)) { double energyNeeded = getMaxEnergy(itemStack)-getEnergy(itemStack); - double toReceive = Math.min(energy, energyNeeded); + double toReceive = Math.min(energy*Mekanism.FROM_UE, energyNeeded); if(doRecharge) { setEnergy(itemStack, getEnergy(itemStack) + toReceive); } - return (float)toReceive; + return (float)(toReceive*Mekanism.TO_UE); } return 0; @@ -466,14 +466,14 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt if(canSend(itemStack)) { double energyRemaining = getEnergy(itemStack); - double toSend = Math.min(energy, energyRemaining); + double toSend = Math.min((energy*Mekanism.FROM_UE), energyRemaining); if(doDischarge) { setEnergy(itemStack, getEnergy(itemStack) - toSend); } - return (float)toSend; + return (float)(toSend*Mekanism.TO_UE); } return 0; @@ -482,24 +482,24 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt @Override public float getElectricityStored(ItemStack theItem) { - return (float)getEnergy(theItem); + return (float)(getEnergy(theItem)*Mekanism.TO_UE); } @Override public float getMaxElectricityStored(ItemStack theItem) { - return (float)getMaxEnergy(theItem); + return (float)(getMaxEnergy(theItem)*Mekanism.TO_UE); } @Override public void setElectricity(ItemStack itemStack, float joules) { - setEnergy(itemStack, joules); + setEnergy(itemStack, joules*Mekanism.TO_UE); } @Override public float getTransfer(ItemStack itemStack) { - return (float)getMaxTransfer(itemStack); + return (float)(getMaxTransfer(itemStack)*Mekanism.TO_UE); } }