From 65dd53c6ec721f457d13878ddb188beb26e07ced Mon Sep 17 00:00:00 2001 From: Tntrololol Date: Tue, 12 May 2015 13:26:23 -0500 Subject: [PATCH] Added machine GUI progress bars --- .../client/gui/GuiAssemblingMachine.java | 36 +++++----- .../client/gui/GuiImplosionCompressor.java | 32 +++++---- .../java/techreborn/client/gui/GuiLathe.java | 32 +++++---- .../client/gui/GuiPlateCuttingMachine.java | 32 +++++---- .../techreborn/tiles/TileMachineBase.java | 65 ++++++++---------- .../tiles/TilePlateCuttingMachine.java | 29 ++++---- .../textures/gui/implosion_compressor.png | Bin 1810 -> 1805 bytes 7 files changed, 115 insertions(+), 111 deletions(-) diff --git a/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java b/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java index 634b37258..453ca2667 100644 --- a/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java +++ b/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java @@ -15,23 +15,19 @@ import techreborn.tiles.TileBlastFurnace; public class GuiAssemblingMachine extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation( - "techreborn", "textures/gui/assembling_machine.png"); + private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/assembling_machine.png"); - TileAssemblingMachine assemblinmachine; + TileAssemblingMachine assemblingmachine; - public GuiAssemblingMachine(EntityPlayer player, - TileAssemblingMachine tileassemblinmachine) - { + public GuiAssemblingMachine(EntityPlayer player, TileAssemblingMachine tileassemblinmachine) { super(new ContainerAssemblingMachine(tileassemblinmachine, player)); this.xSize = 176; this.ySize = 167; - assemblinmachine = tileassemblinmachine; + assemblingmachine = tileassemblinmachine; } @Override public void initGui() { - this.buttonList.clear(); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; @@ -40,22 +36,28 @@ public class GuiAssemblingMachine extends GuiContainer { } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, - int p_146976_2_, int p_146976_3_) - { + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + + int j = 0; + + if(assemblingmachine.crafter.currentRecipe != null) { + j = this.assemblingmachine.crafter.currentTickTime * 20 / this.assemblingmachine.crafter.currentRecipe.tickTime(); + } + this.drawTexturedModalRect(k + 86, l + 34, 176, 14, j + 1, 16); + + j = (int)this.assemblingmachine.energy.getEnergyStored() * 12 / this.assemblingmachine.energy.getCapacity(); + if(j > 0) { + this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); + } } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, - int p_146979_2_) - { + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { String name = StatCollector.translateToLocal("tile.techreborn.assemblinmachine.name"); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); - this.fontRendererObj.drawString( - I18n.format("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); } } diff --git a/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java b/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java index 3986f5b23..c09ef7894 100644 --- a/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java +++ b/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java @@ -13,23 +13,19 @@ import net.minecraft.util.StatCollector; public class GuiImplosionCompressor extends GuiContainer{ - private static final ResourceLocation texture = new ResourceLocation( - "techreborn", "textures/gui/implosion_compressor.png"); + private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/implosion_compressor.png"); TileImplosionCompressor compresser; - public GuiImplosionCompressor(EntityPlayer player, TileImplosionCompressor tilecompresser) - { + public GuiImplosionCompressor(EntityPlayer player, TileImplosionCompressor tilecompresser) { super(new ContainerImplosionCompressor(tilecompresser, player)); this.xSize = 176; this.ySize = 167; compresser = tilecompresser; - } @Override public void initGui() { - this.buttonList.clear(); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; @@ -38,23 +34,29 @@ public class GuiImplosionCompressor extends GuiContainer{ } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, - int p_146976_2_, int p_146976_3_) - { + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + + int j = 0; + + if(compresser.crafter.currentRecipe != null) { + j = this.compresser.crafter.currentTickTime * 20 / this.compresser.crafter.currentRecipe.tickTime(); + } + this.drawTexturedModalRect(k + 60, l + 38, 176, 14, j + 1, 16); + + j = (int)this.compresser.energy.getEnergyStored() * 12 / this.compresser.energy.getCapacity(); + if(j > 0) { + this.drawTexturedModalRect(k + 16, l + 37 + 12 - j, 176, 12 - j, 14, j + 2); + } } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, - int p_146979_2_) - { + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { String name = StatCollector.translateToLocal("tile.techreborn.implosioncompressor.name"); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); - this.fontRendererObj.drawString( - I18n.format("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); } } diff --git a/src/main/java/techreborn/client/gui/GuiLathe.java b/src/main/java/techreborn/client/gui/GuiLathe.java index 014822e68..cdd124962 100644 --- a/src/main/java/techreborn/client/gui/GuiLathe.java +++ b/src/main/java/techreborn/client/gui/GuiLathe.java @@ -15,14 +15,11 @@ import techreborn.tiles.TileLathe; public class GuiLathe extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation( - "techreborn", "textures/gui/lathe.png"); + private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/lathe.png"); TileLathe lathe; - public GuiLathe(EntityPlayer player, - TileLathe tilelathe) - { + public GuiLathe(EntityPlayer player, TileLathe tilelathe) { super(new ContainerLathe(tilelathe, player)); this.xSize = 176; this.ySize = 167; @@ -31,7 +28,6 @@ public class GuiLathe extends GuiContainer { @Override public void initGui() { - this.buttonList.clear(); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; @@ -40,22 +36,28 @@ public class GuiLathe extends GuiContainer { } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, - int p_146976_2_, int p_146976_3_) - { + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + + int j = 0; + + if(lathe.crafter.currentRecipe != null) { + j = this.lathe.crafter.currentTickTime * 20 / this.lathe.crafter.currentRecipe.tickTime(); + } + this.drawTexturedModalRect(k + 80, l + 34, 176, 14, j, 16); + + j = (int)this.lathe.energy.getEnergyStored() * 12 / this.lathe.energy.getCapacity(); + if(j > 0) { + this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); + } } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, - int p_146979_2_) - { + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { String name = StatCollector.translateToLocal("tile.techreborn.lathe.name"); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); - this.fontRendererObj.drawString( - I18n.format("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); } } diff --git a/src/main/java/techreborn/client/gui/GuiPlateCuttingMachine.java b/src/main/java/techreborn/client/gui/GuiPlateCuttingMachine.java index abbe6d00b..6b1155810 100644 --- a/src/main/java/techreborn/client/gui/GuiPlateCuttingMachine.java +++ b/src/main/java/techreborn/client/gui/GuiPlateCuttingMachine.java @@ -17,14 +17,11 @@ import techreborn.tiles.TilePlateCuttingMachine; public class GuiPlateCuttingMachine extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation( - "techreborn", "textures/gui/plate_cutting_machine.png"); + private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/plate_cutting_machine.png"); TilePlateCuttingMachine platecuttingmachine; - public GuiPlateCuttingMachine(EntityPlayer player, - TilePlateCuttingMachine tileplatecuttingmachine) - { + public GuiPlateCuttingMachine(EntityPlayer player, TilePlateCuttingMachine tileplatecuttingmachine) { super(new ContainerPlateCuttingMachine(tileplatecuttingmachine, player)); this.xSize = 176; this.ySize = 167; @@ -33,7 +30,6 @@ public class GuiPlateCuttingMachine extends GuiContainer { @Override public void initGui() { - this.buttonList.clear(); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; @@ -42,22 +38,28 @@ public class GuiPlateCuttingMachine extends GuiContainer { } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, - int p_146976_2_, int p_146976_3_) - { + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + + int j = 0; + + if(platecuttingmachine.crafter.currentRecipe != null) { + j = this.platecuttingmachine.crafter.currentTickTime * 20 / this.platecuttingmachine.crafter.currentRecipe.tickTime(); + } + this.drawTexturedModalRect(k + 83, l + 34, 176, 14, j, 16); + + j = (int)this.platecuttingmachine.energy.getEnergyStored() * 12 / this.platecuttingmachine.energy.getCapacity(); + if(j > 0) { + this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); + } } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, - int p_146979_2_) - { + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { String name = StatCollector.translateToLocal("tile.techreborn.platecuttingmachine.name"); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); - this.fontRendererObj.drawString( - I18n.format("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); } } diff --git a/src/main/java/techreborn/tiles/TileMachineBase.java b/src/main/java/techreborn/tiles/TileMachineBase.java index 04f9643af..f5a1bed19 100644 --- a/src/main/java/techreborn/tiles/TileMachineBase.java +++ b/src/main/java/techreborn/tiles/TileMachineBase.java @@ -12,48 +12,41 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class TileMachineBase extends TileEntity { - private int facing; + private int facing; - @Override - public void updateEntity() - { - super.updateEntity(); - // TODO make this happen less - // syncWithAll(); - } + @Override + public void updateEntity() { + super.updateEntity(); + // TODO make this happen less + // syncWithAll(); + } - @SideOnly(Side.CLIENT) - public void addWailaInfo(List info) - { + @SideOnly(Side.CLIENT) + public void addWailaInfo(List info) { - } + } - public void syncWithAll() - { - if (!worldObj.isRemote) - { - PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(), - worldObj); - } - } + public void syncWithAll() { + if (!worldObj.isRemote) { + PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(), + worldObj); + } + } - public Packet getDescriptionPacket() - { - NBTTagCompound nbtTag = new NBTTagCompound(); - writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, - this.zCoord, 1, nbtTag); - } - - @Override - public void onDataPacket(NetworkManager net, - S35PacketUpdateTileEntity packet) - { - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, - yCoord, zCoord); - readFromNBT(packet.func_148857_g()); - } + public Packet getDescriptionPacket() { + NBTTagCompound nbtTag = new NBTTagCompound(); + writeToNBT(nbtTag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, + this.zCoord, 1, nbtTag); + } + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) { + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, + yCoord, zCoord); + readFromNBT(packet.func_148857_g()); + } } diff --git a/src/main/java/techreborn/tiles/TilePlateCuttingMachine.java b/src/main/java/techreborn/tiles/TilePlateCuttingMachine.java index 7d9ff18b7..894ebfbca 100644 --- a/src/main/java/techreborn/tiles/TilePlateCuttingMachine.java +++ b/src/main/java/techreborn/tiles/TilePlateCuttingMachine.java @@ -81,21 +81,24 @@ public class TilePlateCuttingMachine extends TileMachineBase implements IWrencha { return false; } - - public void readFromNBT(NBTTagCompound tagCompound) - { - super.readFromNBT(tagCompound); - inventory.readFromNBT(tagCompound); - } + @Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + inventory.readFromNBT(tagCompound); + energy.readFromNBT(tagCompound); + crafter.readFromNBT(tagCompound); + } - @Override - public void writeToNBT(NBTTagCompound tagCompound) - { - super.writeToNBT(tagCompound); - inventory.writeToNBT(tagCompound); - - } + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + inventory.writeToNBT(tagCompound); + energy.writeToNBT(tagCompound); + crafter.writeToNBT(tagCompound); + } } diff --git a/src/main/resources/assets/techreborn/textures/gui/implosion_compressor.png b/src/main/resources/assets/techreborn/textures/gui/implosion_compressor.png index 73effc2766930fcef1407c3aad22d50adcd11dc1..4303a5c27fffa0dc1efb70db67abf5dc609278fa 100644 GIT binary patch delta 1420 zcmV;71#|k64vh|wQ-2E=DjUo?ycz%i2AWAkK~#9!?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