From c6cb70c9dae061079f759a43db643cf33154be81 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sat, 1 Feb 2014 20:32:26 -0500 Subject: [PATCH] Gas tanks can now dump gasses --- .../mekanism/client/gui/GuiDigitalMiner.java | 2 +- common/mekanism/client/gui/GuiGasTank.java | 31 +++++++++++++++++ .../common/tile/TileEntityGasTank.java | 32 ++++++++++++++++++ .../mekanism/gui/GuiElectrolyticSeparator.png | Bin 4280 -> 4259 bytes resources/assets/mekanism/gui/GuiGasTank.png | Bin 3600 -> 3809 bytes resources/assets/mekanism/lang/en_US.lang | 2 +- 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/common/mekanism/client/gui/GuiDigitalMiner.java b/common/mekanism/client/gui/GuiDigitalMiner.java index 908375589..762495f49 100644 --- a/common/mekanism/client/gui/GuiDigitalMiner.java +++ b/common/mekanism/client/gui/GuiDigitalMiner.java @@ -155,7 +155,7 @@ public class GuiDigitalMiner extends GuiMekanism fontRenderer.drawString(tileEntity.getInvName(), 69, 6, 0x404040); fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(tileEntity.running ? MekanismUtils.localize("gui.digitalMiner.running") : MekanismUtils.localize("gui.digitalMiner.idle"), 9, 10, 0x00CD00); + fontRenderer.drawString(tileEntity.running ? MekanismUtils.localize("gui.digitalMiner.running") : MekanismUtils.localize("gui.idle"), 9, 10, 0x00CD00); fontRenderer.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00); fontRenderer.drawString(MekanismUtils.localize("gui.eject") + ": " + MekanismUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), 9, 30, 0x00CD00); diff --git a/common/mekanism/client/gui/GuiGasTank.java b/common/mekanism/client/gui/GuiGasTank.java index 0b0d5dc58..d464cc8a0 100644 --- a/common/mekanism/client/gui/GuiGasTank.java +++ b/common/mekanism/client/gui/GuiGasTank.java @@ -1,6 +1,12 @@ package mekanism.client.gui; +import java.util.ArrayList; + +import mekanism.api.Coord4D; +import mekanism.common.PacketHandler; +import mekanism.common.PacketHandler.Transmission; import mekanism.common.inventory.container.ContainerGasTank; +import mekanism.common.network.PacketTileEntity; import mekanism.common.tile.TileEntityGasTank; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -37,6 +43,9 @@ public class GuiGasTank extends GuiMekanism fontRenderer.drawString("Gas: " + (tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() : "None"), 45, 49, 0x404040); fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); + String name = tileEntity.dumping ? "Dumping..." : MekanismUtils.localize("gui.idle"); + fontRenderer.drawString(name, 156-fontRenderer.getStringWidth(name), 73, 0x404040); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @@ -50,6 +59,9 @@ public class GuiGasTank extends GuiMekanism int guiWidth = (width - xSize) / 2; int guiHeight = (height - ySize) / 2; drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int displayInt = tileEntity.dumping ? 18 : 10; + drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); if(tileEntity.gasTank.getGas() != null) { @@ -57,4 +69,23 @@ public class GuiGasTank extends GuiMekanism drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 20); } } + + @Override + protected void mouseClicked(int x, int y, int button) + { + super.mouseClicked(x, y, button); + + int xAxis = (x - (width - xSize) / 2); + int yAxis = (y - (height - ySize) / 2); + + if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) + { + ArrayList data = new ArrayList(); + data.add(0); + + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + + } + } } diff --git a/common/mekanism/common/tile/TileEntityGasTank.java b/common/mekanism/common/tile/TileEntityGasTank.java index 876aa3194..ffa950ad2 100644 --- a/common/mekanism/common/tile/TileEntityGasTank.java +++ b/common/mekanism/common/tile/TileEntityGasTank.java @@ -12,7 +12,11 @@ import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; import mekanism.common.IRedstoneControl; +import mekanism.common.PacketHandler; +import mekanism.common.PacketHandler.Transmission; +import mekanism.common.network.PacketTileEntity; import mekanism.common.util.MekanismUtils; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -30,6 +34,8 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH /** How fast this tank can output gas. */ public int output = 16; + public boolean dumping; + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType; @@ -68,6 +74,11 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH } } } + + if(!worldObj.isRemote && dumping) + { + gasTank.draw(8, true); + } } @Override @@ -139,6 +150,23 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH @Override public void handlePacketData(ByteArrayDataInput dataStream) { + if(!worldObj.isRemote) + { + int type = dataStream.readInt(); + + if(type == 0) + { + dumping = !dumping; + } + + for(EntityPlayer player : playersUsing) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), player); + } + + return; + } + super.handlePacketData(dataStream); if(dataStream.readBoolean()) @@ -149,6 +177,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH gasTank.setGas(null); } + dumping = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); @@ -160,6 +189,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH super.readFromNBT(nbtTags); gasTank.read(nbtTags.getCompoundTag("gasTank")); + dumping = nbtTags.getBoolean("dumping"); controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; } @@ -169,6 +199,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH super.writeToNBT(nbtTags); nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); + nbtTags.setBoolean("dumping", dumping); nbtTags.setInteger("controlType", controlType.ordinal()); } @@ -187,6 +218,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH data.add(false); } + data.add(dumping); data.add(controlType.ordinal()); return data; diff --git a/resources/assets/mekanism/gui/GuiElectrolyticSeparator.png b/resources/assets/mekanism/gui/GuiElectrolyticSeparator.png index 3e8fd23f73a6f723daf66da2142c02c3ecca4f3b..13b91156daab4314c34b24e3940a8c2be0c4218d 100644 GIT binary patch delta 12 Tcmdm?xL9#RFw5o)mH-|AA5sJ$ delta 32 lcmZ3ixI=M6FpDq)XMsm#F#`j)FbFd;%$g&yIgllY2LOUI2Q~lz diff --git a/resources/assets/mekanism/gui/GuiGasTank.png b/resources/assets/mekanism/gui/GuiGasTank.png index 30c3aad8cd605837b9f219591a38639bef960fd9..5308566c1dd77d93181ca0aa44d845364e2563a8 100644 GIT binary patch delta 2345 zcmcIkdpMNa9$w#PMl+>tPz@(B$nCgIZMUTHl}plQR1S(^Dm%0rCYN%F`Mwk)MJju{ zG*ibm?(CFuDRXk7l8vwtGIm=u$TeeJ&v%~Z{B@rF=Q-=2-?P^9u4lc!_kDjWU43{* zBF?Z zk3lE!JW2pOs#d@}y%O66d=q&R%CO=JCbn;x&a#7;j?n;wK!y&QWU zxBTfsov3$leQvZZlWOK?TxNM;D0fvVz3Rp5>E|r7oY-7AFfeeWskZ)P*7n-TP;6?b zVLfiRNq60se{pmOIe(!S&dSRA9@Y3I#-Q_eHPOS8o0@i}%)R^B$#7NQxv=N)5AY-xbbglfJ#({*<1IzZ zF3x;>_WrB`DmqClhTOkleGz3$w&qx=RG2sr9_w+$z*OTP@(Sw$~S50}k7i_hWC;@go8i6PI9exzl zr{GJA(~{VZ`lRJlxNWg;x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