From 63335a57c8b199bca1714831cd57b92f01ced18d Mon Sep 17 00:00:00 2001 From: aidancbrady Date: Fri, 26 Feb 2016 20:44:21 -0500 Subject: [PATCH] Resistive heater is just about done! --- .../client/gui/GuiResistiveHeater.java | 69 +++++++++++++++++- .../mekanism/common/block/BlockMachine.java | 5 +- .../container/ContainerResistiveHeater.java | 2 +- .../tile/TileEntityResistiveHeater.java | 14 +++- .../mekanism/gui/GuiResistiveHeater.png | Bin 3898 -> 3940 bytes .../resources/assets/mekanism/lang/en_US.lang | 1 + 6 files changed, 84 insertions(+), 7 deletions(-) diff --git a/src/main/java/mekanism/client/gui/GuiResistiveHeater.java b/src/main/java/mekanism/client/gui/GuiResistiveHeater.java index c07367c6f..95a9e3155 100644 --- a/src/main/java/mekanism/client/gui/GuiResistiveHeater.java +++ b/src/main/java/mekanism/client/gui/GuiResistiveHeater.java @@ -1,9 +1,17 @@ package mekanism.client.gui; +import java.util.ArrayList; + +import mekanism.api.Coord4D; +import mekanism.api.util.UnitDisplayUtils.TemperatureUnit; +import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotType; +import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; import mekanism.common.inventory.container.ContainerResistiveHeater; +import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityResistiveHeater; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; @@ -29,7 +37,8 @@ public class GuiResistiveHeater extends GuiMekanism super(tentity, new ContainerResistiveHeater(inventory, tentity)); tileEntity = tentity; - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 27, 34).with(SlotOverlay.POWER)); + guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), 164, 15)); + guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), 14, 34).with(SlotOverlay.POWER)); } @Override @@ -42,7 +51,7 @@ public class GuiResistiveHeater extends GuiMekanism String prevEnergyUsage = energyUsageField != null ? energyUsageField.getText() : ""; - energyUsageField = new GuiTextField(fontRendererObj, guiWidth + 50, guiHeight + 104, 86, 11); + energyUsageField = new GuiTextField(fontRendererObj, guiWidth + 49, guiHeight + 52, 66, 11); energyUsageField.setMaxStringLength(7); energyUsageField.setEnableBackgroundDrawing(false); energyUsageField.setText(prevEnergyUsage); @@ -53,6 +62,9 @@ public class GuiResistiveHeater extends GuiMekanism { fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040); fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); + + renderScaledText(LangUtils.localize("gui.temp") + ": " + MekanismUtils.getTemperatureDisplay(tileEntity.temperature, TemperatureUnit.AMBIENT), 50, 25, 0x00CD00, 76); + renderScaledText(LangUtils.localize("gui.usage") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.energyUsage), 50, 41, 0x00CD00, 76); super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -60,18 +72,69 @@ public class GuiResistiveHeater extends GuiMekanism @Override protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.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); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if(xAxis >= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61) + { + drawTexturedModalRect(guiWidth + 116, guiHeight + 51, xSize, 0, 11, 11); + } + else { + drawTexturedModalRect(guiWidth + 116, guiHeight + 51, xSize, 11, 11, 11); + } super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + energyUsageField.drawTextBox(); } private void setEnergyUsage() { + if(!energyUsageField.getText().isEmpty()) + { + int toUse = Integer.parseInt(energyUsageField.getText()); + + ArrayList data = new ArrayList(); + data.add(toUse); + + Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + + energyUsageField.setText(""); + } + } + + @Override + public void updateScreen() + { + super.updateScreen(); + energyUsageField.updateCursorCounter(); + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int button) + { + super.mouseClicked(mouseX, mouseY, button); + + energyUsageField.mouseClicked(mouseX, mouseY, button); + + if(button == 0) + { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if(xAxis >= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61) + { + setEnergyUsage(); + SoundHandler.playSound("gui.button.press"); + } + } } @Override diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 81b1108c6..d100cdcb0 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -225,6 +225,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo case MACHINE_BLOCK_3: icons[0][0] = register.registerIcon("mekanism:AmbientAccumulator"); icons[2][0] = BASE_ICON; + icons[4][0] = BASE_ICON; MekanismRenderer.loadDynamicTextures(register, MachineType.OREDICTIONIFICATOR.name, icons[3], DefIcon.getAll(register.registerIcon("mekanism:OredictionificatorSide"))); break; } @@ -1147,7 +1148,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", 47, TileEntitySolarNeutronActivator.class, false, true, false), AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, TileEntityAmbientAccumulator.class, true, false, false), OREDICTIONIFICATOR(MachineBlock.MACHINE_BLOCK_3, 3, "Oredictionificator", 52, TileEntityOredictionificator.class, false, false, false), - RESISTIVE_HEATER(MachineBlock.MACHINE_BLOCK_3, 4, "ResistiveHeater", 53, TileEntityResistiveHeater.class, true, true, false); + RESISTIVE_HEATER(MachineBlock.MACHINE_BLOCK_3, 4, "ResistiveHeater", 53, TileEntityResistiveHeater.class, true, false, false); public MachineBlock typeBlock; public int meta; @@ -1198,7 +1199,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo for(MachineType type : MachineType.values()) { - if(type != ENTANGLED_BLOCK && type != AMBIENT_ACCUMULATOR && type != RESISTIVE_HEATER) + if(type != ENTANGLED_BLOCK && type != AMBIENT_ACCUMULATOR) { ret.add(type); } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java b/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java index 46ae9328a..2f67947f6 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java @@ -16,7 +16,7 @@ public class ContainerResistiveHeater extends Container public ContainerResistiveHeater(InventoryPlayer inventory, TileEntityResistiveHeater tentity) { tileEntity = tentity; - addSlotToContainer(new SlotDischarge(tentity, 0, 28, 35)); + addSlotToContainer(new SlotDischarge(tentity, 0, 15, 35)); int slotY; diff --git a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java index 090be3b6e..fbb654fba 100644 --- a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java +++ b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java @@ -16,6 +16,7 @@ import mekanism.common.util.HeatUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock implements IHeatTransfer @@ -73,6 +74,7 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl double toUse = Math.min(getEnergy(), energyUsage); heatToAbsorb += toUse/general.energyPerHeat; setEnergy(getEnergy() - toUse); + setActive(toUse > 0); simulateHeat(); applyTemperatureChange(); @@ -87,6 +89,8 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl energyUsage = nbtTags.getDouble("energyUsage"); temperature = nbtTags.getDouble("temperature"); clientActive = isActive = nbtTags.getBoolean("isActive"); + + maxEnergy = energyUsage * 400; } @Override @@ -104,7 +108,8 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl { if(!worldObj.isRemote) { - energyUsage = dataStream.readDouble(); + energyUsage = dataStream.readInt(); + maxEnergy = energyUsage * 400; return; } @@ -185,6 +190,13 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl @Override public IHeatTransfer getAdjacent(ForgeDirection side) { + TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); + + if(adj instanceof IHeatTransfer) + { + return (IHeatTransfer)adj; + } + return null; } diff --git a/src/main/resources/assets/mekanism/gui/GuiResistiveHeater.png b/src/main/resources/assets/mekanism/gui/GuiResistiveHeater.png index cd1a0231ed84bdac7cf32b9ded6c067bec8348a0..67588cf77610516d8b9aefa148b742cede0f009f 100644 GIT binary patch delta 2492 zcmb`JX;4$=8plr#Nk~`&vM92IA{7b<3PP#|4$8hOA_%fvswl_~0)pY>*eVzh9JGj_ zCRYThqCo<}MJNH46j`(eT7dvzQHdsmeTzcR%$>Pk+BA2y;aW3TX)cQ~?!+UH2ukKX4zRTd1or?qUj<2hZnuxO>2Fl}XL*peKL4qWC$jR9^U}svo&-3WLqkI_ z=d3k0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cDJf-{@V7CwkgQZU;3&%ggY-&dhuz1?uA7t$9CoIt#C); zLF#gIU7f=R2gwL3QY=ipQ7EkVf~Z6|zBV&OAD?Th&Z(@)2e$eu6tcG+Qt{iDywu>} z;5ObW^Gl4wTesQFV5=vXLqUIdI(bd~?p1kbp?zFIQ&ZC|+rqgj4gRUKOH@;K!ZY>1 zTQj9&<}Q`t%~aJ6L}AV`Wz}d;Sn>r{b6=PTK%5zz)Z#A8T&%8Pxp zyLcD&A5wLPZ(qm$f;MrluQJhO?f!;JFzypxa z@K-ae9h8q=_5Vy`72IW5!Mn9^tn7%-DFHbw;7(bA$c=N81x(|jnb0mg?*B>4yJ-(5kBuqu@vSnCs!1cDzW=pWGh zDG7UE2F#t8`2n(S~m(akg1k@lv1(%lg_rOMFaNd z_V(?2#smTjmyRPty@8x19B1(mY5Gd5LEP|?oIcC^kXqK1`coKOv}XE76b-tDwcuy1 zTC;#3u$1m`O80Uyv6TLp1pSkrL1vZ!dRb}H@R{g0eUA-eOriU@{=jYn z_V7g7;z@$*0aI4*NsGwHldXk`&QwEXok>8${>Ta@Ky>~Z|0$NqbM0fO95%r& z;|;DQdlFkugX>EWcLZ=>d}wx=jsTxpb0+jJV&}V9Tnk^tCc~tL-5H38O@^0!c}M~l zXCo`kpKL+~Op=H7ys*h|)v!l`cgNc4?oWfBW95`VMpX7i7I1Nz;Y)t>E4Q??ss1-^ z)D)@+fiq6svt%>yCt_o>8-7pVf8UsoC8dCagM%$hW7)eZ8jaS*%tku9xRqLGbl43k zxQAGV|` y#{E4^xOn8-cY7YLsd3fO0&@sD>6>iMvej!G)QQ_n#i2U@?D6*SbHDEvasEH_4NE-$ diff --git a/src/main/resources/assets/mekanism/lang/en_US.lang b/src/main/resources/assets/mekanism/lang/en_US.lang index b891dec81..43be41f24 100644 --- a/src/main/resources/assets/mekanism/lang/en_US.lang +++ b/src/main/resources/assets/mekanism/lang/en_US.lang @@ -518,6 +518,7 @@ gui.steamInput=Steam Input gui.capacity=Capacity gui.unit=Unit gui.temp=Temp +gui.usage=Usage gui.reactor.injectionRate=Injection Rate