forked from wormzjl/ModularMachinery
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathGuiMEFluidOutputBus.java
More file actions
90 lines (76 loc) · 3.64 KB
/
Copy pathGuiMEFluidOutputBus.java
File metadata and controls
90 lines (76 loc) · 3.64 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
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.GuiFluidTank;
import appeng.fluids.util.IAEFluidTank;
import github.kasuminova.mmce.common.container.ContainerMEFluidOutputBus;
import github.kasuminova.mmce.common.network.PktOpenMEBusGui;
import github.kasuminova.mmce.common.tile.MEFluidOutputBus;
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 GuiMEFluidOutputBus extends GuiUpgradeable {
private static final ResourceLocation TEXTURES_OUTPUT_BUS = new ResourceLocation(ModularMachinery.MODID, "textures/gui/mefluidoutputbus.png");
private final MEFluidOutputBus bus;
private GuiMEBusPollingButton pollingRateBtn;
public GuiMEFluidOutputBus(final MEFluidOutputBus te, final EntityPlayer player) {
super(new ContainerMEFluidOutputBus(te, player));
this.bus = te;
this.ySize = 204;
}
@Override
@SuppressWarnings("deprecation")
public void initGui() {
super.initGui();
final IAEFluidTank fluidTank = this.bus.getTanks();
for (int i = 0; i < MEFluidOutputBus.TANK_SLOT_AMOUNT; i++) {
final GuiFluidTank guiTank = new GuiFluidTank(fluidTank, i, i,
8 + 18 * i, 26, 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);
}
}
}
@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(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRenderer.drawString(I18n.format("gui.mefluidoutputbus.title"), 8, 8, 0x404040);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 104, 0x404040);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.mc.getTextureManager().bindTexture(TEXTURES_OUTPUT_BUS);
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}