Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cz.grossik.farmcraft2.crushing;
- 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 GuiCrushing extends GuiContainer
- {
- private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("farmcraft2:textures/gui/container/crushing.png");
- /** The player inventory bound to this GUI. */
- private final InventoryPlayer playerInventory;
- private IInventory tileFurnace;
- public GuiCrushing(InventoryPlayer playerInv, TileEntityCrushing furnaceInv)
- {
- super(new ContainerCrushing(playerInv, furnaceInv));
- this.playerInventory = playerInv;
- this.tileFurnace = furnaceInv;
- }
- /**
- * Draw the foreground layer for the GuiContainer (everything in front of the items)
- *
- * @param mouseX Mouse x coordinate
- * @param mouseY Mouse y coordinate
- */
- protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
- {
- String s = this.tileFurnace.getDisplayName().getUnformattedText();
- this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
- this.fontRendererObj.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
- }
- /**
- * Draws the background layer of this container (behind the items).
- *
- * @param partialTicks How far into the current tick the game is, with 0.0 being the start of the tick and 1.0 being
- * the end.
- * @param mouseX Mouse x coordinate
- * @param mouseY Mouse y coordinate
- */
- protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
- {
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
- 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 (TileEntityCrushing.isBurning(this.tileFurnace))
- {
- int k = this.getCookProgressScaled(24);
- this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
- }
- int l = this.getCookProgressScaled(24);
- this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
- }
- private int getCookProgressScaled(int pixels)
- {
- int i = this.tileFurnace.getField(2);
- int j = this.tileFurnace.getField(3);
- return j != 0 && i != 0 ? i * pixels / j : 0;
- }
- private int getBurnLeftScaled(int pixels)
- {
- int i = this.tileFurnace.getField(1);
- if (i == 0)
- {
- i = 200;
- }
- return this.tileFurnace.getField(0) * pixels / i;
- }
- }
Add Comment
Please, Sign In to add comment