-
Notifications
You must be signed in to change notification settings - Fork 497
/
GuiCombustionEngine.java
97 lines (79 loc) · 2.94 KB
/
GuiCombustionEngine.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy.gui;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import buildcraft.core.DefaultProps;
import buildcraft.core.utils.StringUtils;
import buildcraft.energy.TileEngineIron;
import buildcraft.energy.TileEngineWithInventory;
public class GuiCombustionEngine extends GuiEngine {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/combustion_engine_gui.png");
private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b;
public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngineWithInventory tileEngine) {
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
String title = StringUtils.localize("tile.engineIron");
fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040);
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.func_110577_a(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
TileEngineIron engine = (TileEngineIron) tile;
if (engine.getScaledBurnTime(58) > 0) {
displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engine.getFuel());
}
if (engine.getScaledCoolant(58) > 0) {
displayGauge(j, k, 19, 122, engine.getScaledCoolant(58), engine.getCoolant());
}
}
private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid) {
if (liquid == null) {
return;
}
int start = 0;
Icon liquidIcon = null;
Fluid fluid = liquid.getFluid();
if (fluid != null && fluid.getStillIcon() != null) {
liquidIcon = fluid.getStillIcon();
}
mc.renderEngine.func_110577_a(BLOCK_TEXTURE);
if (liquidIcon != null) {
while (true) {
int x;
if (squaled > 16) {
x = 16;
squaled -= 16;
} else {
x = squaled;
squaled = 0;
}
drawTexturedModelRectFromIcon(j + col, k + line + 58 - x - start, liquidIcon, 16, 16 - (16 - x));
start = start + 16;
if (x == 0 || squaled == 0) {
break;
}
}
}
mc.renderEngine.func_110577_a(TEXTURE);
drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
}
}