diff --git a/src/main/java/mekanism/common/EnergyNetwork.java b/src/main/java/mekanism/common/EnergyNetwork.java index 11b012149..f83a19a6b 100644 --- a/src/main/java/mekanism/common/EnergyNetwork.java +++ b/src/main/java/mekanism/common/EnergyNetwork.java @@ -201,21 +201,26 @@ public class EnergyNetwork extends DynamicNetwork if(acceptor instanceof IStrictEnergyAcceptor) { - sent += ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending); + double used = ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending); + sent += used; + if(used > 0) continue; } - else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) + if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) { IEnergyHandler handler = (IEnergyHandler)acceptor; int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(currentSending*Mekanism.TO_TE), false); sent += used*Mekanism.FROM_TE; + if(used > 0) continue; } - else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) + if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) { - double toSend = Math.min(currentSending, EnergyNet.instance.getPowerFromTier(((IEnergySink) acceptor).getSinkTier())*Mekanism.FROM_IC2); + double toSend = Math.min(currentSending, EnergyNet.instance.getPowerFromTier(Math.min(((IEnergySink) acceptor).getSinkTier(), 8))*Mekanism.FROM_IC2); toSend = Math.min(toSend, ((IEnergySink)acceptor).getDemandedEnergy()*Mekanism.FROM_IC2); - sent += (toSend - (((IEnergySink)acceptor).injectEnergy(side.getOpposite(), toSend*Mekanism.TO_IC2, 0)*Mekanism.FROM_IC2)); + double used = toSend - (((IEnergySink)acceptor).injectEnergy(side.getOpposite(), toSend*Mekanism.TO_IC2, 0)*Mekanism.FROM_IC2); + sent += used; + if(used > 0) continue; } - else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) + if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) { PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(side.getOpposite()); @@ -223,6 +228,7 @@ public class EnergyNetwork extends DynamicNetwork { double toSend = receiver.receiveEnergy(Type.PIPE, (float)(Math.min(receiver.powerRequest(), currentSending*Mekanism.TO_BC)), side.getOpposite()); sent += toSend*Mekanism.FROM_BC; + if(toSend > 0) continue; } } } @@ -260,10 +266,11 @@ public class EnergyNetwork extends DynamicNetwork if(handler.getMaxEnergy() - handler.getEnergy() > 0) { toReturn.add(acceptor); + continue; } } } - else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) + if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) { IEnergyHandler handler = (IEnergyHandler)acceptor; @@ -272,22 +279,27 @@ public class EnergyNetwork extends DynamicNetwork if(handler.getMaxEnergyStored(side.getOpposite()) - handler.getEnergyStored(side.getOpposite()) > 0 || handler.receiveEnergy(side.getOpposite(), 1, true) > 0) { toReturn.add(acceptor); + continue; } } } - else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) + if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) { IEnergySink handler = (IEnergySink)acceptor; if(handler.acceptsEnergyFrom(null, side.getOpposite())) { - if(Math.min((handler.getDemandedEnergy()*Mekanism.FROM_IC2), (EnergyNet.instance.getPowerFromTier(handler.getSinkTier())*Mekanism.FROM_IC2)) > 0) + double demanded = handler.getDemandedEnergy()*Mekanism.FROM_IC2; + int tier = Math.min(handler.getSinkTier(), 8); + double max = EnergyNet.instance.getPowerFromTier(tier)*Mekanism.FROM_IC2; + if(Math.min(demanded, max) > 0) { toReturn.add(acceptor); + continue; } } } - else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) + if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) { IPowerReceptor handler = (IPowerReceptor)acceptor; @@ -301,6 +313,7 @@ public class EnergyNetwork extends DynamicNetwork } toReturn.add(acceptor); + continue; } } } diff --git a/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java b/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java index b596bbdcb..cb3698ded 100644 --- a/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java +++ b/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java @@ -5,6 +5,8 @@ import mekanism.generators.client.gui.GuiHeatGenerator; import mekanism.generators.client.gui.GuiGasGenerator; import mekanism.generators.client.gui.GuiNeutronCapture; import mekanism.generators.client.gui.GuiReactorController; +import mekanism.generators.client.gui.GuiReactorFuel; +import mekanism.generators.client.gui.GuiReactorHeat; import mekanism.generators.client.gui.GuiSolarGenerator; import mekanism.generators.client.gui.GuiWindTurbine; import mekanism.generators.client.render.RenderAdvancedSolarGenerator; @@ -77,6 +79,10 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy case 10: return new GuiReactorController(player.inventory, (TileEntityReactorController)tileEntity); case 11: + return new GuiReactorHeat(player.inventory, (TileEntityReactorController)tileEntity); + case 12: + return new GuiReactorFuel(player.inventory, (TileEntityReactorController)tileEntity); + case 13: return new GuiNeutronCapture(player.inventory, (TileEntityReactorNeutronCapture)tileEntity); } diff --git a/src/main/java/mekanism/generators/client/gui/GuiFuelTab.java b/src/main/java/mekanism/generators/client/gui/GuiFuelTab.java new file mode 100644 index 000000000..bc637a2eb --- /dev/null +++ b/src/main/java/mekanism/generators/client/gui/GuiFuelTab.java @@ -0,0 +1,84 @@ +package mekanism.generators.client.gui; + +import mekanism.api.Coord4D; +import mekanism.client.gui.GuiElement; +import mekanism.client.gui.IGuiWrapper; +import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; +import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mekanism.generators.common.MekanismGenerators; +import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiFuelTab extends GuiElement +{ + TileEntity tileEntity; + + public GuiFuelTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) + { + super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiFuelTab.png"), gui, def); + + tileEntity = tile; + } + + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) + { + return new Rectangle4i(guiWidth - 26, guiHeight + 34, 26, 26); + } + + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) + { + mc.renderEngine.bindTexture(RESOURCE); + + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 34, 0, 0, 26, 26); + + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) + { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 38, 26, 0, 18, 18); + } + else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 38, 26, 18, 18, 18); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) + { + mc.renderEngine.bindTexture(RESOURCE); + + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) + { + displayTooltip(MekanismUtils.localize("gui.fuel"), xAxis, yAxis); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) + { + if(button == 0) + { + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) + { + MekanismGenerators.packetHandler.sendToServer(new GeneratorsGuiMessage(Coord4D.get(tileEntity), 12)); + SoundHandler.playSound("gui.button.press"); + } + } + } +} diff --git a/src/main/java/mekanism/generators/client/gui/GuiHeatTab.java b/src/main/java/mekanism/generators/client/gui/GuiHeatTab.java new file mode 100644 index 000000000..e6cb80ff2 --- /dev/null +++ b/src/main/java/mekanism/generators/client/gui/GuiHeatTab.java @@ -0,0 +1,84 @@ +package mekanism.generators.client.gui; + +import mekanism.api.Coord4D; +import mekanism.client.gui.GuiElement; +import mekanism.client.gui.IGuiWrapper; +import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; +import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mekanism.generators.common.MekanismGenerators; +import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiHeatTab extends GuiElement +{ + TileEntity tileEntity; + + public GuiHeatTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) + { + super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiHeatTab.png"), gui, def); + + tileEntity = tile; + } + + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) + { + return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26); + } + + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) + { + mc.renderEngine.bindTexture(RESOURCE); + + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 6, 0, 0, 26, 26); + + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) + { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 0, 18, 18); + } + else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 18, 18, 18); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) + { + mc.renderEngine.bindTexture(RESOURCE); + + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) + { + displayTooltip(MekanismUtils.localize("gui.heat"), xAxis, yAxis); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) + { + if(button == 0) + { + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) + { + MekanismGenerators.packetHandler.sendToServer(new GeneratorsGuiMessage(Coord4D.get(tileEntity), 11)); + SoundHandler.playSound("gui.button.press"); + } + } + } +} diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java index 4b1312306..9700acffc 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java @@ -1,7 +1,9 @@ package mekanism.generators.client.gui; +import java.util.ArrayList; import java.util.List; +import mekanism.api.Coord4D; import mekanism.api.ListUtils; import mekanism.api.gas.GasTank; import mekanism.client.gui.GuiEnergyInfo; @@ -17,6 +19,9 @@ import mekanism.client.gui.GuiNumberGauge.INumberInfoHandler; import mekanism.client.gui.GuiPowerBar; import mekanism.client.gui.GuiSlot; import mekanism.client.gui.GuiSlot.SlotType; +import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; +import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.common.inventory.container.ContainerReactorController; @@ -48,101 +53,10 @@ public class GuiReactorController extends GuiMekanism "Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), "Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() - { - @Override - public GasTank getTank() - { - return tentity.deuteriumTank; - } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 124, 6)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() - { - @Override - public GasTank getTank() - { - return tentity.tritiumTank; - } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 124, 36)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() - { - @Override - public GasTank getTank() - { - return tentity.fuelTank; - } - }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 144, 6)); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() - { - @Override - public FluidTank getTank() - { - return tentity.waterTank; - } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 78, 46)); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() - { - @Override - public FluidTank getTank() - { - return tentity.steamTank; - } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 98, 46)); - guiElements.add(new GuiNumberGauge(new INumberInfoHandler() - { - @Override - public IIcon getIcon() - { - return BlockStaticLiquid.getLiquidIcon("lava_still"); - } - - @Override - public double getLevel() - { - return tileEntity.getPlasmaTemp(); - } - - @Override - public double getMaxLevel() - { - return 5E8; - } - - @Override - public String getText(double level) - { - return "Plasma: " + (int)(level+23) + "C"; - } - }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall"), 124, 76)); - guiElements.add(new GuiNumberGauge(new INumberInfoHandler() - { - @Override - public IIcon getIcon() - { - return BlockStaticLiquid.getLiquidIcon("lava_still"); - } - - @Override - public double getLevel() - { - return tileEntity.getCaseTemp(); - } - - @Override - public double getMaxLevel() - { - return 5E8; - } - - @Override - public String getText(double level) - { - return "Case: " + (int)(level+23) + "C"; - } - }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 144, 76)); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 164, 15)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 98, 26)); + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); + guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 79, 38)); + guiElements.add(new GuiHeatTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); + guiElements.add(new GuiFuelTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); } @Override @@ -164,7 +78,7 @@ public class GuiReactorController extends GuiMekanism @Override protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png")); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int guiWidth = (width - xSize) / 2; int guiHeight = (height - ySize) / 2; @@ -172,4 +86,25 @@ public class GuiReactorController extends GuiMekanism super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } + + @Override + protected void mouseClicked(int x, int y, int button) + { + super.mouseClicked(x, y, button); + + if(button == 0) + { + int xAxis = (x - (width - xSize) / 2); + int yAxis = (y - (height - ySize) / 2); + + if(xAxis >= 48 && xAxis <= 128 && yAxis >= 5 && yAxis <= 17) + { + ArrayList data = new ArrayList(); + data.add(0); + + Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + SoundHandler.playSound("gui.button.press"); + } + } + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java new file mode 100644 index 000000000..ac3e6e956 --- /dev/null +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java @@ -0,0 +1,117 @@ +package mekanism.generators.client.gui; + +import java.util.List; + +import mekanism.api.ListUtils; +import mekanism.api.gas.GasTank; +import mekanism.client.gui.GuiEnergyInfo; +import mekanism.client.gui.GuiEnergyInfo.IInfoHandler; +import mekanism.client.gui.GuiFluidGauge; +import mekanism.client.gui.GuiFluidGauge.IFluidInfoHandler; +import mekanism.client.gui.GuiGasGauge; +import mekanism.client.gui.GuiGasGauge.IGasInfoHandler; +import mekanism.client.gui.GuiGauge.Type; +import mekanism.client.gui.GuiMekanism; +import mekanism.client.gui.GuiNumberGauge; +import mekanism.client.gui.GuiNumberGauge.INumberInfoHandler; +import mekanism.client.gui.GuiPowerBar; +import mekanism.client.gui.GuiProgress; +import mekanism.client.gui.GuiProgress.IProgressInfoHandler; +import mekanism.client.gui.GuiProgress.ProgressBar; +import mekanism.client.gui.GuiSlot; +import mekanism.client.gui.GuiSlot.SlotType; +import mekanism.common.inventory.container.ContainerNull; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mekanism.generators.common.inventory.container.ContainerReactorController; +import mekanism.generators.common.tile.reactor.TileEntityReactorController; + +import net.minecraft.block.BlockStaticLiquid; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.FluidTank; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiReactorFuel extends GuiMekanism +{ + public TileEntityReactorController tileEntity; + + public GuiReactorFuel(InventoryPlayer inventory, final TileEntityReactorController tentity) + { + super(new ContainerNull(inventory.player, tentity)); + tileEntity = tentity; + guiElements.add(new GuiEnergyInfo(new IInfoHandler() + { + @Override + public List getInfo() + { + return ListUtils.asList( + "Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + "Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); + guiElements.add(new GuiGasGauge(new IGasInfoHandler() + { + @Override + public GasTank getTank() + { + return tentity.deuteriumTank; + } + }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 25, 64)); + guiElements.add(new GuiGasGauge(new IGasInfoHandler() + { + @Override + public GasTank getTank() + { + return tentity.fuelTank; + } + }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 79, 50)); + guiElements.add(new GuiGasGauge(new IGasInfoHandler() + { + @Override + public GasTank getTank() + { + return tentity.tritiumTank; + } + }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 133, 64)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return tileEntity.getActive() ? 1 : 0; + } + }, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 45, 75)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return tileEntity.getActive() ? 1 : 0; + } + }, ProgressBar.SMALL_LEFT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 99, 75)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + + fontRendererObj.drawString(tileEntity.getInventoryName(), 6, 6, 0x404040); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png")); + 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); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } +} diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java new file mode 100644 index 000000000..c23ca7b3c --- /dev/null +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java @@ -0,0 +1,180 @@ +package mekanism.generators.client.gui; + +import java.util.List; + +import mekanism.api.ListUtils; +import mekanism.api.energy.IStrictEnergyStorage; +import mekanism.api.gas.GasTank; +import mekanism.client.gui.GuiEnergyGauge; +import mekanism.client.gui.GuiEnergyGauge.IEnergyInfoHandler; +import mekanism.client.gui.GuiEnergyInfo; +import mekanism.client.gui.GuiEnergyInfo.IInfoHandler; +import mekanism.client.gui.GuiFluidGauge; +import mekanism.client.gui.GuiFluidGauge.IFluidInfoHandler; +import mekanism.client.gui.GuiGasGauge; +import mekanism.client.gui.GuiGasGauge.IGasInfoHandler; +import mekanism.client.gui.GuiGauge.Type; +import mekanism.client.gui.GuiMekanism; +import mekanism.client.gui.GuiNumberGauge; +import mekanism.client.gui.GuiNumberGauge.INumberInfoHandler; +import mekanism.client.gui.GuiPowerBar; +import mekanism.client.gui.GuiProgress; +import mekanism.client.gui.GuiProgress.IProgressInfoHandler; +import mekanism.client.gui.GuiProgress.ProgressBar; +import mekanism.client.gui.GuiSlot; +import mekanism.client.gui.GuiSlot.SlotType; +import mekanism.common.inventory.container.ContainerNull; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import mekanism.generators.common.inventory.container.ContainerReactorController; +import mekanism.generators.common.tile.reactor.TileEntityReactorController; + +import net.minecraft.block.BlockStaticLiquid; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.FluidTank; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiReactorHeat extends GuiMekanism +{ + public TileEntityReactorController tileEntity; + + public GuiReactorHeat(InventoryPlayer inventory, final TileEntityReactorController tentity) + { + super(new ContainerNull(inventory.player, tentity)); + tileEntity = tentity; + guiElements.add(new GuiEnergyInfo(new IInfoHandler() + { + @Override + public List getInfo() + { + return ListUtils.asList( + "Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + "Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); + guiElements.add(new GuiNumberGauge(new INumberInfoHandler() + { + @Override + public IIcon getIcon() + { + return BlockStaticLiquid.getLiquidIcon("lava_still"); + } + + @Override + public double getLevel() + { + return tileEntity.getPlasmaTemp(); + } + + @Override + public double getMaxLevel() + { + return 5E8; + } + + @Override + public String getText(double level) + { + return "Plasma: " + (int)(level+23) + "C"; + } + }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 7, 50)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return tileEntity.getPlasmaTemp() > tileEntity.getCaseTemp() ? 1 : 0; + } + }, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 27, 75)); + guiElements.add(new GuiNumberGauge(new INumberInfoHandler() + { + @Override + public IIcon getIcon() + { + return BlockStaticLiquid.getLiquidIcon("lava_still"); + } + + @Override + public double getLevel() + { + return tileEntity.getCaseTemp(); + } + + @Override + public double getMaxLevel() + { + return 5E8; + } + + @Override + public String getText(double level) + { + return "Case: " + (int)(level+23) + "C"; + } + }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 61, 50)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return tileEntity.getCaseTemp() > 0 ? 1 : 0; + } + }, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 81, 60)); + guiElements.add(new GuiProgress(new IProgressInfoHandler() + { + @Override + public double getProgress() + { + return (tileEntity.getCaseTemp() > 0 && tileEntity.waterTank.getFluidAmount() > 0 && tileEntity.steamTank.getFluidAmount() < tileEntity.steamTank.getCapacity()) ? 1 : 0; + } + }, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 81, 90)); + guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() + { + @Override + public FluidTank getTank() + { + return tentity.waterTank; + } + }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 115, 84)); + guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() + { + @Override + public FluidTank getTank() + { + return tentity.steamTank; + } + }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 151, 84)); + guiElements.add(new GuiEnergyGauge(new IEnergyInfoHandler() + { + @Override + public IStrictEnergyStorage getEnergyStorage() + { + return tileEntity; + } + }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 115, 46)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + + fontRendererObj.drawString(tileEntity.getInventoryName(), 6, 6, 0x404040); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png")); + 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); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } +} diff --git a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java index 2b316f330..e7b4ac667 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java +++ b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java @@ -1,6 +1,7 @@ package mekanism.generators.common; import mekanism.common.Mekanism; +import mekanism.common.inventory.container.ContainerNull; import mekanism.generators.common.inventory.container.ContainerBioGenerator; import mekanism.generators.common.inventory.container.ContainerHeatGenerator; import mekanism.generators.common.inventory.container.ContainerGasGenerator; @@ -124,6 +125,9 @@ public class GeneratorsCommonProxy case 10: return new ContainerReactorController(player.inventory, (TileEntityReactorController)tileEntity); case 11: + case 12: + return new ContainerNull(player, (TileEntityReactorController)tileEntity); + case 13: return new ContainerNeutronCapture(player.inventory, (TileEntityReactorNeutronCapture)tileEntity); } diff --git a/src/main/java/mekanism/generators/common/GeneratorsPacketHandler.java b/src/main/java/mekanism/generators/common/GeneratorsPacketHandler.java new file mode 100644 index 000000000..c69fe425f --- /dev/null +++ b/src/main/java/mekanism/generators/common/GeneratorsPacketHandler.java @@ -0,0 +1,183 @@ +package mekanism.generators.common; + +import io.netty.buffer.ByteBuf; + +import java.util.ArrayList; +import java.util.List; + +import mekanism.common.Mekanism; +import mekanism.generators.common.network.PacketGeneratorsGui; +import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import cpw.mods.fml.relauncher.Side; + +/** + * Mekanism packet handler. As always, use packets sparingly! + * @author AidanBrady + * + */ +public class GeneratorsPacketHandler +{ + public SimpleNetworkWrapper netHandler = NetworkRegistry.INSTANCE.newSimpleChannel("MEKGEN"); + + public void initialize() + { + netHandler.registerMessage(PacketGeneratorsGui.class, GeneratorsGuiMessage.class, 0, Side.SERVER); + netHandler.registerMessage(PacketGeneratorsGui.class, GeneratorsGuiMessage.class, 0, Side.CLIENT); + } + + /** + * Encodes an Object[] of data into a DataOutputStream. + * @param dataValues - an Object[] of data to encode + * @param output - the output stream to write to + */ + public static void encode(Object[] dataValues, ByteBuf output) + { + try { + for(Object data : dataValues) + { + if(data instanceof Integer) + { + output.writeInt((Integer)data); + } + else if(data instanceof Boolean) + { + output.writeBoolean((Boolean)data); + } + else if(data instanceof Double) + { + output.writeDouble((Double)data); + } + else if(data instanceof Float) + { + output.writeFloat((Float)data); + } + else if(data instanceof String) + { + writeString(output, (String)data); + } + else if(data instanceof Byte) + { + output.writeByte((Byte)data); + } + else if(data instanceof int[]) + { + for(int i : (int[])data) + { + output.writeInt(i); + } + } + else if(data instanceof byte[]) + { + for(byte b : (byte[])data) + { + output.writeByte(b); + } + } + else if(data instanceof ArrayList) + { + encode(((ArrayList)data).toArray(), output); + } + } + } catch(Exception e) { + Mekanism.logger.error("Error while encoding packet data."); + e.printStackTrace(); + } + } + + public static void writeString(ByteBuf output, String s) + { + output.writeInt(s.getBytes().length); + output.writeBytes(s.getBytes()); + } + + public static String readString(ByteBuf input) + { + return new String(input.readBytes(input.readInt()).array()); + } + + public static EntityPlayer getPlayer(MessageContext context) + { + return Mekanism.proxy.getPlayer(context); + } + + /** + * Send this message to everyone. + * @param message - the message to send + */ + public void sendToAll(IMessage message) + { + netHandler.sendToAll(message); + } + + /** + * Send this message to the specified player. + * @param message - the message to send + * @param player - the player to send it to + */ + public void sendTo(IMessage message, EntityPlayerMP player) + { + netHandler.sendTo(message, player); + } + + /** + * Send this message to everyone within a certain range of a point. + * + * @param message - the message to send + * @param point - the TargetPoint around which to send + */ + public void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) + { + netHandler.sendToAllAround(message, point); + } + + /** + * Send this message to everyone within the supplied dimension. + * @param message - the message to send + * @param dimensionId - the dimension id to target + */ + public void sendToDimension(IMessage message, int dimensionId) + { + netHandler.sendToDimension(message, dimensionId); + } + + /** + * Send this message to the server. + * @param message - the message to send + */ + public void sendToServer(IMessage message) + { + netHandler.sendToServer(message); + } + + /** + * Send this message to all players within a defined AABB cuboid. + * @param message - the message to send + * @param cuboid - the AABB cuboid to send the packet in + * @param dimId - the dimension the cuboid is in + */ + public void sendToCuboid(IMessage message, AxisAlignedBB cuboid, int dimId) + { + MinecraftServer server = MinecraftServer.getServer(); + + if(server != null && cuboid != null) + { + for(EntityPlayerMP player : (List)server.getConfigurationManager().playerEntityList) + { + if(player.dimension == dimId && cuboid.isVecInside(Vec3.createVectorHelper(player.posX, player.posY, player.posZ))) + { + sendTo(message, player); + } + } + } + } +} diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index fd3b4d8b1..aba5f887e 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -42,6 +42,9 @@ import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "8.0.0", dependencies = "required-after:Mekanism", guiFactory = "mekanism.generators.client.gui.GeneratorsGuiFactory") public class MekanismGenerators implements IModule { + /** Mekanism Generators Packet Pipeline */ + public static GeneratorsPacketHandler packetHandler = new GeneratorsPacketHandler(); + @SidedProxy(clientSide = "mekanism.generators.client.GeneratorsClientProxy", serverSide = "mekanism.generators.common.GeneratorsCommonProxy") public static GeneratorsCommonProxy proxy; @@ -90,6 +93,8 @@ public class MekanismGenerators implements IModule { //Add this module to the core list Mekanism.modulesLoaded.add(this); + + packetHandler.initialize(); //Set up the GUI handler NetworkRegistry.INSTANCE.registerGuiHandler(this, new GeneratorsGuiHandler()); diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index cc31bc86d..0f94d9688 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -7,6 +7,7 @@ import mekanism.api.energy.IEnergizedItem; import mekanism.common.IActiveState; import mekanism.common.IBoundingBlock; import mekanism.common.ISpecialBounds; +import mekanism.common.ISustainedData; import mekanism.common.ISustainedInventory; import mekanism.common.ISustainedTank; import mekanism.common.ItemAttacher; @@ -18,8 +19,8 @@ import mekanism.generators.client.GeneratorsClientProxy; import mekanism.generators.common.MekanismGenerators; import mekanism.generators.common.tile.TileEntityAdvancedSolarGenerator; import mekanism.generators.common.tile.TileEntityBioGenerator; -import mekanism.generators.common.tile.TileEntityHeatGenerator; import mekanism.generators.common.tile.TileEntityGasGenerator; +import mekanism.generators.common.tile.TileEntityHeatGenerator; import mekanism.generators.common.tile.TileEntitySolarGenerator; import mekanism.generators.common.tile.TileEntityWindTurbine; import net.minecraft.block.Block; @@ -39,7 +40,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.tools.IToolWrench; - import cpw.mods.fml.common.ModAPIManager; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -459,6 +459,11 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); + + if(tileEntity instanceof ISustainedData) + { + ((ISustainedData)tileEntity).writeSustainedData(itemStack); + } if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) { diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index 71e5fbb11..e65a0002e 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -260,7 +260,7 @@ public class BlockReactor extends BlockContainer CONTROLLER(MekanismGenerators.Reactor, 0, "ReactorController", 10, TileEntityReactorController.class), FRAME(MekanismGenerators.Reactor, 1, "ReactorFrame", -1, TileEntityReactorFrame.class), LASER_FOCUS_MATRIX(MekanismGenerators.Reactor, 2, "ReactorLaserFocusMatrix", -1, TileEntityReactorLaserFocusMatrix.class), - NEUTRON_CAPTURE(MekanismGenerators.Reactor, 3, "ReactorNeutronCapturePlate", 11, TileEntityReactorNeutronCapture.class), + NEUTRON_CAPTURE(MekanismGenerators.Reactor, 3, "ReactorNeutronCapturePlate", 13, TileEntityReactorNeutronCapture.class), PORT(MekanismGenerators.Reactor, 4, "ReactorInOutPort", -1, TileEntityReactorPort.class), GLASS(MekanismGenerators.ReactorGlass, 0, "ReactorGlass", -1, TileEntityReactorGlass.class); diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java index 91808e4b8..89fc4bce5 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java @@ -18,9 +18,17 @@ public class ContainerReactorController extends Container public ContainerReactorController(InventoryPlayer inventory, TileEntityReactorController tentity) { tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 99, 27)); + addSlotToContainer(new Slot(tentity, 0, 80, 39)); int slotX; + for(slotX = 0; slotX < 3; slotX++) + { + for(int slotY = 0; slotY < 9; slotY++) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + for(slotX = 0; slotX < 9; ++slotX) { addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java index 33e373e8f..83b05f678 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java @@ -8,6 +8,7 @@ import java.util.List; import mekanism.api.EnumColor; import mekanism.api.energy.IEnergizedItem; import mekanism.client.MekanismKeyHandler; +import mekanism.common.ISustainedData; import mekanism.common.ISustainedInventory; import mekanism.common.ISustainedTank; import mekanism.common.Mekanism; @@ -31,7 +32,6 @@ import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; import cofh.api.energy.IEnergyContainerItem; - import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.InterfaceList; import cpw.mods.fml.common.Optional.Method; @@ -169,6 +169,14 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp tileEntity.electricityStored = getEnergy(stack); ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); + + if(tileEntity instanceof ISustainedData) + { + if(stack.stackTagCompound != null) + { + ((ISustainedData)tileEntity).readSustainedData(stack); + } + } if(tileEntity instanceof ISustainedTank) { diff --git a/src/main/java/mekanism/generators/common/network/PacketGeneratorsGui.java b/src/main/java/mekanism/generators/common/network/PacketGeneratorsGui.java new file mode 100644 index 000000000..e12e3bff0 --- /dev/null +++ b/src/main/java/mekanism/generators/common/network/PacketGeneratorsGui.java @@ -0,0 +1,114 @@ +package mekanism.generators.common.network; + +import io.netty.buffer.ByteBuf; +import mekanism.api.Coord4D; +import mekanism.generators.common.GeneratorsPacketHandler; +import mekanism.common.tile.TileEntityBasicBlock; +import mekanism.generators.common.MekanismGenerators; +import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class PacketGeneratorsGui implements IMessageHandler +{ + @Override + public IMessage onMessage(GeneratorsGuiMessage message, MessageContext context) + { + EntityPlayer player = GeneratorsPacketHandler.getPlayer(context); + + if(!player.worldObj.isRemote) + { + World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId); + + if(worldServer != null && message.coord4D.getTileEntity(worldServer) instanceof TileEntityBasicBlock) + { + if(message.guiId == -1) + { + return null; + } + + GeneratorsGuiMessage.openServerGui(message.guiId, (EntityPlayerMP)player, player.worldObj, message.coord4D); + } + } + else { + FMLCommonHandler.instance().showGuiScreen(GeneratorsGuiMessage.getGui(message.guiId, player, player.worldObj, message.coord4D)); + player.openContainer.windowId = message.windowId; + } + + return null; + } + + public static class GeneratorsGuiMessage implements IMessage + { + public Coord4D coord4D; + + public int guiId; + + public int windowId; + + public GeneratorsGuiMessage() {} + + public GeneratorsGuiMessage(Coord4D coord, int gui) + { + coord4D = coord; + guiId = gui; + } + + public GeneratorsGuiMessage(Coord4D coord, int gui, int id) + { + this(coord, gui); + windowId = id; + } + + public static void openServerGui(int id, EntityPlayerMP playerMP, World world, Coord4D obj) + { + playerMP.closeContainer(); + playerMP.getNextWindowId(); + + int window = playerMP.currentWindowId; + + MekanismGenerators.packetHandler.sendTo(new GeneratorsGuiMessage(obj, id, window), playerMP); + + playerMP.openContainer = MekanismGenerators.proxy.getServerGui(id, playerMP, world, obj.xCoord, obj.yCoord, obj.zCoord); + playerMP.openContainer.windowId = window; + playerMP.openContainer.addCraftingToCrafters(playerMP); + } + + @SideOnly(Side.CLIENT) + public static GuiScreen getGui(int id, EntityPlayer player, World world, Coord4D obj) + { + return (GuiScreen)MekanismGenerators.proxy.getClientGui(id, player, world, obj.xCoord, obj.yCoord, obj.zCoord); + } + + @Override + public void toBytes(ByteBuf dataStream) + { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeInt(guiId); + dataStream.writeInt(windowId); + } + + @Override + public void fromBytes(ByteBuf dataStream) + { + coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); + + guiId = dataStream.readInt(); + windowId = dataStream.readInt(); + } + } +} diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java index 916fab482..33170f7a6 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java @@ -7,6 +7,7 @@ import java.util.EnumSet; import mekanism.client.sound.TileSound; import mekanism.common.FluidSlot; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.util.ChargeUtils; import mekanism.common.util.MekanismUtils; @@ -26,7 +27,7 @@ import cpw.mods.fml.relauncher.SideOnly; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandler +public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData { /** The Sound instance for this machine. */ @SideOnly(Side.CLIENT) @@ -317,4 +318,16 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui { return null; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + itemStack.stackTagCompound.setInteger("fluidStored", bioFuelSlot.fluidStored); + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + bioFuelSlot.setFluid(itemStack.stackTagCompound.getInteger("fluidStored")); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java index e04492126..db53d2050 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java @@ -14,6 +14,7 @@ import mekanism.api.gas.GasTransmission; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.util.ChargeUtils; import mekanism.common.util.MekanismUtils; @@ -21,11 +22,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.Optional.Method; - import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ITubeConnection +public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ITubeConnection, ISustainedData { /** The maximum amount of gas this block can store. */ public int MAX_GAS = 18000; @@ -277,4 +277,19 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH { return side != ForgeDirection.getOrientation(facing); } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(fuelTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("fuelTank", fuelTank.write(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + fuelTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("fuelTank"))); + } } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java index 174e653f2..690df00cf 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.api.lasers.ILaserReceptor; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.util.ChargeUtils; import mekanism.common.util.FluidContainerUtils; @@ -28,7 +29,7 @@ import cpw.mods.fml.common.Optional.Method; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler, ILaserReceptor +public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler, ILaserReceptor, ISustainedData { /** The FluidTank for this generator. */ public FluidTank lavaTank = new FluidTank(24000); @@ -354,4 +355,19 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { return 0; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(lavaTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("lavaTank", lavaTank.getFluid().writeToNBT(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + lavaTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("lavaTank"))); + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java index 161cc1e8d..4b9aacf54 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java @@ -109,7 +109,20 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen @Override public void handlePacketData(ByteBuf dataStream) { + if(!worldObj.isRemote) + { + int type = dataStream.readInt(); + + if(type == 0) + { + formMultiblock(); + } + + return; + } + super.handlePacketData(dataStream); + boolean formed = dataStream.readBoolean(); if(formed) { diff --git a/src/main/java/mekanism/tools/common/MekanismTools.java b/src/main/java/mekanism/tools/common/MekanismTools.java index 943f188a0..3f62fdd45 100644 --- a/src/main/java/mekanism/tools/common/MekanismTools.java +++ b/src/main/java/mekanism/tools/common/MekanismTools.java @@ -394,84 +394,84 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "maxUses", 2500).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "efficiency", 20d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "damage", 10).getInt() - , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "enchantability", 40).getInt() ); toolOBSIDIAN2 = EnumHelper.addToolMaterial("OBSIDIAN2" , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "maxUses", 3000).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "efficiency", 25d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "damage", 10).getInt() - , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "enchantability", 50).getInt() ); toolLAZULI = EnumHelper.addToolMaterial("LAZULI" , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "maxUses", 200).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.lapis.regular", "efficiency", 5d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "damage", 2).getInt() - , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "enchantability", 22).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "enchantability", 8).getInt() ); toolLAZULI2 = EnumHelper.addToolMaterial("LAZULI2" , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "maxUses", 250).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "efficiency", 6d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "damage", 4).getInt() - , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "enchantability", 10).getInt() ); toolOSMIUM = EnumHelper.addToolMaterial("OSMIUM" , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "maxUses", 500).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.osmium.regular", "efficiency", 10d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "damage", 4).getInt() - , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "enchantability", 30).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "enchantability", 12).getInt() ); toolOSMIUM2 = EnumHelper.addToolMaterial("OSMIUM2" , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "maxUses", 700).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "efficiency", 12d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "damage", 5).getInt() - , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "enchantability", 40).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "enchantability", 16).getInt() ); toolBRONZE = EnumHelper.addToolMaterial("BRONZE" , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "maxUses", 800).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.bronze.regular", "efficiency", 14d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "damage", 6).getInt() - , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "enchantability", 10).getInt() ); toolBRONZE2 = EnumHelper.addToolMaterial("BRONZE2" , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "maxUses", 1100).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "efficiency", 16d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "damage", 10).getInt() - , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "enchantability", 14).getInt() ); toolGLOWSTONE = EnumHelper.addToolMaterial("GLOWSTONE" , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "maxUses", 300).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "efficiency", 14d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "damage", 5).getInt() - , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "enchantability", 80).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "enchantability", 18).getInt() ); toolGLOWSTONE2 = EnumHelper.addToolMaterial("GLOWSTONE2" , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "maxUses", 450).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "efficiency", 18d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "damage", 5).getInt() - , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "enchantability", 22).getInt() ); toolSTEEL = EnumHelper.addToolMaterial("STEEL" , Mekanism.configuration.get("tools.tool-balance.steel.regular", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.steel.regular", "maxUses", 850).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.steel.regular", "efficiency", 14d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.steel.regular", "damage", 4).getInt() - , Mekanism.configuration.get("tools.tool-balance.steel.regular", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.regular", "enchantability", 10).getInt() ); toolSTEEL2 = EnumHelper.addToolMaterial("STEEL2" , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "maxUses", 1250).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.steel.paxel", "efficiency", 18d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "damage", 8).getInt() - , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "enchantability", 14).getInt() ); //Armors @@ -484,7 +484,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "legs", 8).getInt() , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "feet", 5).getInt() } - , Mekanism.configuration.get("tools.armor-balance.obsidian", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.obsidian", "enchantability", 40).getInt() ); armorLAZULI = EnumHelper.addArmorMaterial("LAZULI" , Mekanism.configuration.get("tools.armor-balance.lapis", "durability", 13).getInt() @@ -495,7 +495,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "legs", 6).getInt() , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "feet", 2).getInt() } - , Mekanism.configuration.get("tools.armor-balance.lapis", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.lapis", "enchantability", 8).getInt() ); armorOSMIUM = EnumHelper.addArmorMaterial("OSMIUM" , Mekanism.configuration.get("tools.armor-balance.osmium", "durability", 30).getInt() @@ -506,7 +506,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "legs", 6).getInt() , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "feet", 3).getInt() } - , Mekanism.configuration.get("tools.armor-balance.osmium", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.osmium", "enchantability", 12).getInt() ); armorBRONZE = EnumHelper.addArmorMaterial("BRONZE" , Mekanism.configuration.get("tools.armor-balance.bronze", "durability", 35).getInt() @@ -517,7 +517,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "legs", 5).getInt() , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "feet", 2).getInt() } - , Mekanism.configuration.get("tools.armor-balance.bronze", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.bronze", "enchantability", 10).getInt() ); armorGLOWSTONE = EnumHelper.addArmorMaterial("GLOWSTONE" , Mekanism.configuration.get("tools.armor-balance.glowstone", "durability", 18).getInt() @@ -528,7 +528,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "legs", 6).getInt() , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "feet", 3).getInt() } - , Mekanism.configuration.get("tools.armor-balance.glowstone", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.glowstone", "enchantability", 18).getInt() ); armorSTEEL = EnumHelper.addArmorMaterial("STEEL" , Mekanism.configuration.get("tools.armor-balance.steel", "durability", 40).getInt() @@ -539,7 +539,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.steel.protection", "legs", 6).getInt() , Mekanism.configuration.get("tools.armor-balance.steel.protection", "feet", 3).getInt() } - , Mekanism.configuration.get("tools.armor-balance.steel", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.steel", "enchantability", 10).getInt() ); //Bronze diff --git a/src/main/resources/assets/mekanism/gui/GuiTall.png b/src/main/resources/assets/mekanism/gui/GuiTall.png index f1edcc4d3..5e44ebf6c 100644 Binary files a/src/main/resources/assets/mekanism/gui/GuiTall.png and b/src/main/resources/assets/mekanism/gui/GuiTall.png differ diff --git a/src/main/resources/assets/mekanism/gui/elements/GuiFuelTab.png b/src/main/resources/assets/mekanism/gui/elements/GuiFuelTab.png new file mode 100644 index 000000000..98fdc81b3 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/elements/GuiFuelTab.png differ diff --git a/src/main/resources/assets/mekanism/gui/elements/GuiHeatTab.png b/src/main/resources/assets/mekanism/gui/elements/GuiHeatTab.png new file mode 100644 index 000000000..ca54790d6 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/elements/GuiHeatTab.png differ diff --git a/src/main/resources/assets/mekanism/gui/elements/GuiProgress.png b/src/main/resources/assets/mekanism/gui/elements/GuiProgress.png index 72359f0f6..3cef60021 100644 Binary files a/src/main/resources/assets/mekanism/gui/elements/GuiProgress.png and b/src/main/resources/assets/mekanism/gui/elements/GuiProgress.png differ