90 lines
3.0 KiB
Java
90 lines
3.0 KiB
Java
package com.droog71.prospect.gui;
|
|
|
|
import com.droog71.prospect.inventory.BioGenContainer;
|
|
import com.droog71.prospect.tile_entity.BioGenTileEntity;
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
import net.minecraft.inventory.IInventory;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public class BioGenGUI extends GuiContainer
|
|
{
|
|
private static final ResourceLocation BIO_GEN_GUI_TEXTURES = new ResourceLocation("prospect:textures/gui/bio_gen.png");
|
|
/** The player inventory bound to this GUI. */
|
|
private final InventoryPlayer playerInventory;
|
|
private final IInventory tileBioGen;
|
|
|
|
public BioGenGUI(InventoryPlayer playerInv, IInventory bioGenInv)
|
|
{
|
|
super(new BioGenContainer(playerInv, bioGenInv));
|
|
this.playerInventory = playerInv;
|
|
this.tileBioGen = bioGenInv;
|
|
}
|
|
|
|
/**
|
|
* Draws the screen and all the components in it.
|
|
*/
|
|
@Override
|
|
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
|
{
|
|
this.drawDefaultBackground();
|
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
this.renderHoveredToolTip(mouseX, mouseY);
|
|
}
|
|
|
|
/**
|
|
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
|
*/
|
|
@Override
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
|
{
|
|
String s = this.tileBioGen.getName();
|
|
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
|
|
this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
|
|
}
|
|
|
|
/**
|
|
* Draws the background layer of this container (behind the items).
|
|
*/
|
|
@Override
|
|
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
|
{
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
this.mc.getTextureManager().bindTexture(BIO_GEN_GUI_TEXTURES);
|
|
int i = (this.width - this.xSize) / 2;
|
|
int j = (this.height - this.ySize) / 2;
|
|
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
|
|
|
if (BioGenTileEntity.isEnergized(this.tileBioGen))
|
|
{
|
|
int k = this.getPowerScaled(13);
|
|
this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
|
|
}
|
|
|
|
int h = this.getBurnProgressScaled(16);
|
|
this.drawTexturedModalRect(i + 79, j + 34, 176, 14, 24, h + 1);
|
|
}
|
|
|
|
private int getBurnProgressScaled(int pixels)
|
|
{
|
|
int i = this.tileBioGen.getField(2);
|
|
int j = this.tileBioGen.getField(3);
|
|
return j != 0 && i != 0 ? i * pixels / j : 16;
|
|
}
|
|
|
|
private int getPowerScaled(int pixels)
|
|
{
|
|
int i = this.tileBioGen.getField(1);
|
|
|
|
if (i == 0)
|
|
{
|
|
i = 200;
|
|
}
|
|
|
|
return this.tileBioGen.getField(0) * pixels / i;
|
|
}
|
|
} |