This commit is contained in:
NotMyWing
2025-03-28 14:29:08 +11:00
parent ad8b7aa7bd
commit 1d1205412c
8 changed files with 96 additions and 12 deletions
@@ -44,5 +44,6 @@ public enum ActionItems
TOGGLE_SHOW_FULL_INTERFACES_OFF,
TOGGLE_SHOW_ONLY_INVALID_PATTERNS_ON,
TOGGLE_SHOW_ONLY_INVALID_PATTERNS_OFF,
HIGHLIGHT_INTERFACE
HIGHLIGHT_INTERFACE,
CONFIGURE_INTERFACE
}
@@ -38,6 +38,8 @@ import appeng.core.AppEng;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigureInterface;
import appeng.helpers.DualityInterface;
import appeng.helpers.PatternHelper;
import appeng.helpers.WirelessTerminalGuiObject;
@@ -285,10 +287,14 @@ public class GuiInterfaceTerminal extends AEBaseGui {
for (int x = 0; x < rows && linesDraw < rows && currentScroll + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(currentScroll + x);
if (lineObj instanceof ClientDCInternalInv inv) {
GuiButton highlightBtn = new GuiImgButton(guiLeft + 4, guiTop + offset + 1, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE);
guiButtonHashMap.put(highlightBtn, inv);
this.buttonList.add(highlightBtn);
GuiButton guiButton = new GuiImgButton(guiLeft + 4, guiTop + offset + 1, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE);
guiButtonHashMap.put(guiButton, inv);
this.buttonList.add(guiButton);
GuiButton configBtn = new GuiImgButton(guiLeft + 4, guiTop + offset + 1 - 16, Settings.ACTIONS, ActionItems.CONFIGURE_INTERFACE);
guiButtonHashMap.put(configBtn, inv);
this.buttonList.add(configBtn);
final int extraLines = numUpgradesMap.get(inv);
for (int row = 0; row < 1 + extraLines && linesDraw < rows; ++row) {
@@ -323,11 +329,12 @@ public class GuiInterfaceTerminal extends AEBaseGui {
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
if (guiButtonHashMap.containsKey(btn)) {
BlockPos blockPos = blockPosHashMap.get(guiButtonHashMap.get(this.selectedButton));
if (guiButtonHashMap.containsKey(btn) && btn instanceof GuiImgButton guiImgButton) {
ClientDCInternalInv inv = guiButtonHashMap.get(this.selectedButton);
BlockPos blockPos = blockPosHashMap.get(inv);
BlockPos blockPos2 = mc.player.getPosition();
int playerDim = mc.world.provider.getDimension();
int interfaceDim = dimHashMap.get(guiButtonHashMap.get(this.selectedButton));
int interfaceDim = dimHashMap.get(inv);
if (playerDim != interfaceDim) {
try {
mc.player.sendStatusMessage(PlayerMessages.InterfaceInOtherDimParam.get(interfaceDim, DimensionManager.getWorld(interfaceDim).provider.getDimensionType().getName()), false);
@@ -335,10 +342,14 @@ public class GuiInterfaceTerminal extends AEBaseGui {
mc.player.sendStatusMessage(PlayerMessages.InterfaceInOtherDim.get(), false);
}
} else {
if (guiImgButton.getCurrentValue() == ActionItems.HIGHLIGHT_INTERFACE) {
hilightBlock(blockPos, System.currentTimeMillis() + 500 * BlockPosUtils.getDistance(blockPos, blockPos2), playerDim);
mc.player.sendStatusMessage(PlayerMessages.InterfaceHighlighted.get(blockPos.getX(), blockPos.getY(), blockPos.getZ()), false);
}
mc.player.closeScreen();
} else if (guiImgButton.getCurrentValue() == ActionItems.CONFIGURE_INTERFACE) {
NetworkHandler.instance.sendToServer(new PacketConfigureInterface(inv.getId()));
}
}
} else if (btn == guiButtonHideFull) {
onlyShowWithSpace = !onlyShowWithSpace;
this.refreshList();
@@ -465,8 +476,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
this.refreshList = true;
}
for (final Object oKey : in.getKeySet()) {
final String key = (String) oKey;
for (final String key : in.getKeySet()) {
if (key.startsWith("=")) {
try {
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
@@ -121,6 +121,7 @@ public class GuiImgButton extends GuiButton implements ITooltip {
this.registerApp(8 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF, ButtonToolTips.ToggleShowFullInterfaces, ButtonToolTips.ToggleShowFullInterfacesOffDesc);
this.registerApp(9 + 5 * 16, Settings.ACTIONS, ActionItems.MOLECULAR_ASSEMBLERS_OFF, ButtonToolTips.ToggleMolecularAssemblers, ButtonToolTips.ToggleMolecularAssemblersOffDesc);
this.registerApp(6 + 6 * 16, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE, ButtonToolTips.HighlightInterface, "");
this.registerApp(66, Settings.ACTIONS, ActionItems.CONFIGURE_INTERFACE, ButtonToolTips.ConfigureInterface, "");
this.registerApp(4 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERNS_OFF, ButtonToolTips.ToggleShowOnlyInvalidInterface, ButtonToolTips.ToggleShowOnlyInvalidInterfaceOffDesc);
this.registerApp(5 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERNS_ON, ButtonToolTips.ToggleShowOnlyInvalidInterface, ButtonToolTips.ToggleShowOnlyInvalidInterfaceOnDesc);
@@ -192,6 +192,15 @@ public class ContainerInterfaceTerminal extends AEBaseContainer {
}
}
public DualityInterface getById(long id) {
var tracker = this.byId.get(id);
if (tracker == null) {
return null;
}
return tracker.getDualityInterface();
}
@Override
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slot, final long id) {
final InvTracker inv = this.byId.get(id);
@@ -428,8 +437,10 @@ public class ContainerInterfaceTerminal extends AEBaseContainer {
private final BlockPos pos;
private final int dim;
private final int numUpgrades;
private final DualityInterface dualityInterface;
public InvTracker(final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName) {
this.dualityInterface = dual;
this.server = patterns;
this.client = new AppEngInternalInventory(null, this.server.getSlots());
this.unlocalizedName = unlocalizedName;
@@ -438,6 +449,10 @@ public class ContainerInterfaceTerminal extends AEBaseContainer {
this.dim = dual.getLocation().getWorld().provider.getDimension();
this.numUpgrades = dual.getInstalledUpgrades(Upgrades.PATTERN_EXPANSION);
}
public DualityInterface getDualityInterface() {
return dualityInterface;
}
}
private static class PatternSlotFilter implements IAEItemFilter {
@@ -168,6 +168,8 @@ public enum ButtonToolTips {
ToggleShowOnlyInvalidInterfaceOffDesc,
HighlightInterface,
HighlightInterfaceDesc,
ConfigureInterface,
ConfigureInterfaceDesc,
SearchFieldInputs,
SearchFieldOutputs,
SearchFieldNames,
@@ -92,6 +92,8 @@ public class AppEngPacketHandlerBase {
PACKET_CABLE_BUS_LANDING_PARTICLE(PacketCableBusLandingParticle.class),
PACKET_CONFIGURE_INTERFACE(PacketConfigureInterface.class),
;
@@ -0,0 +1,52 @@
package appeng.core.sync.packets;
import appeng.api.util.AEPartLocation;
import appeng.container.implementations.ContainerInterfaceTerminal;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.helpers.IPriorityHost;
import appeng.parts.AEBasePart;
import appeng.util.Platform;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayer;
public class PacketConfigureInterface extends AppEngPacket {
private final long id;
// automatic.
public PacketConfigureInterface(final ByteBuf stream) {
this.id = stream.readLong();
}
// api
public PacketConfigureInterface(final long id) {
this.id = id;
final ByteBuf data = Unpooled.buffer();
data.writeInt(this.getPacketID());
data.writeLong(id);
this.configureWrite(data);
}
@Override
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player) {
var container = player.openContainer;
if (container instanceof ContainerInterfaceTerminal terminal) {
var byId = terminal.getById(this.id);
if (byId != null) {
var host = byId.getHost();
// I don't know why this is in IPriorityHost.
if (host instanceof IPriorityHost guiHandler) {
var bridge = guiHandler.getGuiBridge();
var side = host instanceof AEBasePart part ? part.getSide() : AEPartLocation.INTERNAL;
Platform.openGUI(player, host.getTile(), side, bridge);
}
}
}
}
}
@@ -402,6 +402,7 @@ gui.tooltips.appliedenergistics2.ToggleShowOnlyInvalidInterface=Toggles showing
gui.tooltips.appliedenergistics2.ToggleShowOnlyInvalidInterfaceOffDesc=Showing all interfaces
gui.tooltips.appliedenergistics2.ToggleShowOnlyInvalidInterfaceOnDesc=Showing only interfaces with invalid patterns
gui.tooltips.appliedenergistics2.HighlightInterface=Highlight Interface
gui.tooltips.appliedenergistics2.ConfigureInterface=Configure Interface
gui.tooltips.appliedenergistics2.SearchFieldInputs=Recipe Inputs
gui.tooltips.appliedenergistics2.SearchFieldOutputs=Recipe Outputs
gui.tooltips.appliedenergistics2.SearchFieldNames=Interface Names