-
Notifications
You must be signed in to change notification settings - Fork 81
/
FurnaceGui.java
82 lines (68 loc) · 2.85 KB
/
FurnaceGui.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.progwml6.natura.common.gui.client;
import com.progwml6.natura.common.gui.common.FurnaceContainer;
import com.progwml6.natura.nether.block.furnace.tile.TileEntityNetherrackFurnace;
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 FurnaceGui extends GuiContainer
{
private static final ResourceLocation FURNACE_GUI_TEXTURES = new ResourceLocation("textures/gui/container/furnace.png");
/** The player inventory bound to this GUI. */
private final InventoryPlayer playerInventory;
private final IInventory tileFurnace;
public FurnaceGui(InventoryPlayer playerInv, IInventory furnaceInv)
{
super(new FurnaceContainer(playerInv, furnaceInv));
this.playerInventory = playerInv;
this.tileFurnace = furnaceInv;
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
String s = this.tileFurnace.getDisplayName().getUnformattedText();
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(FURNACE_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 (TileEntityNetherrackFurnace.isBurning(this.tileFurnace))
{
int k = this.getBurnLeftScaled(13);
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;
}
}