package mekanism.client.gui; import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.ListUtils; import mekanism.api.gas.GasStack; import mekanism.client.render.MekanismRenderer; import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; import mekanism.common.inventory.container.ContainerRotaryCondensentrator; import mekanism.common.network.PacketTileEntity; import mekanism.common.tileentity.TileEntityRotaryCondensentrator; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiRotaryCondensentrator extends GuiMekanism { public TileEntityRotaryCondensentrator tileEntity; public GuiRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity) { super(new ContainerRotaryCondensentrator(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"))); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); fontRenderer.drawString(tileEntity.getInvName(), 26, 4, 0x404040); fontRenderer.drawString(tileEntity.mode == 0 ? MekanismUtils.localize("gui.condensentrating") : MekanismUtils.localize("gui.decondensentrating"), 6, (ySize - 94) + 2, 0x404040); if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluid().amount + "mB" : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.rotaryCondensentrator.toggleOperation"), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); } @Override protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.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 displayInt; int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); displayInt = tileEntity.getScaledEnergyLevel(52); drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 36, displayInt, 4); if(tileEntity.getScaledGasLevel(58) > 0) { displayGauge(26, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank.getGas()); } if(tileEntity.getScaledFluidLevel(58) > 0) { displayGauge(134, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null); } if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 0, 18, 18); } else { drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 18, 18, 18); } if(tileEntity.mode == 0) { drawTexturedModalRect(guiWidth + 64, guiHeight + 39, 176, tileEntity.isActive ? 123 : 107, 48, 8); } else if(tileEntity.mode == 1) { drawTexturedModalRect(guiWidth + 64, guiHeight + 39, 176, tileEntity.isActive ? 115 : 99, 48, 8); } } @Override protected void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { 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); } } } public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas) { if(fluid == null && gas == null) { return; } int guiWidth = (width - xSize) / 2; int guiHeight = (height - ySize) / 2; int start = 0; while(true) { int renderRemaining = 0; if(scale > 16) { renderRemaining = 16; scale -= 16; } else { renderRemaining = scale; scale = 0; } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); if(fluid != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); } else if(gas != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } start+=16; if(renderRemaining == 0 || scale == 0) { break; } } mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png")); drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 40, 16, 59); } }