forked from wormzjl/ModularMachinery
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathGuiMEFluidInputBus.java
More file actions
97 lines (82 loc) · 4.03 KB
/
Copy pathGuiMEFluidInputBus.java
File metadata and controls
97 lines (82 loc) · 4.03 KB
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
package github.kasuminova.mmce.client.gui;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.core.localization.GuiText;
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
import appeng.fluids.client.gui.widgets.GuiFluidTank;
import appeng.fluids.util.IAEFluidTank;
import github.kasuminova.mmce.common.container.ContainerMEFluidInputBus;
import github.kasuminova.mmce.common.network.PktOpenMEBusGui;
import github.kasuminova.mmce.common.tile.MEFluidInputBus;
import github.kasuminova.mmce.common.tile.base.MEFluidBus;
import hellfirepvp.modularmachinery.ModularMachinery;
import hellfirepvp.modularmachinery.common.CommonProxy.GuiType;
import hellfirepvp.modularmachinery.common.base.Mods;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import java.util.List;
import java.io.IOException;
public class GuiMEFluidInputBus extends GuiUpgradeable {
private static final ResourceLocation TEXTURES_INPUT_BUS = new ResourceLocation(ModularMachinery.MODID, "textures/gui/mefluidinputbus.png");
private final MEFluidInputBus bus;
private GuiMEBusPollingButton pollingRateBtn;
public GuiMEFluidInputBus(final MEFluidInputBus te, final EntityPlayer player) {
super(new ContainerMEFluidInputBus(te, player));
this.bus = te;
this.ySize = 231;
}
@Override
@SuppressWarnings("deprecation")
public void initGui() {
super.initGui();
final IAEFluidTank configFluids = bus.getConfig();
final IAEFluidTank fluidTank = bus.getTanks();
for (int i = 0; i < MEFluidBus.TANK_SLOT_AMOUNT; i++) {
final GuiFluidTank guiTank = new GuiFluidTank(fluidTank, i, MEFluidBus.TANK_SLOT_AMOUNT + i,
8 + 18 * i, 53, 16, 68);
// AE2 Unofficial Extended Life Check
if (Mods.AE2EL.isPresent()) {
this.guiSlots.add(guiTank);
} else {
// Default AE2
int x = ObfuscationReflectionHelper.getPrivateValue(GuiCustomSlot.class, guiTank, "x");
int y = ObfuscationReflectionHelper.getPrivateValue(GuiCustomSlot.class, guiTank, "y");
ObfuscationReflectionHelper.setPrivateValue(GuiCustomSlot.class, guiTank, getGuiLeft() + x, "x");
ObfuscationReflectionHelper.setPrivateValue(GuiCustomSlot.class, guiTank, getGuiTop() + y, "y");
List<Object> buttonList = (List) this.buttonList;
buttonList.add(guiTank);
}
this.guiSlots.add(new GuiFluidSlot(configFluids, i, i, 8 + 18 * i, 35));
}
}
@Override
protected void addButtons() {
this.pollingRateBtn = new GuiMEBusPollingButton(
this.guiLeft - 18, this.guiTop + 8, this.bus::getPollingRate);
this.buttonList.add(this.pollingRateBtn);
}
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
if (btn == this.pollingRateBtn) {
ModularMachinery.NET_CHANNEL.sendToServer(
new PktOpenMEBusGui(this.bus.getPos(), GuiType.ME_BUS_POLLING)
);
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRenderer.drawString(I18n.format("gui.mefluidinputbus.title"), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752);
this.fontRenderer.drawString(GuiText.StoredFluids.getLocal(), 8, 6 + 112 + 7, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.mc.getTextureManager().bindTexture(TEXTURES_INPUT_BUS);
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}