2013-08-27 00:49:32 +02:00
|
|
|
package mekanism.client.gui;
|
2013-04-03 21:37:26 +02:00
|
|
|
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.client.render.MekanismRenderer;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.inventory.container.ContainerElectricPump;
|
2014-01-08 02:55:50 +01:00
|
|
|
import mekanism.common.tile.TileEntityElectricPump;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2013-04-03 21:37:26 +02:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-01-11 03:50:02 +01:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2013-07-20 18:10:14 +02:00
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
2013-04-03 21:37:26 +02:00
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2013-06-29 01:43:45 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-04-03 21:37:26 +02:00
|
|
|
|
2013-04-13 16:33:37 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-11-27 02:11:26 +01:00
|
|
|
public class GuiElectricPump extends GuiMekanism
|
2013-04-03 21:37:26 +02:00
|
|
|
{
|
|
|
|
public TileEntityElectricPump tileEntity;
|
2014-01-11 03:50:02 +01:00
|
|
|
|
|
|
|
public ResourceLocation guiLocation = MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png");
|
2013-04-03 21:37:26 +02:00
|
|
|
|
|
|
|
public GuiElectricPump(InventoryPlayer inventory, TileEntityElectricPump tentity)
|
|
|
|
{
|
|
|
|
super(new ContainerElectricPump(inventory, tentity));
|
|
|
|
tileEntity = tentity;
|
2014-01-11 03:50:02 +01:00
|
|
|
|
|
|
|
guiElements.add(new GuiPowerBar(this, tileEntity, guiLocation, 164, 15));
|
2013-04-03 21:37:26 +02:00
|
|
|
}
|
2013-04-05 22:26:48 +02:00
|
|
|
|
2013-04-03 21:37:26 +02:00
|
|
|
@Override
|
2013-04-05 22:26:48 +02:00
|
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
2013-04-03 21:37:26 +02:00
|
|
|
{
|
2013-04-05 22:26:48 +02:00
|
|
|
int xAxis = (mouseX - (width - xSize) / 2);
|
|
|
|
int yAxis = (mouseY - (height - ySize) / 2);
|
|
|
|
|
2013-11-30 06:28:02 +01:00
|
|
|
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
|
|
|
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
|
2013-11-23 02:58:49 +01:00
|
|
|
fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
|
2013-11-30 06:28:02 +01:00
|
|
|
fontRenderer.drawString(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getName() + ": " + tileEntity.fluidTank.getFluid().amount : MekanismUtils.localize("gui.noFluid"), 51, 35, 0x00CD00);
|
2013-04-05 22:26:48 +02:00
|
|
|
|
|
|
|
if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72)
|
|
|
|
{
|
2013-11-30 06:28:02 +01:00
|
|
|
drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluid().amount + "mB" : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
|
2013-04-05 22:26:48 +02:00
|
|
|
}
|
2013-06-02 23:44:59 +02:00
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
2013-04-03 21:37:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-11-27 02:11:26 +01:00
|
|
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
2013-04-03 21:37:26 +02:00
|
|
|
{
|
2014-01-11 03:50:02 +01:00
|
|
|
mc.renderEngine.bindTexture(guiLocation);
|
2013-04-03 21:37:26 +02:00
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
2013-12-12 02:24:37 +01:00
|
|
|
int guiWidth = (width - xSize) / 2;
|
|
|
|
int guiHeight = (height - ySize) / 2;
|
2013-04-03 21:37:26 +02:00
|
|
|
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
2014-01-11 03:50:02 +01:00
|
|
|
|
2013-07-20 18:10:14 +02:00
|
|
|
if(tileEntity.getScaledFluidLevel(58) > 0)
|
2013-04-03 21:37:26 +02:00
|
|
|
{
|
2013-11-28 05:42:54 +01:00
|
|
|
displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid());
|
2013-04-03 21:37:26 +02:00
|
|
|
}
|
2014-01-11 03:50:02 +01:00
|
|
|
|
|
|
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
2013-04-03 21:37:26 +02:00
|
|
|
}
|
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid)
|
2013-04-03 21:37:26 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
if(fluid == null)
|
2013-04-03 21:37:26 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-12 02:24:37 +01:00
|
|
|
int guiWidth = (width - xSize) / 2;
|
|
|
|
int guiHeight = (height - ySize) / 2;
|
|
|
|
|
2013-04-03 21:37:26 +02:00
|
|
|
int start = 0;
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
int renderRemaining = 0;
|
|
|
|
|
|
|
|
if(scale > 16)
|
|
|
|
{
|
|
|
|
renderRemaining = 16;
|
|
|
|
scale -= 16;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
renderRemaining = scale;
|
|
|
|
scale = 0;
|
|
|
|
}
|
|
|
|
|
2013-11-24 19:12:42 +01:00
|
|
|
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
2013-11-28 05:42:54 +01:00
|
|
|
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
|
2013-04-05 22:26:48 +02:00
|
|
|
start+=16;
|
2013-04-03 21:37:26 +02:00
|
|
|
|
2013-04-03 21:40:10 +02:00
|
|
|
if(renderRemaining == 0 || scale == 0)
|
2013-04-03 21:37:26 +02:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-11 03:50:02 +01:00
|
|
|
mc.renderEngine.bindTexture(guiLocation);
|
2013-11-28 05:42:54 +01:00
|
|
|
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 52, 16, 60);
|
2013-04-03 21:37:26 +02:00
|
|
|
}
|
|
|
|
}
|