GuiFurnace .java

net.minecraft.client.gui.inventory.GuiFurnace (class, 75 lines): members: furnaceGuiTextures, tileFurnace, playerInventory. imports: ContainerFurnace.

net.minecraft.client.gui.inventoryclass75 linesclientextends GuiContainer2.6 KB

API Surface (2)

void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)

Fields & Constants (3)

furnaceGuiTextures
playerInventory
tileFurnace

String literals (1)

"textures/gui/container/furnace.png"

Full Source

GuiFurnace.java75 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui.inventory;
2
3
import net.minecraft.client.renderer.GlStateManager;
4
import net.minecraft.entity.player.InventoryPlayer;
5
import net.minecraft.inventory.ContainerFurnace;
6
import net.minecraft.inventory.IInventory;
7
import net.minecraft.tileentity.TileEntityFurnace;
8
import net.minecraft.util.ResourceLocation;
9
10
public class GuiFurnace extends GuiContainer
11
{
12
    private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/furnace.png");
13
14
    /** The player inventory bound to this GUI. */
15
    private final InventoryPlayer playerInventory;
16
    private IInventory tileFurnace;
17
18
    public GuiFurnace(InventoryPlayer playerInv, IInventory furnaceInv)
19
    {
20
        super(new ContainerFurnace(playerInv, furnaceInv));
21
        this.playerInventory = playerInv;
22
        this.tileFurnace = furnaceInv;
23
    }
24
25
    /**
26
     * Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
27
     */
28
    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
29
    {
30
        String s = this.tileFurnace.getDisplayName().getUnformattedText();
31
        this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
32
        this.fontRendererObj.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
33
    }
34
35
    /**
36
     * Args : renderPartialTicks, mouseX, mouseY
37
     */
38
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
39
    {
40
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
41
        this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
42
        int i = (this.width - this.xSize) / 2;
43
        int j = (this.height - this.ySize) / 2;
44
        this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
45
46
        if (TileEntityFurnace.isBurning(this.tileFurnace))
47
        {
48
            int k = this.getBurnLeftScaled(13);
49
            this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
50
        }
51
52
        int l = this.getCookProgressScaled(24);
53
        this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
54
    }
55
56
    private int getCookProgressScaled(int pixels)
57
    {
58
        int i = this.tileFurnace.getField(2);
59
        int j = this.tileFurnace.getField(3);
60
        return j != 0 && i != 0 ? i * pixels / j : 0;
61
    }
62
63
    private int getBurnLeftScaled(int pixels)
64
    {
65
        int i = this.tileFurnace.getField(1);
66
67
        if (i == 0)
68
        {
69
            i = 200;
70
        }
71
72
        return this.tileFurnace.getField(0) * pixels / i;
73
    }
74
}
75

Deobfuscated MCP 1.8.9 source of GuiFurnace from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/gui/inventory/GuiFurnace.java), stored verbatim.