mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 17:44:46 +00:00
Add LevelMaintainerTerminal rework logic inside TileLevelMaintainer (#162)
* Use new interface terminal API * Update dependencies.gradle * feat: Update core hooks and integrations * api: Add `LevelTerminalRegistry` functionality * feat: Use `customName` to display in `GuiFluidLevelEmitter` * feat: Rework scheduling and data storage in `TileLevelMaintainer` functionality * feat: Add new item `LevelTerminal` * feat: Support back navigation functionality * feat: add back navigation in `LevelMaintainer` from terminal * use `IGuiTooltipHandler` directly from ae2 include #160 * fix correct `InterfaceTerminalSupportedClassProvider` deprecation * Implement new version of `InterfaceWireless` based on `InterfaceTerminal` * Fix `LevelTerminal` data recursion and few in fixes gui * Use `aeRenderItem` directly and fix `zIndex` in custom slots * Fix rendering numbers bigger than 2.1G through `aeRenderItem` * Fix fails on `getCraftingItem` no root cause was found * Fix add packet logging and try to not fail after receive corrupted packet * Fix add logging around empty configuration * Fix packet corruption and log invalid data * Fix packet corruption with level emitters * Correct handle overwrite packet * Fix intercept dnd click from GT5 hook for `AppEngGuiHandler` keyword `net.bdew.neiaddons.appeng.AppEngGuiHandler` * update be+deps * Update dependencies.gradle * Update dependencies.gradle * Fix `zIndexes` for compatability with `DuraDisplay` * Update AE2 and fix compatability * Change `ForgeDirection` side serialization to `byte` * Fix tooltip zIndexes * Rename all rest parts related to `Level terminal` * Code cleanup after review * Remove duplicated dependency declaration --------- Co-authored-by: Firenoo <[email protected]> Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
80 files changed
+6169
-1785
No files matched your search
+25
-19
@@ -2,31 +2,31 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.parts.PartFluidTerminal;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.implementations.GuiCraftingStatus;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
|
||||
public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
|
||||
public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraftingStatus {
|
||||
|
||||
private GuiTabButton originalGuiBtn;
|
||||
private final ITerminalHost host;
|
||||
|
||||
public GuiFluidPatternTerminalCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super(inventoryPlayer, te);
|
||||
host = te;
|
||||
}
|
||||
@@ -34,20 +34,23 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
|
||||
@Override
|
||||
public void initGui() {
|
||||
if (host instanceof PartFluidPatternTerminal)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL.stack());
|
||||
else if (host instanceof PartFluidPatternTerminalEx)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
|
||||
else if (host instanceof PartFluidTerminal) {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
|
||||
} else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1));
|
||||
} else if (host instanceof WirelessFluidTerminalInventory) {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_FLUID_TERM, 1));
|
||||
} else if (host instanceof WirelessPatternTerminalInventory) {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1));
|
||||
} else if (host instanceof WirelessInterfaceTerminalInventory) {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_INTERFACE_TERM, 1));
|
||||
}
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL_EX.stack());
|
||||
else if (host instanceof PartFluidTerminal)
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERM.stack());
|
||||
else if (host instanceof PartLevelTerminal)
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.LEVEL_TERMINAL.stack());
|
||||
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack());
|
||||
else if (host instanceof WirelessFluidTerminalInventory)
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_FLUID_TERM.stack());
|
||||
else if (host instanceof WirelessPatternTerminalInventory)
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack());
|
||||
else if (host instanceof WirelessInterfaceTerminalInventory)
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack());
|
||||
else if (host instanceof WirelessLevelTerminalInventory)
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack());
|
||||
super.initGui();
|
||||
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
|
||||
}
|
||||
@@ -59,14 +62,17 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
|
||||
else if (host instanceof PartFluidPatternTerminalEx)
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
|
||||
else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
|
||||
else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) InventoryHandler
|
||||
.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
|
||||
else if (host instanceof PartLevelTerminal) InventoryHandler.switchGui(GuiType.LEVEL_TERMINAL);
|
||||
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
|
||||
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(terminal.getItemStack()));
|
||||
else if (host instanceof WirelessFluidTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
else if (host instanceof WirelessPatternTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
else if (host instanceof WirelessInterfaceTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
else if (host instanceof WirelessLevelTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
@@ -6,13 +6,12 @@ import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerDualInterface;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
@@ -148,9 +147,9 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
super.actionPerformed(btn);
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
if (btn == this.priority) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
|
||||
InventoryHandler.switchGui(GuiType.PRIORITY);
|
||||
} else if (btn == this.switcher) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
|
||||
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE_FLUID);
|
||||
} else if (btn == this.interfaceMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards));
|
||||
} else if (btn == this.BlockMode) {
|
||||
|
||||
@@ -11,6 +11,8 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerEssentiaMonitor;
|
||||
import com.glodblock.github.client.me.EssentiaRepo;
|
||||
@@ -21,16 +23,13 @@ import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.CPacketFluidUpdate;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
|
||||
public class GuiEssentiaTerminal extends GuiFluidMonitor {
|
||||
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
protected EntityPlayer player;
|
||||
|
||||
public GuiEssentiaTerminal(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
|
||||
@@ -64,13 +63,15 @@ public class GuiEssentiaTerminal extends GuiFluidMonitor {
|
||||
AspectUtil.getAspectFromGas(fluidStack),
|
||||
fluidStack.amount);
|
||||
IAEItemStack gas = stack.copy().setStackSize(stack.getStackSize() / AspectUtil.R);
|
||||
stackSizeRenderer.setAeStack(gas);
|
||||
stackSizeRenderer.renderItemOverlayIntoGUI(
|
||||
aeRenderItem.setAeStack(gas);
|
||||
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
|
||||
aeRenderItem.renderItemOverlayIntoGUI(
|
||||
fontRendererObj,
|
||||
mc.getTextureManager(),
|
||||
gas.getItemStack(),
|
||||
slot.xDisplayPosition,
|
||||
slot.yDisplayPosition);
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -59,6 +59,13 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
|
||||
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
|
||||
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
|
||||
this.registerApp(20, "LEVEL_TEM", "YES", "level_terminal_w");
|
||||
this.registerApp(21, "SWITCH", "ON", "edit");
|
||||
this.registerApp(22, "SWITCH", "OFF", "view");
|
||||
this.registerApp(21, "SWITCH", "ENABLE", "enable");
|
||||
this.registerApp(22, "SWITCH", "DISABLE", "disable");
|
||||
this.registerApp(23, "CONFIG", "YES", "open_configuration");
|
||||
this.registerApp(24, "HIGHLIGHT", "YES", "block_highlight");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +117,10 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
return this.currentValue;
|
||||
}
|
||||
|
||||
public boolean getMouseIn() {
|
||||
return this.field_146123_n;
|
||||
}
|
||||
|
||||
public void set(final String e) {
|
||||
if (!this.currentValue.equals(e)) {
|
||||
this.currentValue = e;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.base.FCGuiAmount;
|
||||
@@ -10,8 +9,10 @@ import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.parts.PartFluidTerminal;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketCraftRequest;
|
||||
@@ -65,20 +66,26 @@ public class GuiFluidCraftAmount extends FCGuiAmount {
|
||||
@Override
|
||||
protected void setOriginGUI(Object target) {
|
||||
if (target instanceof PartFluidPatternTerminal) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
|
||||
} else if (target instanceof PartFluidPatternTerminalEx) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
} else if (target instanceof PartFluidTerminal) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERM.stack();
|
||||
this.originalGui = GuiType.FLUID_TERMINAL;
|
||||
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
|
||||
} else if (target instanceof PartLevelTerminal) {
|
||||
myIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.LEVEL_TERMINAL;
|
||||
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
|
||||
this.myIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
} else if (target instanceof WirelessPatternTerminalInventory) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
|
||||
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
|
||||
this.originalGui = GuiType.FLUID_TERMINAL;
|
||||
} else if (target instanceof WirelessLevelTerminalInventory) {
|
||||
myIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,37 +2,42 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
|
||||
public class GuiFluidCraftConfirm extends GuiCraftConfirm {
|
||||
|
||||
private GuiType OriginalGui;
|
||||
private GuiType originalGui;
|
||||
|
||||
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te);
|
||||
if (te instanceof PartFluidPatternTerminal) {
|
||||
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL;
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
|
||||
} else if (te instanceof PartFluidPatternTerminalEx) {
|
||||
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
} else if (te instanceof IWirelessTerminal && ((IWirelessTerminal) te).isUniversal(te)) {
|
||||
this.OriginalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) te).getItemStack());
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
} else if (te instanceof PartLevelTerminal) {
|
||||
originalGui = GuiType.LEVEL_TERMINAL;
|
||||
} else if (te instanceof IWirelessTerminal terminal && terminal.isUniversal(te)) {
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
} else if (te instanceof WirelessPatternTerminalInventory) {
|
||||
this.OriginalGui = GuiType.FLUID_TERMINAL;
|
||||
this.originalGui = GuiType.FLUID_TERMINAL;
|
||||
} else if (te instanceof WirelessLevelTerminalInventory) {
|
||||
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchToOriginalGUI() {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
|
||||
InventoryHandler.switchGui(originalGui);
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,11 @@ import com.glodblock.github.client.gui.container.ContainerFluidInterface;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.gui.TankMouseHandler;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class GuiFluidInterface extends AEBaseGui {
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
if (btn == this.switcher) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE));
|
||||
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidLevelEmitter;
|
||||
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
|
||||
import com.glodblock.github.network.CPacketValueConfig;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
@@ -16,7 +15,6 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiColors;
|
||||
@@ -25,7 +23,6 @@ import appeng.core.localization.GuiText;
|
||||
public class GuiFluidLevelEmitter extends GuiUpgradeable {
|
||||
|
||||
private GuiNumberBox level;
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
private GuiButton plus1;
|
||||
private GuiButton plus10;
|
||||
private GuiButton plus100;
|
||||
@@ -82,7 +79,7 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(
|
||||
NameConst.i18n(NameConst.GUI_FLUID_LEVEL_EMITTER),
|
||||
getGuiDisplayName(NameConst.i18n(NameConst.GUI_FLUID_LEVEL_EMITTER)),
|
||||
8,
|
||||
6,
|
||||
GuiColors.UpgradableTitle.getColor());
|
||||
|
||||
@@ -13,6 +13,8 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
@@ -21,12 +23,10 @@ import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.slot.ISlotFluid;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.network.CPacketEncodePattern;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class GuiFluidPatternEncoder extends AEBaseGui {
|
||||
@@ -35,7 +35,6 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
|
||||
|
||||
private final ContainerFluidPatternEncoder cont;
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
|
||||
public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) {
|
||||
super(new ContainerFluidPatternEncoder(ipl, tile));
|
||||
@@ -95,13 +94,15 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
|
||||
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
|
||||
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
|
||||
}
|
||||
stackSizeRenderer.setAeStack(fake);
|
||||
stackSizeRenderer.renderItemOverlayIntoGUI(
|
||||
aeRenderItem.setAeStack(fake);
|
||||
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
|
||||
aeRenderItem.renderItemOverlayIntoGUI(
|
||||
fontRendererObj,
|
||||
mc.getTextureManager(),
|
||||
stack.getItemStack(),
|
||||
slot.xDisplayPosition,
|
||||
slot.yDisplayPosition);
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
} else {
|
||||
super.func_146977_a(slot);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import org.lwjgl.input.Mouse;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageBus;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -93,7 +93,7 @@ public class GuiFluidStorageBus extends GuiUpgradeable {
|
||||
} else if (btn == this.clear) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
|
||||
} else if (btn == this.priority) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
|
||||
InventoryHandler.switchGui(GuiType.PRIORITY);
|
||||
} else if (btn == this.rwMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.CPacketFluidUpdate;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
|
||||
@@ -31,12 +30,10 @@ import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
|
||||
public class GuiFluidTerminal extends GuiFluidMonitor {
|
||||
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
protected EntityPlayer player;
|
||||
public ContainerFluidMonitor container;
|
||||
|
||||
@@ -84,13 +81,15 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
|
||||
if (stack == null) return true;
|
||||
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
|
||||
this.drawWidget(slot.xDisplayPosition, slot.yDisplayPosition, fluidStack.getFluid());
|
||||
stackSizeRenderer.setAeStack(stack);
|
||||
stackSizeRenderer.renderItemOverlayIntoGUI(
|
||||
aeRenderItem.setAeStack(stack);
|
||||
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
|
||||
aeRenderItem.renderItemOverlayIntoGUI(
|
||||
fontRendererObj,
|
||||
mc.getTextureManager(),
|
||||
stack.getItemStack(),
|
||||
slot.xDisplayPosition,
|
||||
slot.yDisplayPosition);
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,769 +0,0 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.base.FCBaseMEGui;
|
||||
import com.glodblock.github.client.gui.container.ContainerInterfaceWireless;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.CPacketRenamer;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.ClientDCInternalInv;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.client.render.BlockPosHighlighter;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.PatternHelper;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
|
||||
|
||||
protected int offsetY;
|
||||
private static final int MAGIC_HEIGHT_NUMBER = 52 + 99;
|
||||
private static final int offsetX = 21;
|
||||
|
||||
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
|
||||
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
||||
private final HashMap<ClientDCInternalInv, Util.DimensionalCoordSide> blockPosHashMap = new HashMap<>();
|
||||
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<Object> lines = new ArrayList<>();
|
||||
private final Set<Object> matchedStacks = new HashSet<>();
|
||||
|
||||
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
|
||||
|
||||
protected static String searchFieldOutputsText = "";
|
||||
protected static String searchFieldInputsText = "";
|
||||
protected static String searchFieldNamesText = "";
|
||||
private final MEGuiTextField searchFieldOutputs;
|
||||
private final MEGuiTextField searchFieldInputs;
|
||||
private final MEGuiTextField searchFieldNames;
|
||||
private final GuiImgButton guiButtonHideFull;
|
||||
private final GuiImgButton guiButtonAssemblersOnly;
|
||||
private final GuiImgButton guiButtonBrokenRecipes;
|
||||
private GuiImgButton searchStringSave;
|
||||
private GuiImgButton terminalStyleBox;
|
||||
private boolean refreshList = false;
|
||||
protected static boolean onlyMolecularAssemblers = false;
|
||||
protected static boolean onlyBrokenRecipes = false;
|
||||
protected GuiTabButton craftingStatusBtn;
|
||||
|
||||
private int rows = 3;
|
||||
|
||||
private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.BlockMolecularAssembler";
|
||||
|
||||
public GuiInterfaceTerminalWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
|
||||
super(inventoryPlayer, new ContainerInterfaceWireless(inventoryPlayer, te));
|
||||
|
||||
this.setScrollBar(new GuiScrollbar());
|
||||
this.xSize = 208;
|
||||
this.ySize = 255;
|
||||
|
||||
searchFieldInputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldInputs.getLocal()) {
|
||||
|
||||
@Override
|
||||
public void onTextChange(final String oldText) {
|
||||
refreshList();
|
||||
}
|
||||
};
|
||||
|
||||
searchFieldOutputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldOutputs.getLocal()) {
|
||||
|
||||
@Override
|
||||
public void onTextChange(final String oldText) {
|
||||
refreshList();
|
||||
}
|
||||
};
|
||||
|
||||
searchFieldNames = new MEGuiTextField(71, 12, ButtonToolTips.SearchFieldNames.getLocal()) {
|
||||
|
||||
@Override
|
||||
public void onTextChange(final String oldText) {
|
||||
refreshList();
|
||||
}
|
||||
};
|
||||
searchFieldNames.setFocused(true);
|
||||
|
||||
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
|
||||
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
|
||||
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffsetY() {
|
||||
return this.offsetY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOffsetY(int y) {
|
||||
this.offsetY = y;
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
this.getScrollBar().setTop(52).setLeft(189).setHeight(this.rows * 18 - 2);
|
||||
this.getScrollBar().setRange(0, this.lines.size() - this.rows, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.rows = calculateRowsCount();
|
||||
this.ySize = MAGIC_HEIGHT_NUMBER + this.rows * 18;
|
||||
final int unusedSpace = this.height - this.ySize;
|
||||
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
|
||||
this.offsetY = this.guiTop + 8;
|
||||
this.buttonList.add(
|
||||
this.terminalStyleBox = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.offsetY,
|
||||
Settings.TERMINAL_STYLE,
|
||||
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
|
||||
this.offsetY += 20;
|
||||
this.buttonList.add(
|
||||
this.searchStringSave = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.offsetY,
|
||||
Settings.SAVE_SEARCH,
|
||||
AEConfig.instance.settings.getSetting(Settings.SAVE_SEARCH)));
|
||||
this.offsetY += 20;
|
||||
|
||||
searchFieldInputs.x = guiLeft + Math.max(32, offsetX);
|
||||
searchFieldInputs.y = guiTop + 25;
|
||||
|
||||
searchFieldOutputs.x = guiLeft + Math.max(32, offsetX);
|
||||
searchFieldOutputs.y = guiTop + 38;
|
||||
|
||||
searchFieldNames.x = guiLeft + Math.max(32, offsetX) + 99;
|
||||
searchFieldNames.y = guiTop + 38;
|
||||
|
||||
guiButtonAssemblersOnly.xPosition = guiLeft + Math.max(32, offsetX) + 99;
|
||||
guiButtonAssemblersOnly.yPosition = guiTop + 20;
|
||||
|
||||
guiButtonHideFull.xPosition = guiButtonAssemblersOnly.xPosition + 18;
|
||||
guiButtonHideFull.yPosition = guiTop + 20;
|
||||
|
||||
guiButtonBrokenRecipes.xPosition = guiButtonHideFull.xPosition + 18;
|
||||
guiButtonBrokenRecipes.yPosition = guiTop + 20;
|
||||
|
||||
terminalStyleBox.xPosition = guiLeft - 18;
|
||||
terminalStyleBox.yPosition = guiTop + 8;
|
||||
this.buttonList.add(
|
||||
this.craftingStatusBtn = new GuiTabButton(
|
||||
this.guiLeft + this.xSize - 24,
|
||||
this.guiTop - 4,
|
||||
2 + 11 * 16,
|
||||
GuiText.CraftingStatus.getLocal(),
|
||||
itemRender));
|
||||
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
|
||||
|
||||
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
|
||||
setSearchString();
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
this.repositionSlots();
|
||||
this.initGuiDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
searchFieldOutputsText = this.searchFieldOutputs.getText();
|
||||
searchFieldInputsText = this.searchFieldInputs.getText();
|
||||
searchFieldNamesText = this.searchFieldNames.getText();
|
||||
}
|
||||
|
||||
public void setSearchString() {
|
||||
this.searchFieldOutputs.setText(searchFieldOutputsText);
|
||||
this.searchFieldInputs.setText(searchFieldInputsText);
|
||||
this.searchFieldNames.setText(searchFieldNamesText);
|
||||
}
|
||||
|
||||
protected void repositionSlots() {
|
||||
for (final Object obj : this.inventorySlots.inventorySlots) {
|
||||
if (obj instanceof final AppEngSlot slot) {
|
||||
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int calculateRowsCount() {
|
||||
final int maxRows = this.getMaxRows();
|
||||
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
|
||||
final int input = 22;
|
||||
final int topPanel = 18;
|
||||
final int NEIPadding = hasNEI ? input + topPanel : 0;
|
||||
final int extraSpace = this.height - MAGIC_HEIGHT_NUMBER - NEIPadding;
|
||||
|
||||
return Math.max(3, Math.min(maxRows, extraSpace / 18));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
fontRendererObj.drawString(
|
||||
getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()),
|
||||
8,
|
||||
6,
|
||||
GuiColors.InterfaceTerminalTitle.getColor());
|
||||
fontRendererObj.drawString(
|
||||
GuiText.inventory.getLocal(),
|
||||
GuiInterfaceTerminalWireless.offsetX + 2,
|
||||
this.ySize - 96,
|
||||
GuiColors.InterfaceTerminalInventory.getColor());
|
||||
|
||||
int offset = 51;
|
||||
final int ex = getScrollBar().getCurrentScroll();
|
||||
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof final ClientDCInternalInv inv) {
|
||||
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
|
||||
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z))) drawRect(
|
||||
z * 18 + 22,
|
||||
1 + offset,
|
||||
z * 18 + 22 + 16,
|
||||
1 + offset + 16,
|
||||
GuiColors.InterfaceTerminalMatch.getColor());
|
||||
}
|
||||
} else if (lineObj instanceof String name) {
|
||||
final int rows = this.byName.get(name).size();
|
||||
String postfix = "";
|
||||
|
||||
if (rows > 1) {
|
||||
postfix = " (" + rows + ')';
|
||||
}
|
||||
|
||||
while (name.length() > 2 && this.fontRendererObj.getStringWidth(name + postfix) > 158) {
|
||||
name = name.substring(0, name.length() - 1);
|
||||
}
|
||||
|
||||
this.fontRendererObj.drawString(
|
||||
name + postfix,
|
||||
GuiInterfaceTerminalWireless.offsetX + 3,
|
||||
6 + offset,
|
||||
GuiColors.InterfaceTerminalName.getColor());
|
||||
}
|
||||
|
||||
offset += 18;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
|
||||
buttonList.clear();
|
||||
inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
|
||||
|
||||
guiButtonAssemblersOnly.set(
|
||||
onlyMolecularAssemblers ? ActionItems.MOLECULAR_ASSEMBLEERS_ON : ActionItems.MOLECULAR_ASSEMBLEERS_OFF);
|
||||
guiButtonHideFull.set(
|
||||
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
|
||||
? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF
|
||||
: ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
|
||||
guiButtonBrokenRecipes.set(
|
||||
onlyBrokenRecipes ? ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_OFF
|
||||
: ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_ON);
|
||||
|
||||
terminalStyleBox.set(AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE));
|
||||
|
||||
buttonList.add(guiButtonAssemblersOnly);
|
||||
buttonList.add(guiButtonHideFull);
|
||||
buttonList.add(guiButtonBrokenRecipes);
|
||||
|
||||
buttonList.add(terminalStyleBox);
|
||||
buttonList.add(searchStringSave);
|
||||
buttonList.add(craftingStatusBtn);
|
||||
this.guiButtonHashMap.clear();
|
||||
addSwitchGuiBtns();
|
||||
|
||||
int offset = 51;
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof final ClientDCInternalInv inv) {
|
||||
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
|
||||
inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z, z * 18 + 22, 1 + offset));
|
||||
}
|
||||
|
||||
GuiButton guiButton = new GuiImgButton(
|
||||
guiLeft + 4,
|
||||
guiTop + offset + 1,
|
||||
Settings.ACTIONS,
|
||||
ActionItems.HIGHLIGHT_INTERFACE);
|
||||
GuiFCImgButton editButton = new GuiFCImgButton(guiLeft + 4, guiTop + offset + 1, "EDIT", "YES");
|
||||
guiButtonHashMap.put(guiButton, inv);
|
||||
guiButtonHashMap.put(editButton, inv);
|
||||
if (isShiftKeyDown()) {
|
||||
buttonList.add(editButton);
|
||||
} else {
|
||||
buttonList.add(guiButton);
|
||||
}
|
||||
}
|
||||
|
||||
offset += 18;
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
|
||||
handleTooltip(mouseX, mouseY, searchFieldInputs);
|
||||
handleTooltip(mouseX, mouseY, searchFieldOutputs);
|
||||
handleTooltip(mouseX, mouseY, searchFieldNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||
boolean focusIn = searchFieldInputs.isFocused();
|
||||
boolean focusOut = searchFieldOutputs.isFocused();
|
||||
boolean focusName = searchFieldNames.isFocused();
|
||||
|
||||
searchFieldInputs.mouseClicked(xCoord, yCoord, btn);
|
||||
searchFieldOutputs.mouseClicked(xCoord, yCoord, btn);
|
||||
searchFieldNames.mouseClicked(xCoord, yCoord, btn);
|
||||
|
||||
if (focusIn && !searchFieldInputs.isFocused()) {
|
||||
searchFieldInputsText = searchFieldInputs.getText();
|
||||
} else if (focusOut && !searchFieldOutputs.isFocused()) {
|
||||
searchFieldOutputsText = searchFieldOutputs.getText();
|
||||
} else if (focusName && !searchFieldNames.isFocused()) {
|
||||
searchFieldNamesText = searchFieldNames.getText();
|
||||
}
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (guiButtonHashMap.containsKey(btn)) {
|
||||
Util.DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
|
||||
if (btn instanceof GuiFCImgButton) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketRenamer(
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z,
|
||||
blockPos.getDimension(),
|
||||
blockPos.getSide()));
|
||||
} else {
|
||||
|
||||
WorldCoord blockPos2 = new WorldCoord(
|
||||
(int) mc.thePlayer.posX,
|
||||
(int) mc.thePlayer.posY,
|
||||
(int) mc.thePlayer.posZ);
|
||||
if (mc.theWorld.provider.dimensionId != blockPos.getDimension()) {
|
||||
mc.thePlayer.addChatMessage(
|
||||
new ChatComponentTranslation(
|
||||
PlayerMessages.InterfaceInOtherDim.getName(),
|
||||
blockPos.getDimension()));
|
||||
} else {
|
||||
BlockPosHighlighter.highlightBlock(
|
||||
blockPos,
|
||||
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
|
||||
mc.thePlayer.addChatMessage(
|
||||
new ChatComponentTranslation(
|
||||
PlayerMessages.InterfaceHighlighted.getName(),
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z));
|
||||
}
|
||||
mc.thePlayer.closeScreen();
|
||||
}
|
||||
} else if (btn == guiButtonHideFull) {
|
||||
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal = !AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal;
|
||||
this.refreshList();
|
||||
} else if (btn == guiButtonAssemblersOnly) {
|
||||
onlyMolecularAssemblers = !onlyMolecularAssemblers;
|
||||
this.refreshList();
|
||||
} else if (btn == guiButtonBrokenRecipes) {
|
||||
onlyBrokenRecipes = !onlyBrokenRecipes;
|
||||
this.refreshList();
|
||||
} else if (ModAndClassUtil.isSaveText && btn == searchStringSave) {
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
final GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
final Enum<?> cv = iBtn.getCurrentValue();
|
||||
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
|
||||
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
|
||||
AEConfig.instance.settings.putSetting(Settings.SAVE_SEARCH, next);
|
||||
this.searchStringSave.set(next);
|
||||
|
||||
} else if (btn == craftingStatusBtn) {
|
||||
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
|
||||
} else if (btn instanceof final GuiImgButton iBtn) {
|
||||
if (iBtn.getSetting() != Settings.ACTIONS) {
|
||||
final Enum cv = iBtn.getCurrentValue();
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
|
||||
|
||||
if (btn == this.terminalStyleBox) {
|
||||
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
|
||||
|
||||
this.reinitialize();
|
||||
}
|
||||
|
||||
iBtn.set(next);
|
||||
}
|
||||
}
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
private void reinitialize() {
|
||||
this.buttonList.clear();
|
||||
this.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.bindTexture("guis/newinterfaceterminal.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 53);
|
||||
|
||||
int offset = 51;
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
|
||||
for (int x = 0; x < this.rows; x++) {
|
||||
this.drawTexturedModalRect(offsetX, offsetY + 53 + x * 18, 0, 52, this.xSize, 18);
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
|
||||
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof final ClientDCInternalInv inv) {
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
final int width = inv.getInventory().getSizeInventory() * 18;
|
||||
this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 173, width, 18);
|
||||
}
|
||||
|
||||
offset += 18;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(offsetX, offsetY + 50 + this.rows * 18, 0, 158, this.xSize, 99);
|
||||
|
||||
searchFieldInputs.drawTextBox();
|
||||
searchFieldOutputs.drawTextBox();
|
||||
searchFieldNames.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!checkHotbarKeys(key)) {
|
||||
if (character == ' ') {
|
||||
if ((searchFieldInputs.getText().isEmpty() && searchFieldInputs.isFocused())
|
||||
|| (searchFieldOutputs.getText().isEmpty() && searchFieldOutputs.isFocused())
|
||||
|| (searchFieldNames.getText().isEmpty() && searchFieldNames.isFocused()))
|
||||
return;
|
||||
} else if (character == '\t') {
|
||||
if (handleTab()) return;
|
||||
}
|
||||
if (searchFieldInputs.textboxKeyTyped(character, key) || searchFieldOutputs.textboxKeyTyped(character, key)
|
||||
|| searchFieldNames.textboxKeyTyped(character, key)) {
|
||||
refreshList();
|
||||
} else {
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleTab() {
|
||||
if (searchFieldInputs.isFocused()) {
|
||||
searchFieldInputs.setFocused(false);
|
||||
if (isShiftKeyDown()) searchFieldNames.setFocused(true);
|
||||
else searchFieldOutputs.setFocused(true);
|
||||
return true;
|
||||
} else if (searchFieldOutputs.isFocused()) {
|
||||
searchFieldOutputs.setFocused(false);
|
||||
if (isShiftKeyDown()) searchFieldInputs.setFocused(true);
|
||||
else searchFieldNames.setFocused(true);
|
||||
return true;
|
||||
} else if (searchFieldNames.isFocused()) {
|
||||
searchFieldNames.setFocused(false);
|
||||
if (isShiftKeyDown()) searchFieldOutputs.setFocused(true);
|
||||
else searchFieldInputs.setFocused(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void postUpdate(final NBTTagCompound in) {
|
||||
if (in.getBoolean("clear")) {
|
||||
this.byId.clear();
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
for (final Object oKey : in.func_150296_c()) {
|
||||
final String key = (String) oKey;
|
||||
if (key.startsWith("=")) {
|
||||
try {
|
||||
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
|
||||
final NBTTagCompound invData = in.getCompoundTag(key);
|
||||
int size = invData.getInteger("size");
|
||||
final ClientDCInternalInv current = this
|
||||
.getById(id, invData.getLong("sortBy"), invData.getString("un"), size);
|
||||
int X = invData.getInteger("x");
|
||||
int Y = invData.getInteger("y");
|
||||
int Z = invData.getInteger("z");
|
||||
int dim = invData.getInteger("dim");
|
||||
ForgeDirection side = ForgeDirection.getOrientation(invData.getInteger("side"));
|
||||
blockPosHashMap.put(
|
||||
current,
|
||||
new Util.DimensionalCoordSide(X, Y, Z, dim, side, current.getUnlocalizedName()));
|
||||
|
||||
for (int x = 0; x < current.getInventory().getSizeInventory(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.hasKey(which)) {
|
||||
current.getInventory().setInventorySlotContents(
|
||||
x,
|
||||
ItemStack.loadItemStackFromNBT(invData.getCompoundTag(which)));
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.refreshList) {
|
||||
this.refreshList = false;
|
||||
// invalidate caches on refresh
|
||||
this.cachedSearches.clear();
|
||||
this.refreshList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the list of interfaces.
|
||||
* <p>
|
||||
* Respects a search term if present (ignores case) and adding only matching patterns.
|
||||
*/
|
||||
private void refreshList() {
|
||||
this.byName.clear();
|
||||
this.buttonList.clear();
|
||||
this.matchedStacks.clear();
|
||||
|
||||
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
|
||||
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
|
||||
final String searchFieldNames = this.searchFieldNames.getText().toLowerCase();
|
||||
|
||||
final Set<Object> cachedSearch = this.getCacheForSearchTerm(
|
||||
"IN:" + searchFieldInputs
|
||||
+ "OUT:"
|
||||
+ searchFieldOutputs
|
||||
+ "NAME:"
|
||||
+ searchFieldNames
|
||||
+ AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
|
||||
+ onlyMolecularAssemblers
|
||||
+ onlyBrokenRecipes);
|
||||
final boolean rebuild = cachedSearch.isEmpty();
|
||||
|
||||
for (final ClientDCInternalInv entry : this.byId.values()) {
|
||||
// ignore inventory if not doing a full rebuild and cache already marks it as miss.
|
||||
if (!rebuild && !cachedSearch.contains(entry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Shortcut to skip any filter if search term is ""/empty
|
||||
boolean found = searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty();
|
||||
boolean interfaceHasFreeSlots = false;
|
||||
boolean interfaceHasBrokenRecipes = false;
|
||||
|
||||
// Search if the current inventory holds a pattern containing the search term.
|
||||
if (!found || AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || onlyBrokenRecipes) {
|
||||
for (final ItemStack itemStack : entry.getInventory()) {
|
||||
// If only Interfaces with empty slots should be shown, check that here
|
||||
if (itemStack == null) {
|
||||
interfaceHasFreeSlots = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (onlyBrokenRecipes && recipeIsBroken(itemStack)) {
|
||||
interfaceHasBrokenRecipes = true;
|
||||
}
|
||||
|
||||
if ((!searchFieldInputs.isEmpty() && itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0))
|
||||
|| (!searchFieldOutputs.isEmpty()
|
||||
&& itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1))) {
|
||||
found = true;
|
||||
matchedStacks.add(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((found && entry.getName().toLowerCase().contains(searchFieldNames))
|
||||
&& (!onlyMolecularAssemblers || entry.getUnlocalizedName().contains(MOLECULAR_ASSEMBLER))
|
||||
&& (!AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || interfaceHasFreeSlots)
|
||||
&& (!onlyBrokenRecipes || interfaceHasBrokenRecipes)) {
|
||||
this.byName.put(entry.getName(), entry);
|
||||
cachedSearch.add(entry);
|
||||
} else {
|
||||
cachedSearch.remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
this.names.clear();
|
||||
this.names.addAll(this.byName.keySet());
|
||||
|
||||
Collections.sort(this.names);
|
||||
|
||||
this.lines.clear();
|
||||
this.lines.ensureCapacity(this.names.size() + this.byId.size());
|
||||
|
||||
for (final String n : this.names) {
|
||||
this.lines.add(n);
|
||||
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>(this.byName.get(n));
|
||||
Collections.sort(clientInventories);
|
||||
this.lines.addAll(clientInventories);
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm, int pass) {
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final NBTTagCompound encodedValue = itemStack.getTagCompound();
|
||||
|
||||
if (encodedValue == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final NBTTagList tags = encodedValue.getTagList(pass == 0 ? "in" : "out", 10);
|
||||
final boolean containsInvalidDisplayName = GuiText.UnknownItem.getLocal().toLowerCase().contains(searchTerm);
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
final NBTTagCompound tag = tags.getCompoundTagAt(i);
|
||||
final ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT(tag);
|
||||
|
||||
if (parsedItemStack != null) {
|
||||
final String displayName = Platform
|
||||
.getItemDisplayName(AEApi.instance().storage().createItemStack(parsedItemStack)).toLowerCase();
|
||||
if (displayName.contains(searchTerm)) {
|
||||
return true;
|
||||
}
|
||||
} else if (containsInvalidDisplayName && !tag.hasNoTags()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean recipeIsBroken(final ItemStack itemStack) {
|
||||
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final NBTTagCompound encodedValue = itemStack.getTagCompound();
|
||||
if (encodedValue == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final World w = CommonHelper.proxy.getWorld();
|
||||
if (w == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
new PatternHelper(itemStack, w);
|
||||
return false;
|
||||
} catch (final Throwable t) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to retrieve a cache for a with search term as keyword.
|
||||
* <p>
|
||||
* If this cache should be empty, it will populate it with an earlier cache if available or at least the cache for
|
||||
* the empty string.
|
||||
*
|
||||
* @param searchTerm the corresponding search
|
||||
* @return a Set matching a superset of the search term
|
||||
*/
|
||||
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
|
||||
if (!this.cachedSearches.containsKey(searchTerm)) {
|
||||
this.cachedSearches.put(searchTerm, new HashSet<>());
|
||||
}
|
||||
|
||||
final Set<Object> cache = this.cachedSearches.get(searchTerm);
|
||||
|
||||
if (cache.isEmpty() && searchTerm.length() > 1) {
|
||||
cache.addAll(this.getCacheForSearchTerm(searchTerm.substring(0, searchTerm.length() - 1)));
|
||||
return cache;
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
private int getMaxRows() {
|
||||
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
|
||||
? AEConfig.instance.InterfaceTerminalSmallSize
|
||||
: Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
private ClientDCInternalInv getById(final long id, final long sortBy, final String unlocalizedName,
|
||||
final int sizeInit) {
|
||||
ClientDCInternalInv o = this.byId.get(id);
|
||||
|
||||
if (o == null) {
|
||||
this.byId.put(id, o = new ClientDCInternalInv(sizeInit, id, sortBy, unlocalizedName));
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
public boolean isOverTextField(final int mousex, final int mousey) {
|
||||
return searchFieldInputs.isMouseIn(mousex, mousey) || searchFieldOutputs.isMouseIn(mousex, mousey)
|
||||
|| searchFieldNames.isMouseIn(mousex, mousey);
|
||||
}
|
||||
|
||||
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
|
||||
|
||||
if (searchFieldInputs.isMouseIn(mousex, mousey)) {
|
||||
searchFieldInputs.setText(displayName);
|
||||
} else if (searchFieldOutputs.isMouseIn(mousex, mousey)) {
|
||||
searchFieldOutputs.setText(displayName);
|
||||
} else if (searchFieldNames.isMouseIn(mousex, mousey)) {
|
||||
searchFieldNames.setText(displayName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import static com.glodblock.github.client.gui.container.ContainerLevelMaintainer.createLevelValues;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -13,23 +15,41 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer.Action;
|
||||
import com.glodblock.github.network.CPacketLevelTerminalCommands;
|
||||
import com.glodblock.github.util.FCGuiColors;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketNEIDragClick;
|
||||
import codechicken.nei.VisiblityData;
|
||||
@@ -45,11 +65,15 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
private final ContainerLevelMaintainer cont;
|
||||
private final Component[] component = new Component[TileLevelMaintainer.REQ_COUNT];
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
private FCGuiTextField input;
|
||||
private int lastWorkingTick;
|
||||
private int refreshTick;
|
||||
private final CoFHFontRenderer render;
|
||||
protected ItemStack icon = null;
|
||||
|
||||
protected GuiType originalGui;
|
||||
protected Util.DimensionalCoordSide originalBlockPos;
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
|
||||
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
|
||||
super(new ContainerLevelMaintainer(ipl, tile));
|
||||
@@ -62,27 +86,72 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
Minecraft.getMinecraft().getTextureManager(),
|
||||
true);
|
||||
this.refreshTick = 0;
|
||||
if (ipl.player.openContainer instanceof AEBaseContainer container) {
|
||||
var target = container.getTarget();
|
||||
if (target instanceof PartLevelTerminal terminal) {
|
||||
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.LEVEL_TERMINAL;
|
||||
DimensionalCoord blockPos = new DimensionalCoord(terminal.getTile());
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z,
|
||||
blockPos.getDimension(),
|
||||
terminal.getSide(),
|
||||
"");
|
||||
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
|
||||
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
terminal.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0,
|
||||
ipl.player.worldObj.provider.dimensionId,
|
||||
ForgeDirection.UNKNOWN,
|
||||
"");
|
||||
} else if (target instanceof WirelessLevelTerminalInventory terminal) {
|
||||
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
terminal.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0,
|
||||
ipl.player.worldObj.provider.dimensionId,
|
||||
ForgeDirection.UNKNOWN,
|
||||
"");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list) {
|
||||
for (Slot slot : this.cont.getRequestSlots()) {
|
||||
if (!slot.getHasStack()) {
|
||||
component[slot.getSlotIndex()].setState(TileLevelMaintainer.State.Nothing);
|
||||
component[slot.getSlotIndex()].setState(State.None);
|
||||
}
|
||||
}
|
||||
for (IAEItemStack is : list) {
|
||||
NBTTagCompound data = is.getItemStack().getTagCompound();
|
||||
long size = data.getLong("Batch");
|
||||
int i = data.getInteger("Index");
|
||||
boolean isEnable = data.getBoolean("Enable");
|
||||
TileLevelMaintainer.State state = TileLevelMaintainer.State.values()[data.getInteger("State")];
|
||||
component[i].getQty().textField.setText(String.valueOf(is.getStackSize()));
|
||||
component[i].getBatch().textField.setText(String.valueOf(size));
|
||||
component[i].setEnable(isEnable);
|
||||
component[i].setState(state);
|
||||
if (data == null) {
|
||||
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
|
||||
AELog.info("Received empty configuration: ", is);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
long batch = data.getLong(TLMTags.Batch.tagName);
|
||||
long quantity = data.getLong(TLMTags.Quantity.tagName);
|
||||
int idx = data.getInteger(TLMTags.Index.tagName);
|
||||
boolean isEnable = data.getBoolean(TLMTags.Enable.tagName);
|
||||
State state = State.values()[data.getInteger(TLMTags.State.tagName)];
|
||||
component[idx].getQty().textField.setText(String.valueOf(quantity));
|
||||
component[idx].getBatch().textField.setText(String.valueOf(batch));
|
||||
component[idx].setEnable(isEnable);
|
||||
component[idx].setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.lastWorkingTick = this.refreshTick;
|
||||
@@ -92,19 +161,29 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
new FCGuiTextField(this.fontRendererObj, guiLeft + 46, guiTop + 19 + 19 * i, 52, 14),
|
||||
NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE,
|
||||
i,
|
||||
"TileLevelMaintainer.Quantity"),
|
||||
Action.Quantity),
|
||||
new Widget(
|
||||
new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 19 + 19 * i, 52, 14),
|
||||
NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE,
|
||||
i,
|
||||
"TileLevelMaintainer.Batch"),
|
||||
Action.Batch),
|
||||
new GuiFCImgButton(guiLeft + 105 + 47, guiTop + 17 + 19 * i, "SUBMIT", "SUBMIT", false),
|
||||
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "ENABLE", "ENABLE", false),
|
||||
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "DISABLE", "DISABLE", false),
|
||||
new FCGuiLineField(fontRendererObj, guiLeft + 47, guiTop + 33 + 19 * i, 125),
|
||||
this.buttonList);
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
|
||||
if (this.icon != null) {
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 151,
|
||||
this.guiTop - 4,
|
||||
this.icon,
|
||||
this.icon.getDisplayName(),
|
||||
itemRender);
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
this.buttonList.add(originalGuiBtn);
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
|
||||
}
|
||||
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
@@ -124,7 +203,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
int tick = this.refreshTick;
|
||||
int interval = 20;
|
||||
if (tick > lastWorkingTick + interval && this.input == null) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
|
||||
lastWorkingTick = this.refreshTick;
|
||||
}
|
||||
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
|
||||
@@ -154,13 +233,15 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
} else {
|
||||
fake.setStackSize(0);
|
||||
}
|
||||
stackSizeRenderer.setAeStack(fake);
|
||||
stackSizeRenderer.renderItemOverlayIntoGUI(
|
||||
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
|
||||
aeRenderItem.setAeStack(fake);
|
||||
aeRenderItem.renderItemOverlayIntoGUI(
|
||||
fontRendererObj,
|
||||
mc.getTextureManager(),
|
||||
stack.getItemStack(),
|
||||
fake.getItemStack(),
|
||||
slot.xDisplayPosition,
|
||||
slot.yDisplayPosition);
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -225,14 +306,33 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
for (Component com : this.component) {
|
||||
if (com.sendToServer(btn)) {
|
||||
break;
|
||||
if (btn == originalGuiBtn) {
|
||||
switchGui();
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
for (Component com : this.component) {
|
||||
if (com.sendToServer(btn)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GuiType getOriginalGui() {
|
||||
return originalGui;
|
||||
}
|
||||
|
||||
public void switchGui() {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketLevelTerminalCommands(
|
||||
CPacketLevelTerminalCommands.Action.BACK,
|
||||
originalBlockPos.x,
|
||||
originalBlockPos.y,
|
||||
originalBlockPos.z,
|
||||
originalBlockPos.getDimension(),
|
||||
originalBlockPos.getSide()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
|
||||
return currentVisibility;
|
||||
@@ -254,20 +354,20 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
|
||||
for (SlotFluidConvertingFake slot : this.cont.getRequestSlots()) {
|
||||
if (getSlotArea(slot).contains(mouseX, mouseY)) {
|
||||
slot.putStack(draggedStack);
|
||||
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(draggedStack, slot.getSlotIndex()));
|
||||
if (draggedStack != null) {
|
||||
this.updateAmount(slot.getSlotIndex(), draggedStack.stackSize);
|
||||
draggedStack.stackSize = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (draggedStack != null) {
|
||||
draggedStack.stackSize = 0;
|
||||
}
|
||||
for (int i = 0; i < this.cont.getRequestSlots().length; i++) {
|
||||
SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i];
|
||||
if (getSlotArea(slot).contains(mouseX, mouseY) && draggedStack != null) {
|
||||
ItemStack itemStack = createLevelValues(draggedStack.copy());
|
||||
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
|
||||
slot.putStack(itemStack);
|
||||
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
|
||||
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -285,8 +385,9 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
private final GuiFCImgButton enable;
|
||||
private final GuiFCImgButton submit;
|
||||
private final FCGuiLineField line;
|
||||
private TileLevelMaintainer.State state;
|
||||
private State state;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Component(Widget qtyInput, Widget batchInput, GuiFCImgButton submitBtn, GuiFCImgButton enableBtn,
|
||||
GuiFCImgButton disableBtn, FCGuiLineField line, List buttonList) {
|
||||
this.qty = qtyInput;
|
||||
@@ -295,14 +396,14 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
this.disable = disableBtn;
|
||||
this.submit = submitBtn;
|
||||
this.line = line;
|
||||
this.state = TileLevelMaintainer.State.Nothing;
|
||||
this.state = State.None;
|
||||
buttonList.add(this.submit);
|
||||
buttonList.add(this.enable);
|
||||
buttonList.add(this.disable);
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.getQty().idx;
|
||||
return this.qty.idx;
|
||||
}
|
||||
|
||||
public void setEnable(boolean enable) {
|
||||
@@ -332,20 +433,18 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
if (this.send(this.getQty())) this.send(this.getBatch());
|
||||
didSomething = true;
|
||||
} else if (this.enable == btn) {
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex()));
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Enable, this.getIndex()));
|
||||
didSomething = true;
|
||||
} else if (this.disable == btn) {
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex()));
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Disable, this.getIndex()));
|
||||
didSomething = true;
|
||||
}
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
public FCGuiTextField isMouseIn(final int xCoord, final int yCoord) {
|
||||
if (this.getQty().textField.isMouseIn(xCoord, yCoord)) return this.getQty().textField;
|
||||
if (this.getBatch().textField.isMouseIn(xCoord, yCoord)) return this.getBatch().textField;
|
||||
if (this.qty.textField.isMouseIn(xCoord, yCoord)) return this.getQty().textField;
|
||||
if (this.batch.textField.isMouseIn(xCoord, yCoord)) return this.getBatch().textField;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -362,33 +461,39 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
this.getQty().draw();
|
||||
this.getBatch().draw();
|
||||
this.qty.draw();
|
||||
this.batch.draw();
|
||||
ArrayList<String> message = new ArrayList<>();
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_TITLE) + "\n");
|
||||
switch (this.state) {
|
||||
case Idling -> {
|
||||
this.line.setColor(0xFF55FF55);
|
||||
case Idle -> {
|
||||
this.line.setColor(FCGuiColors.StateIdle.getColor());
|
||||
message.add(
|
||||
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
|
||||
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
|
||||
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
|
||||
}
|
||||
case Crafting -> {
|
||||
this.line.setColor(0xFFFFFF55);
|
||||
case Craft -> {
|
||||
this.line.setColor(FCGuiColors.StateCraft.getColor());
|
||||
message.add(
|
||||
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
|
||||
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
|
||||
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
|
||||
}
|
||||
case Exporting -> {
|
||||
this.line.setColor(0xFFAA00AA);
|
||||
case Export -> {
|
||||
this.line.setColor(FCGuiColors.StateExport.getColor());
|
||||
message.add(
|
||||
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
|
||||
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
|
||||
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
|
||||
}
|
||||
default -> {
|
||||
this.line.setColor(0);
|
||||
case Error -> {
|
||||
this.line.setColor(FCGuiColors.StateError.getColor());
|
||||
message.add(
|
||||
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
|
||||
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
|
||||
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
|
||||
}
|
||||
default -> {
|
||||
this.line.setColor(FCGuiColors.StateNone.getColor());
|
||||
message.add(
|
||||
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
|
||||
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NONE));
|
||||
}
|
||||
}
|
||||
@@ -399,7 +504,9 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK_DESC) + "\n");
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC));
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC) + "\n");
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
|
||||
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR_DESC));
|
||||
} else {
|
||||
message.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
@@ -415,7 +522,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public void setState(TileLevelMaintainer.State state) {
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@@ -423,11 +530,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
private class Widget {
|
||||
|
||||
public final int idx;
|
||||
public final String action;
|
||||
public final Action action;
|
||||
private final FCGuiTextField textField;
|
||||
private final String tooltip;
|
||||
|
||||
public Widget(FCGuiTextField textField, String tooltip, int idx, String action) {
|
||||
public Widget(FCGuiTextField textField, String tooltip, int idx, Action action) {
|
||||
this.textField = textField;
|
||||
this.textField.setEnableBackgroundDrawing(false);
|
||||
this.textField.setText("0");
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,24 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelWireless;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
|
||||
public class GuiLevelWireless extends GuiLevelTerminal {
|
||||
|
||||
public GuiLevelWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
|
||||
super(inventoryPlayer, new ContainerLevelWireless(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void repositionSlots() {
|
||||
for (final Object obj : this.inventorySlots.inventorySlots) {
|
||||
if (obj instanceof final AppEngSlot slot) {
|
||||
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.base.FCGuiAmount;
|
||||
@@ -67,16 +66,16 @@ public class GuiPatternValueAmount extends FCGuiAmount {
|
||||
@Override
|
||||
protected void setOriginGUI(Object target) {
|
||||
if (target instanceof PartFluidPatternTerminal) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
|
||||
} else if (target instanceof PartFluidPatternTerminalEx) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
|
||||
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
|
||||
this.myIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
} else if (target instanceof WirelessPatternTerminalInventory) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
|
||||
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
|
||||
this.originalGui = GuiType.WIRELESS_FLUID_PATTERN_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -7,10 +8,19 @@ import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerRenamer;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketRenamer;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.core.localization.GuiColors;
|
||||
@@ -18,20 +28,46 @@ import appeng.core.localization.GuiText;
|
||||
|
||||
public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
|
||||
private final MEGuiTextField textField;
|
||||
protected final MEGuiTextField textField;
|
||||
|
||||
protected final ITerminalHost host;
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
|
||||
protected ItemStack icon = null;
|
||||
|
||||
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(new ContainerRenamer(ip, monitorable));
|
||||
this.host = monitorable;
|
||||
this.xSize = 256;
|
||||
|
||||
this.textField = new MEGuiTextField(230, 12);
|
||||
this.textField.setMaxStringLength(32);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(CPacketRenamer.Action.GET_TEXT));
|
||||
if (host instanceof PartLevelTerminal) {
|
||||
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
} else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host)) {
|
||||
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
} else if (host instanceof WirelessLevelTerminalInventory) {
|
||||
icon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
|
||||
} else if (host instanceof WirelessInterfaceTerminalInventory) {
|
||||
icon = ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack();
|
||||
}
|
||||
if (this.icon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 231,
|
||||
this.guiTop - 4,
|
||||
this.icon,
|
||||
this.icon.getDisplayName(),
|
||||
itemRender));
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
}
|
||||
this.textField.x = this.guiLeft + 12;
|
||||
this.textField.y = this.guiTop + 35;
|
||||
this.textField.setFocused(true);
|
||||
@@ -68,6 +104,25 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
return textField.isMouseIn(mousex, mousey);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button == originalGuiBtn) {
|
||||
switchGui();
|
||||
} else {
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
}
|
||||
|
||||
public void switchGui() {
|
||||
if (host instanceof PartLevelTerminal) InventoryHandler.switchGui(GuiType.LEVEL_TERMINAL);
|
||||
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
|
||||
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(terminal.getItemStack()));
|
||||
else if (host instanceof WirelessInterfaceTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
else if (host instanceof WirelessLevelTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
}
|
||||
|
||||
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
|
||||
textField.setText(displayName);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternExWireless;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternWireless;
|
||||
import com.glodblock.github.client.gui.GuiFluidPortableCell;
|
||||
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
|
||||
import com.glodblock.github.client.gui.GuiInterfaceWireless;
|
||||
import com.glodblock.github.client.gui.GuiLevelWireless;
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
@@ -29,7 +30,8 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
protected GuiFCImgButton PatternTerminal;
|
||||
protected GuiFCImgButton EssentiaTerminal;
|
||||
protected GuiFCImgButton InterfaceTerminal;
|
||||
protected GuiFCImgButton PatternTerminaleEx;
|
||||
protected GuiFCImgButton LevelTerminal;
|
||||
protected GuiFCImgButton PatternTerminalEx;
|
||||
protected List<GuiFCImgButton> termBtns = new ArrayList<>();
|
||||
protected boolean drawSwitchGuiBtn;
|
||||
|
||||
@@ -87,13 +89,13 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
}
|
||||
if (!(this instanceof GuiFluidPatternExWireless)) {
|
||||
this.buttonList.add(
|
||||
this.PatternTerminaleEx = new GuiFCImgButton(
|
||||
this.PatternTerminalEx = new GuiFCImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.getOffsetY(),
|
||||
"PATTERN_EX_TEM",
|
||||
"YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.PatternTerminaleEx);
|
||||
termBtns.add(this.PatternTerminalEx);
|
||||
}
|
||||
if (!(this instanceof GuiFluidPortableCell)) {
|
||||
this.buttonList.add(
|
||||
@@ -101,7 +103,7 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.FluidTerminal);
|
||||
}
|
||||
if (!(this instanceof GuiInterfaceTerminalWireless)) {
|
||||
if (!(this instanceof GuiInterfaceWireless)) {
|
||||
this.buttonList.add(
|
||||
this.InterfaceTerminal = new GuiFCImgButton(
|
||||
this.guiLeft - 18,
|
||||
@@ -111,6 +113,12 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.InterfaceTerminal);
|
||||
}
|
||||
if (!(this instanceof GuiLevelWireless)) {
|
||||
this.buttonList.add(
|
||||
this.LevelTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "LEVEL_TEM", "YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.LevelTerminal);
|
||||
}
|
||||
if (ModAndClassUtil.ThE && !(this instanceof GuiEssentiaTerminal)) {
|
||||
this.buttonList.add(
|
||||
this.EssentiaTerminal = new GuiFCImgButton(
|
||||
@@ -123,6 +131,7 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addSwitchGuiBtns() {
|
||||
if (!drawSwitchGuiBtn) return;
|
||||
this.buttonList.addAll(termBtns);
|
||||
@@ -141,7 +150,9 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
} else if (btn == this.InterfaceTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
} else if (btn == this.PatternTerminaleEx) {
|
||||
} else if (btn == this.LevelTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
} else if (btn == this.PatternTerminalEx) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
@@ -65,11 +64,12 @@ public abstract class FCGuiAmount extends AEBaseGui {
|
||||
if (this.originalGui != null && this.myIcon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 154,
|
||||
this.guiTop,
|
||||
this.guiLeft + 151,
|
||||
this.guiTop - 4,
|
||||
this.myIcon,
|
||||
this.myIcon.getDisplayName(),
|
||||
itemRender));
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
}
|
||||
|
||||
this.amountBox = new GuiTextField(
|
||||
@@ -106,7 +106,7 @@ public abstract class FCGuiAmount extends AEBaseGui {
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
if (btn == this.originalGuiBtn) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
|
||||
InventoryHandler.switchGui(originalGui);
|
||||
}
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus = btn == this.minus1 || btn == this.minus10
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFCImgButton;
|
||||
@@ -15,7 +16,6 @@ import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
@@ -23,7 +23,6 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -54,7 +53,6 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
|
||||
protected GuiFCImgButton autoFillPatternEnableBtn;
|
||||
protected GuiFCImgButton autoFillPatternDisableBtn;
|
||||
protected final GuiScrollbar processingScrollBar = new GuiScrollbar();
|
||||
protected final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
|
||||
public FCGuiEncodeTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te,
|
||||
final FCContainerEncodeTerminal c) {
|
||||
@@ -184,13 +182,15 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
|
||||
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
|
||||
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
|
||||
} else return true;
|
||||
stackSizeRenderer.setAeStack(fake);
|
||||
stackSizeRenderer.renderItemOverlayIntoGUI(
|
||||
aeRenderItem.setAeStack(fake);
|
||||
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
|
||||
aeRenderItem.renderItemOverlayIntoGUI(
|
||||
fontRendererObj,
|
||||
mc.getTextureManager(),
|
||||
stack.getItemStack(),
|
||||
slot.xDisplayPosition,
|
||||
slot.yDisplayPosition);
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
+4
@@ -9,6 +9,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
@@ -35,6 +36,9 @@ public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
|
||||
if (ah instanceof PartFluidPatternTerminalEx) {
|
||||
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
if (ah instanceof PartLevelTerminal) {
|
||||
originalGui = GuiType.LEVEL_TERMINAL;
|
||||
}
|
||||
if (ah instanceof IWirelessTerminal) {
|
||||
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
|
||||
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
|
||||
|
||||
+6
-355
@@ -1,58 +1,23 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||
import appeng.helpers.IInterfaceTerminalSupport;
|
||||
import appeng.helpers.InterfaceTerminalSupportedClassProvider;
|
||||
import appeng.container.implementations.ContainerInterfaceTerminal;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorIInventory;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
import appeng.util.inv.WrapperInvSlot;
|
||||
|
||||
public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
|
||||
/**
|
||||
* this stuff is all server side
|
||||
*/
|
||||
private static long autoBase = Long.MIN_VALUE;
|
||||
|
||||
private final Multimap<IInterfaceTerminalSupport, InvTracker> supportedInterfaces = HashMultimap.create();
|
||||
private final Map<Long, InvTracker> byId = new HashMap<>();
|
||||
private IGrid grid;
|
||||
private NBTTagCompound data = new NBTTagCompound();
|
||||
ContainerInterfaceTerminal delegateContainer;
|
||||
|
||||
public ContainerInterfaceWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
|
||||
super(ip, monitorable);
|
||||
if (Platform.isServer()) {
|
||||
this.grid = monitorable.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
delegateContainer = new ContainerInterfaceTerminal(ip, monitorable);
|
||||
|
||||
this.bindPlayerInventory(ip, 14, 0);
|
||||
}
|
||||
@@ -64,330 +29,16 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (this.grid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
boolean missing = false;
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
if (host != null) {
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if (agn != null && agn.isActive()) {
|
||||
for (var clz : InterfaceTerminalSupportedClassProvider.getSupportedClasses()) {
|
||||
for (final IGridNode gn : this.grid.getMachines(clz)) {
|
||||
final IInterfaceTerminalSupport interfaceTerminalSupport = (IInterfaceTerminalSupport) gn
|
||||
.getMachine();
|
||||
if (!gn.isActive() || !interfaceTerminalSupport.shouldDisplay()) continue;
|
||||
|
||||
final Collection<InvTracker> t = supportedInterfaces.get(interfaceTerminalSupport);
|
||||
final String name = interfaceTerminalSupport.getName();
|
||||
missing = t.isEmpty() || t.stream().anyMatch(it -> !it.unlocalizedName.equals(name));
|
||||
total += interfaceTerminalSupport.getPatternsConfigurations().length;
|
||||
if (missing) break;
|
||||
}
|
||||
// we can stop if any is missing. The value of `total` is not important if `missing == true`
|
||||
if (missing) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total != this.supportedInterfaces.size() || missing) {
|
||||
this.regenList(this.data);
|
||||
} else {
|
||||
for (final ContainerInterfaceWireless.InvTracker inv : supportedInterfaces.values()) {
|
||||
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
|
||||
if (this.isDifferent(inv.server.getStackInSlot(inv.offset + x), inv.client.getStackInSlot(x))) {
|
||||
this.addItems(this.data, inv, x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.data.hasNoTags()) {
|
||||
try {
|
||||
NetworkHandler.instance
|
||||
.sendTo(new PacketCompressedNBT(this.data), (EntityPlayerMP) this.getPlayerInv().player);
|
||||
} catch (final IOException ignored) {}
|
||||
|
||||
this.data = new NBTTagCompound();
|
||||
}
|
||||
delegateContainer.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slot, final long id) {
|
||||
final ContainerInterfaceWireless.InvTracker inv = this.byId.get(id);
|
||||
if (inv != null) {
|
||||
final ItemStack is = inv.server.getStackInSlot(slot + inv.offset);
|
||||
final boolean hasItemInHand = player.inventory.getItemStack() != null;
|
||||
|
||||
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
|
||||
|
||||
final WrapperInvSlot slotInv = new ContainerInterfaceWireless.PatternInvSlot(inv.server);
|
||||
|
||||
final IInventory theSlot = slotInv.getWrapper(slot + inv.offset);
|
||||
final InventoryAdaptor interfaceSlot = new AdaptorIInventory(theSlot);
|
||||
|
||||
IInventory interfaceHandler = inv.server;
|
||||
boolean canInsert = true;
|
||||
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN -> {
|
||||
if (hasItemInHand) {
|
||||
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
|
||||
if (Platform.isSameItemPrecise(
|
||||
interfaceHandler.getStackInSlot(s),
|
||||
player.inventory.getItemStack())) {
|
||||
canInsert = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (canInsert) {
|
||||
ItemStack inSlot = theSlot.getStackInSlot(0);
|
||||
if (inSlot == null) {
|
||||
player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack()));
|
||||
} else {
|
||||
inSlot = inSlot.copy();
|
||||
final ItemStack inHand = player.inventory.getItemStack().copy();
|
||||
|
||||
theSlot.setInventorySlotContents(0, null);
|
||||
player.inventory.setItemStack(null);
|
||||
|
||||
player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy()));
|
||||
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
player.inventory.setItemStack(inSlot);
|
||||
} else {
|
||||
player.inventory.setItemStack(inHand);
|
||||
theSlot.setInventorySlotContents(0, inSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
|
||||
mySlot.setInventorySlotContents(0, playerHand.addItems(mySlot.getStackInSlot(0)));
|
||||
}
|
||||
}
|
||||
case SPLIT_OR_PLACE_SINGLE -> {
|
||||
if (hasItemInHand) {
|
||||
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
|
||||
if (Platform.isSameItemPrecise(
|
||||
interfaceHandler.getStackInSlot(s),
|
||||
player.inventory.getItemStack())) {
|
||||
canInsert = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (canInsert) {
|
||||
ItemStack extra = playerHand.removeItems(1, null, null);
|
||||
if (extra != null && !interfaceSlot.containsItems()) {
|
||||
extra = interfaceSlot.addItems(extra);
|
||||
}
|
||||
if (extra != null) {
|
||||
playerHand.addItems(extra);
|
||||
}
|
||||
}
|
||||
} else if (is != null) {
|
||||
ItemStack extra = interfaceSlot.removeItems((is.stackSize + 1) / 2, null, null);
|
||||
if (extra != null) {
|
||||
extra = playerHand.addItems(extra);
|
||||
}
|
||||
if (extra != null) {
|
||||
interfaceSlot.addItems(extra);
|
||||
}
|
||||
}
|
||||
}
|
||||
case SHIFT_CLICK -> {
|
||||
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
|
||||
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
mySlot.setInventorySlotContents(0, mergeToPlayerInventory(playerInv, mySlot.getStackInSlot(0)));
|
||||
}
|
||||
case MOVE_REGION -> {
|
||||
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
|
||||
inv.server.setInventorySlotContents(
|
||||
x + inv.offset,
|
||||
mergeToPlayerInventory(playerInvAd, inv.server.getStackInSlot(x + inv.offset)));
|
||||
}
|
||||
}
|
||||
case CREATIVE_DUPLICATE -> {
|
||||
if (player.capabilities.isCreativeMode && !hasItemInHand) {
|
||||
player.inventory.setItemStack(is == null ? null : is.copy());
|
||||
}
|
||||
}
|
||||
default -> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack) {
|
||||
if (stack == null) return null;
|
||||
for (ItemSlot slot : playerInv) {
|
||||
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
|
||||
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
|
||||
++slot.getItemStack().stackSize;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return playerInv.addItems(stack);
|
||||
}
|
||||
|
||||
private void regenList(final NBTTagCompound data) {
|
||||
this.byId.clear();
|
||||
this.supportedInterfaces.clear();
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
if (host != null) {
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if (agn != null && agn.isActive()) {
|
||||
for (var clz : InterfaceTerminalSupportedClassProvider.getSupportedClasses()) {
|
||||
for (final IGridNode gn : this.grid.getMachines(clz)) {
|
||||
final IInterfaceTerminalSupport terminalSupport = (IInterfaceTerminalSupport) gn.getMachine();
|
||||
if (!gn.isActive() || !terminalSupport.shouldDisplay()) continue;
|
||||
|
||||
final var configurations = terminalSupport.getPatternsConfigurations();
|
||||
|
||||
for (int i = 0; i < configurations.length; ++i) {
|
||||
this.supportedInterfaces.put(
|
||||
terminalSupport,
|
||||
new ContainerInterfaceWireless.InvTracker(terminalSupport, configurations[i], i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.setBoolean("clear", true);
|
||||
|
||||
for (final ContainerInterfaceWireless.InvTracker inv : this.supportedInterfaces.values()) {
|
||||
this.byId.put(inv.which, inv);
|
||||
this.addItems(data, inv, 0, inv.client.getSizeInventory());
|
||||
}
|
||||
delegateContainer.doAction(player, action, slot, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isWirelessTerminal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isDifferent(final ItemStack a, final ItemStack b) {
|
||||
if (a == null && b == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a == null || b == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !ItemStack.areItemStacksEqual(a, b);
|
||||
}
|
||||
|
||||
private void addItems(final NBTTagCompound data, final ContainerInterfaceWireless.InvTracker inv, final int offset,
|
||||
final int length) {
|
||||
final String name = '=' + Long.toString(inv.which, Character.MAX_RADIX);
|
||||
final NBTTagCompound tag = data.getCompoundTag(name);
|
||||
|
||||
if (tag.hasNoTags()) {
|
||||
tag.setLong("sortBy", inv.sortBy);
|
||||
tag.setString("un", inv.unlocalizedName);
|
||||
tag.setInteger("x", inv.X);
|
||||
tag.setInteger("y", inv.Y);
|
||||
tag.setInteger("z", inv.Z);
|
||||
tag.setInteger("dim", inv.dim);
|
||||
tag.setInteger("side", inv.side.ordinal());
|
||||
tag.setInteger("size", inv.client.getSizeInventory());
|
||||
}
|
||||
|
||||
for (int x = 0; x < length; x++) {
|
||||
final NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
|
||||
final ItemStack is = inv.server.getStackInSlot(x + offset + inv.offset);
|
||||
|
||||
// "update" client side.
|
||||
inv.client.setInventorySlotContents(offset + x, is == null ? null : is.copy());
|
||||
|
||||
if (is != null) {
|
||||
is.writeToNBT(itemNBT);
|
||||
}
|
||||
|
||||
tag.setTag(Integer.toString(x + offset), itemNBT);
|
||||
}
|
||||
|
||||
data.setTag(name, tag);
|
||||
}
|
||||
|
||||
private static class InvTracker {
|
||||
|
||||
private final long sortBy;
|
||||
private final long which = autoBase++;
|
||||
private final String unlocalizedName;
|
||||
private final IInventory client;
|
||||
private final IInventory server;
|
||||
private final int offset;
|
||||
private final int X;
|
||||
private final int Y;
|
||||
private final int Z;
|
||||
private final int dim;
|
||||
private final ForgeDirection side;
|
||||
|
||||
public InvTracker(final DimensionalCoord coord, long sortValue, final IInventory patterns,
|
||||
final String unlocalizedName, int offset, int size, ForgeDirection side) {
|
||||
this(
|
||||
coord.x,
|
||||
coord.y,
|
||||
coord.z,
|
||||
coord.getDimension(),
|
||||
sortValue,
|
||||
patterns,
|
||||
unlocalizedName,
|
||||
offset,
|
||||
size,
|
||||
side);
|
||||
}
|
||||
|
||||
public InvTracker(int x, int y, int z, int dim, long sortValue, final IInventory patterns,
|
||||
final String unlocalizedName, int offset, int size, ForgeDirection side) {
|
||||
this.server = patterns;
|
||||
this.client = new AppEngInternalInventory(null, size);
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.sortBy = sortValue + offset << 16;
|
||||
this.offset = offset;
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Z = z;
|
||||
this.dim = dim;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public InvTracker(IInterfaceTerminalSupport terminalSupport,
|
||||
IInterfaceTerminalSupport.PatternsConfiguration configuration, int index) {
|
||||
this(
|
||||
terminalSupport.getLocation(),
|
||||
terminalSupport.getSortValue(),
|
||||
terminalSupport.getPatterns(index),
|
||||
terminalSupport.getName(),
|
||||
configuration.offset,
|
||||
configuration.size,
|
||||
terminalSupport instanceof AEBasePart ? ((AEBasePart) terminalSupport).getSide()
|
||||
: ForgeDirection.UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PatternInvSlot extends WrapperInvSlot {
|
||||
|
||||
public PatternInvSlot(final IInventory inv) {
|
||||
super(inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack itemstack) {
|
||||
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
+108
-3
@@ -1,16 +1,25 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
|
||||
@@ -37,15 +46,111 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
return this.requestSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
|
||||
Slot slot = getSlot(slotId);
|
||||
if (slot instanceof SlotFluidConvertingFake) {
|
||||
final ItemStack stack = player.inventory.getItemStack();
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN -> {
|
||||
if (stack == null) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
((SlotFluidConvertingFake) slot).putConvertedStack(createLevelValues(stack.copy()));
|
||||
}
|
||||
}
|
||||
case PLACE_SINGLE -> {
|
||||
if (stack != null) {
|
||||
((SlotFluidConvertingFake) slot).putConvertedStack(
|
||||
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
|
||||
}
|
||||
}
|
||||
case SPLIT_OR_PLACE_SINGLE -> {
|
||||
ItemStack inSlot = slot.getStack();
|
||||
if (inSlot != null) {
|
||||
if (stack == null) {
|
||||
slot.putStack(
|
||||
createLevelValues(
|
||||
Objects.requireNonNull(
|
||||
Util.copyStackWithSize(
|
||||
inSlot,
|
||||
Math.max(1, inSlot.stackSize - 1)))));
|
||||
} else if (stack.isItemEqual(inSlot)) {
|
||||
slot.putStack(
|
||||
createLevelValues(
|
||||
Objects.requireNonNull(
|
||||
Util.copyStackWithSize(
|
||||
inSlot,
|
||||
Math.min(
|
||||
inSlot.getMaxStackSize(),
|
||||
inSlot.stackSize + 1)))));
|
||||
} else {
|
||||
((SlotFluidConvertingFake) slot).putConvertedStack(
|
||||
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
|
||||
}
|
||||
} else if (stack != null) {
|
||||
((SlotFluidConvertingFake) slot).putConvertedStack(
|
||||
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.doAction(player, action, slotId, id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int idx) {
|
||||
for (SlotFluidConvertingFake slot : this.getRequestSlots()) {
|
||||
if (Platform.isClient()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.getRequestSlots().length; i++) {
|
||||
SlotFluidConvertingFake slot = this.getRequestSlots()[i];
|
||||
if (!slot.getHasStack()) {
|
||||
slot.setAeStack(AEItemStack.create(((Slot) this.inventorySlots.get(idx)).getStack()), true);
|
||||
ItemStack itemStack = ((Slot) this.inventorySlots.get(idx)).getStack();
|
||||
ItemStack configuration = createLevelValues(itemStack.copy());
|
||||
configuration.getTagCompound().setInteger(TLMTags.Index.tagName, i);
|
||||
slot.putConvertedStack(configuration);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public static ItemStack createLevelValues(ItemStack itemStack) {
|
||||
var data = itemStack.hasTagCompound() ? itemStack.getTagCompound() : new NBTTagCompound();
|
||||
if (!data.hasKey(TLMTags.Stack.tagName)) {
|
||||
var itemStackTag = new NBTTagCompound();
|
||||
itemStack.copy().writeToNBT(itemStackTag);
|
||||
data.setTag(TLMTags.Stack.tagName, itemStackTag);
|
||||
}
|
||||
if (!data.hasKey(TLMTags.Quantity.tagName)) {
|
||||
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize > 0 ? itemStack.stackSize : 1);
|
||||
}
|
||||
if (!data.hasKey(TLMTags.Batch.tagName)) {
|
||||
data.setLong(TLMTags.Batch.tagName, 1);
|
||||
}
|
||||
if (!data.hasKey(TLMTags.Enable.tagName)) {
|
||||
data.setBoolean(TLMTags.Enable.tagName, false);
|
||||
}
|
||||
if (data.hasKey(TLMTags.Index.tagName)) {
|
||||
data.removeTag(TLMTags.Index.tagName);
|
||||
}
|
||||
|
||||
data.setInteger(TLMTags.State.tagName, State.None.ordinal());
|
||||
itemStack.setTagCompound(data);
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,406 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.api.registries.ILevelViewable;
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
|
||||
public class ContainerLevelTerminal extends FCBaseContainer {
|
||||
|
||||
/**
|
||||
* this stuff is all server side
|
||||
*/
|
||||
private int nextId = 0;
|
||||
|
||||
private final Map<IGridHost, ContainerLevelTerminal.InvTracker> tracked = new HashMap<>();
|
||||
private final Map<Long, ContainerLevelTerminal.InvTracker> trackedById = new HashMap<>();
|
||||
|
||||
private IGrid grid;
|
||||
private SPacketLevelTerminalUpdate dirty;
|
||||
private boolean isDirty;
|
||||
private boolean wasOff;
|
||||
private int ticks = 0;
|
||||
|
||||
public ContainerLevelTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
if (Platform.isServer()) {
|
||||
if (monitorable instanceof PartLevelTerminal terminal) {
|
||||
grid = terminal.getActionableNode().getGrid();
|
||||
} else if (monitorable instanceof IWirelessTerminal wirelessTerminal) {
|
||||
grid = wirelessTerminal.getActionableNode().getGrid();
|
||||
}
|
||||
dirty = this.updateList();
|
||||
if (dirty != null) {
|
||||
this.isDirty = true;
|
||||
} else {
|
||||
dirty = new SPacketLevelTerminalUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
this.bindPlayerInventory(ip, 14, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (this.grid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
|
||||
if (!host.getActionableNode().isActive()) {
|
||||
if (!wasOff) {
|
||||
SPacketLevelTerminalUpdate update = new SPacketLevelTerminalUpdate();
|
||||
|
||||
update.setDisconnect();
|
||||
wasOff = true;
|
||||
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
wasOff = false;
|
||||
|
||||
if (isDirty) {
|
||||
FluidCraft.proxy.netHandler.sendTo(dirty, (EntityPlayerMP) this.getPlayerInv().player);
|
||||
dirty = new SPacketLevelTerminalUpdate();
|
||||
isDirty = false;
|
||||
} else if (++ticks % 20 == 0) {
|
||||
ticks = 0;
|
||||
SPacketLevelTerminalUpdate update = this.updateList();
|
||||
if (update != null) {
|
||||
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge from slot -> player inv. Returns the items not added.
|
||||
*/
|
||||
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack) {
|
||||
if (stack == null) return null;
|
||||
for (ItemSlot slot : playerInv) {
|
||||
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
|
||||
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
|
||||
++slot.getItemStack().stackSize;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return playerInv.addItems(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slotIdx, final long id) {
|
||||
final ContainerLevelTerminal.InvTracker invTracker = this.trackedById.get(id);
|
||||
if (invTracker != null) {
|
||||
final ItemStack handStack = player.inventory.getItemStack();
|
||||
|
||||
if (handStack != null && !(handStack.getItem() instanceof ItemEncodedPattern)) {
|
||||
// Why even bother if we're not dealing with an encoded pattern in hand
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack slotStack = invTracker.requests.getStackInSlot(slotIdx);
|
||||
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
|
||||
|
||||
switch (action) {
|
||||
/* Set down/pickup. This is the same as SPLIT_OR_PLACE_SINGLE as our max stack sizes are 1 in slots. */
|
||||
case PICKUP_OR_SET_DOWN -> {
|
||||
if (handStack != null) {
|
||||
for (int s = 0; s < invTracker.requests.getSizeInventory(); s++) {
|
||||
/* Is there a duplicate pattern here? */
|
||||
if (Platform.isSameItemPrecise(invTracker.requests.getStackInSlot(s), handStack)) {
|
||||
/* We're done here - dupe found. */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slotStack == null) {
|
||||
/* Insert to container, if valid */
|
||||
if (handStack == null) {
|
||||
/* Nothing happens */
|
||||
return;
|
||||
}
|
||||
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
|
||||
} else {
|
||||
/* Exchange? */
|
||||
if (handStack != null && handStack.stackSize > 1) {
|
||||
/* Exchange is impossible, abort */
|
||||
return;
|
||||
}
|
||||
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
|
||||
playerHand.addItems(slotStack.copy());
|
||||
}
|
||||
syncLevelTerminalSlot(invTracker, id, slotIdx, invTracker.requests.getStackInSlot(slotIdx));
|
||||
}
|
||||
/* Shift click from slotIdx -> player. Player -> slotIdx is not supported. */
|
||||
case SHIFT_CLICK -> {
|
||||
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player.inventory, ForgeDirection.UNKNOWN);
|
||||
ItemStack leftOver = mergeToPlayerInventory(playerInv, slotStack);
|
||||
|
||||
if (leftOver == null) {
|
||||
invTracker.requests.setInventorySlotContents(slotIdx, null);
|
||||
syncLevelTerminalSlot(invTracker, id, slotIdx, null);
|
||||
}
|
||||
}
|
||||
/* Move all blank patterns -> player */
|
||||
case MOVE_REGION -> {
|
||||
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
List<Integer> valid = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < invTracker.requests.getSizeInventory(); i++) {
|
||||
ItemStack toExtract = invTracker.requests.getStackInSlot(i);
|
||||
|
||||
if (toExtract == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack leftOver = mergeToPlayerInventory(playerInv, toExtract);
|
||||
|
||||
if (leftOver != null) {
|
||||
break;
|
||||
} else {
|
||||
invTracker.requests.setInventorySlotContents(i, null);
|
||||
}
|
||||
valid.add(i);
|
||||
}
|
||||
if (!valid.isEmpty()) {
|
||||
int[] validIndices = Ints.toArray(valid);
|
||||
NBTTagList tag = new NBTTagList();
|
||||
for (int i = 0; i < valid.size(); ++i) {
|
||||
tag.appendTag(new NBTTagCompound());
|
||||
}
|
||||
dirty.addOverwriteEntry(id).setItems(validIndices, tag);
|
||||
isDirty = true;
|
||||
}
|
||||
}
|
||||
case CREATIVE_DUPLICATE -> {
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
playerHand.addItems(handStack);
|
||||
}
|
||||
}
|
||||
default -> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncLevelTerminalSlot(ContainerLevelTerminal.InvTracker inv, long id, int slot, ItemStack stack) {
|
||||
int[] validIndices = { slot };
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
}
|
||||
list.appendTag(item);
|
||||
inv.updateNBT();
|
||||
this.dirty.addOverwriteEntry(id).setItems(validIndices, list);
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
private SPacketLevelTerminalUpdate updateList() {
|
||||
SPacketLevelTerminalUpdate update = null;
|
||||
var supported = LevelTerminalRegistry.instance().getSupportedClasses();
|
||||
Set<IGridHost> visited = new HashSet<>();
|
||||
|
||||
for (Class<? extends ILevelViewable> clz : supported) {
|
||||
boolean isAdopted = LevelTerminalRegistry.instance().isAdopted(clz);
|
||||
Class<? extends IGridHost> machineClass = isAdopted ? LevelTerminalRegistry.instance().getAdopted(clz)
|
||||
: clz;
|
||||
for (IGridNode gridNode : grid.getMachines(machineClass)) {
|
||||
final IGridHost gridHost = gridNode.getMachine();
|
||||
final ILevelViewable machine = isAdopted
|
||||
? LevelTerminalRegistry.instance().getAdapter(clz).adapt(gridHost)
|
||||
: (ILevelViewable) gridHost;
|
||||
|
||||
/* First check if we are already tracking this node */
|
||||
if (tracked.containsKey(gridHost)) {
|
||||
/* Check for updates */
|
||||
ContainerLevelTerminal.InvTracker knownTracker = tracked.get(gridHost);
|
||||
|
||||
/* Name changed? */
|
||||
String name = machine.getCustomName();
|
||||
|
||||
if (!Objects.equals(knownTracker.name, name)) {
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
update.addRenamedEntry(knownTracker.id, name);
|
||||
knownTracker.name = name;
|
||||
}
|
||||
|
||||
/* Status changed? */
|
||||
boolean isActive = gridNode.isActive() || machine.shouldDisplay();
|
||||
|
||||
if (!knownTracker.online && isActive) {
|
||||
/* Node offline -> online */
|
||||
knownTracker.online = true;
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
knownTracker.updateNBT();
|
||||
update.addOverwriteEntry(knownTracker.id).setOnline(true)
|
||||
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
|
||||
} else if (knownTracker.online && !isActive) {
|
||||
/* Node online -> offline */
|
||||
knownTracker.online = false;
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
update.addOverwriteEntry(knownTracker.id).setOnline(false);
|
||||
}
|
||||
|
||||
for (int i = 0; i < knownTracker.requests.getSizeInventory(); i++) {
|
||||
ItemStack knowmItemStack = ItemStack
|
||||
.loadItemStackFromNBT(knownTracker.inventoryNbt.getCompoundTagAt(i));
|
||||
ItemStack machineItemStack = machine.getInventoryByName("config").getStackInSlot(i);
|
||||
if (isDifferent(knowmItemStack, machineItemStack)) {
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
knownTracker.updateNBT();
|
||||
update.addOverwriteEntry(knownTracker.id)
|
||||
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Add a new entry */
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
ContainerLevelTerminal.InvTracker entry = new ContainerLevelTerminal.InvTracker(
|
||||
nextId++,
|
||||
machine,
|
||||
gridNode.isActive());
|
||||
update.addNewEntry(entry.id, entry.name, entry.online)
|
||||
.setLocation(entry.x, entry.y, entry.z, entry.dim, entry.side.ordinal())
|
||||
.setItems(entry.rows, entry.rowSize, entry.inventoryNbt)
|
||||
.setViewItemStack(machine.getSelfItemStack(), machine.getDisplayItemStack());
|
||||
tracked.put(gridHost, entry);
|
||||
trackedById.put(entry.id, entry);
|
||||
}
|
||||
visited.add(gridHost);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now find any entries that we need to remove */
|
||||
Iterator<Map.Entry<IGridHost, ContainerLevelTerminal.InvTracker>> it = tracked.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
var entry = it.next();
|
||||
if (visited.contains(entry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
|
||||
trackedById.remove(entry.getValue().id);
|
||||
it.remove();
|
||||
update.addRemovalEntry(entry.getValue().id);
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isWirelessTerminal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isDifferent(final ItemStack a, final ItemStack b) {
|
||||
if (a == null && b == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a == null || b == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !ItemStack.areItemStacksEqual(a, b);
|
||||
}
|
||||
|
||||
private static class InvTracker {
|
||||
|
||||
private final long id;
|
||||
private String name;
|
||||
private final IInventory requests;
|
||||
private final int rowSize;
|
||||
private final int rows;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private final int dim;
|
||||
private final ForgeDirection side;
|
||||
private boolean online;
|
||||
private NBTTagList inventoryNbt;
|
||||
|
||||
public InvTracker(long id, ILevelViewable machine, boolean online) {
|
||||
|
||||
DimensionalCoord location = machine.getLocation();
|
||||
|
||||
this.id = id;
|
||||
this.name = machine.getCustomName();
|
||||
this.requests = machine.getInventoryByName("config");
|
||||
this.rowSize = machine.rowSize();
|
||||
this.rows = machine.rows();
|
||||
this.x = location.x;
|
||||
this.y = location.y;
|
||||
this.z = location.z;
|
||||
this.dim = location.getDimension();
|
||||
this.side = machine.getSide();
|
||||
this.online = online;
|
||||
this.inventoryNbt = new NBTTagList();
|
||||
updateNBT();
|
||||
}
|
||||
|
||||
private void updateNBT() {
|
||||
this.inventoryNbt = new NBTTagList();
|
||||
for (int i = 0; i < this.rows; ++i) {
|
||||
for (int j = 0; j < this.rowSize; ++j) {
|
||||
final int offset = this.rowSize * i;
|
||||
ItemStack stack = this.requests.getStackInSlot(offset + j);
|
||||
|
||||
if (stack != null) {
|
||||
this.inventoryNbt.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||
} else {
|
||||
this.inventoryNbt.appendTag(new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
public class ContainerLevelWireless extends ContainerLevelTerminal {
|
||||
|
||||
public ContainerLevelWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
|
||||
super(ip, monitorable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isWirelessTerminal() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,9 @@ public enum FCPartsTexture {
|
||||
PartFluidPatternTerminal_Bright("pattern_terminal_bright"),
|
||||
PartFluidPatternTerminal_Dark("pattern_terminal_dark"),
|
||||
PartFluidPatternTerminal_Colored("pattern_terminal_medium"),
|
||||
PartLevelTerminal_Bright("level_terminal_bright"),
|
||||
PartLevelTerminal_Dark("level_terminal_dark"),
|
||||
PartLevelTerminal_Colored("level_terminal_medium"),
|
||||
PartTerminalBroad("terminal_broad"),
|
||||
PartFluidImportBus("fluid_import_face"),
|
||||
PartFluidExportBus("fluid_export_face"),
|
||||
|
||||
Reference in new issue
Block a user