-
Notifications
You must be signed in to change notification settings - Fork 497
/
ContainerEngine.java
73 lines (57 loc) · 2.51 KB
/
ContainerEngine.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
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
* <p/>
* 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.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import buildcraft.core.lib.engines.TileEngineWithInventory;
import buildcraft.core.lib.gui.BuildCraftContainer;
import buildcraft.core.lib.gui.widgets.FluidTankWidget;
import buildcraft.energy.TileEngineIron;
import buildcraft.energy.TileEngineStone;
public class ContainerEngine extends BuildCraftContainer {
protected TileEngineWithInventory engine;
public ContainerEngine(EntityPlayer player, TileEngineWithInventory tileEngine) {
super(player, tileEngine.getSizeInventory());
engine = tileEngine;
int yOffset = 0;
if (tileEngine instanceof TileEngineStone) {
addSlotToContainer(new Slot(tileEngine, 0, 80, 41));
} else {// Assume TileEngineIron
TileEngineIron combustionEngine = (TileEngineIron) tileEngine;
FluidTankWidget fuelWidget = new FluidTankWidget(combustionEngine.tankFuel, 26, 19, 16, 58).withOverlay(176, 0);
addWidget(fuelWidget);
addWidget(fuelWidget.copyMoved(combustionEngine.tankCoolant, 80, 19));
addWidget(fuelWidget.copyMoved(combustionEngine.tankResidue, 134, 19));
yOffset = 11;
}
for (int i = 0; i < 3; i++) {
for (int k = 0; k < 9; k++) {
addSlotToContainer(new Slot(player.inventory, k + i * 9 + 9, 8 + k * 18, 84 + i * 18 + yOffset));
}
}
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(player.inventory, j, 8 + j * 18, 142 + yOffset));
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (Object crafter : crafters) {
engine.sendGUINetworkData(this, (ICrafting) crafter);
}
}
@Override
public void updateProgressBar(int i, int j) {
engine.getGUINetworkData(i, j);
}
public boolean isUsableByPlayer(EntityPlayer entityplayer) {
return engine.isUseableByPlayer(entityplayer);
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return engine.isUseableByPlayer(entityplayer);
}
}