Rename interface from interface terminal (#1041)

This commit is contained in:
lc-1337 authored and GitHub committed 2026-01-25 09:20:35 +00:00
1 parent 1b4cbc64dd
commit 2f51e96c77
7 files changed
+98 -8

No files matched your search

@@ -74,6 +74,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInterfaceTerminalUpdate;
import appeng.core.sync.packets.PacketInterfaceTerminalUpdate.PacketEntry;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketRemoteRename;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
@@ -901,7 +902,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
addCmd.rowSize,
addCmd.numSlots,
addCmd.online,
addCmd.p2pOutput).setLocation(addCmd.x, addCmd.y, addCmd.z, addCmd.dim)
addCmd.p2pOutput).setLocation(addCmd.x, addCmd.y, addCmd.z, addCmd.dim, addCmd.side)
.setIcons(addCmd.selfRep, addCmd.dispRep).setItems(addCmd.items);
masterList.addEntry(entry);
} else if (cmd instanceof PacketInterfaceTerminalUpdate.PacketRemove) {
@@ -1339,7 +1340,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
ItemStack dispRep;
InterfaceSection section;
long id;
int x, y, z, dim;
int x, y, z, dim, side;
int rows, rowSize;
int numSlots;
int guiHeight;
@@ -1371,11 +1372,12 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.filteredRecipes = new boolean[rows * rowSize];
}
InterfaceTerminalEntry setLocation(int x, int y, int z, int dim) {
InterfaceTerminalEntry setLocation(int x, int y, int z, int dim, int side) {
this.x = x;
this.y = y;
this.z = z;
this.dim = dim;
this.side = side;
return this;
}
@@ -1499,6 +1501,13 @@ public class GuiInterfaceTerminal extends AEBaseGui
&& mouseY > Math.max(optionsButton.yPosition, InterfaceSection.TITLE_HEIGHT)
&& mouseY <= Math.min(optionsButton.yPosition + optionsButton.height, viewHeight)) {
optionsButton.func_146113_a(mc.getSoundHandler());
if (isShiftKeyDown()) {
NetworkHandler.instance.sendToServer(new PacketRemoteRename(x, y, z, dim, side));
return true;
}
// When using the highlight from the interface terminal, we want it to only
// highlight the interface containing the patterns and not any output p2p interfaces
BlockPosHighlighter.highlightNamedBlocks(
@@ -77,7 +77,6 @@ public class GuiRenamer extends GuiSub implements IDropToFillTextField {
} catch (IOException e) {
AELog.debug(e);
}
this.mc.thePlayer.closeScreen();
} else if (!this.textField.textboxKeyTyped(character, key)) {
super.keyTyped(character, key);
}
@@ -51,6 +51,7 @@ import appeng.core.sync.packets.PacketPatternSlot;
import appeng.core.sync.packets.PacketPatternValueSet;
import appeng.core.sync.packets.PacketPickBlock;
import appeng.core.sync.packets.PacketPinsUpdate;
import appeng.core.sync.packets.PacketRemoteRename;
import appeng.core.sync.packets.PacketSwapSlots;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketTransitionEffect;
@@ -130,7 +131,8 @@ public class AppEngPacketHandlerBase {
PACKET_PICK_BLOCK(PacketPickBlock.class),
PACKET_MONITORABLE_ACTION(PacketMonitorableAction.class),
PACKET_VIRTUAL_SLOT(PacketVirtualSlot.class),
PACKET_COLOR_SELECT(PacketColorSelect.class);
PACKET_COLOR_SELECT(PacketColorSelect.class),
PACKET_REMOTE_RENAME(PacketRemoteRename.class);
private final Class<? extends AppEngPacket> packetClass;
private final Constructor<? extends AppEngPacket> packetConstructor;
@@ -0,0 +1,65 @@
package appeng.core.sync.packets;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.container.AEBaseContainer;
import appeng.container.PrimaryGui;
import appeng.container.interfaces.IContainerSubGui;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.INetworkInfo;
import appeng.helpers.ICustomNameObject;
import appeng.util.Platform;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
public class PacketRemoteRename extends AppEngPacket {
int x, y, z, dim, side;
public PacketRemoteRename(final ByteBuf stream) {
this.x = stream.readInt();
this.y = stream.readInt();
this.z = stream.readInt();
this.dim = stream.readInt();
this.side = stream.readInt();
}
public PacketRemoteRename(int x, int y, int z, int dim, int side) {
final ByteBuf data = Unpooled.buffer();
data.writeInt(this.getPacketID());
data.writeInt(x);
data.writeInt(y);
data.writeInt(z);
data.writeInt(dim);
data.writeInt(side);
this.configureWrite(data);
}
@Override
public void serverPacketData(final INetworkInfo manager, final AppEngPacket packet, final EntityPlayer player) {
final Container c = player.openContainer;
if (c instanceof AEBaseContainer bc && player.dimension == this.dim) {
TileEntity te = player.worldObj.getTileEntity(this.x, this.y, this.z);
if (te instanceof ICustomNameObject) {
Platform.openGUI(
player,
te,
ForgeDirection.getOrientation(this.side),
GuiBridge.GUI_RENAMER,
bc.getTargetSlotIndex());
}
if (player.openContainer instanceof IContainerSubGui sg) {
final PrimaryGui pGui = bc.createPrimaryGui();
sg.setPrimaryGui(pGui);
}
}
}
}
@@ -121,6 +121,8 @@ public class PacketValueConfig extends AppEngPacket {
final PrimaryGui pGui = qk.getPrimaryGui();
if (pGui != null) {
pGui.open(player);
} else {
player.closeScreen();
}
} else if (this.Name.equals("TileSecurity.ToggleOption") && c instanceof ContainerSecurity sc) {
sc.toggleSetting(this.Value, player);
@@ -20,11 +20,12 @@ import appeng.container.interfaces.IInventorySlotAware;
import appeng.helpers.ICustomButtonDataObject;
import appeng.helpers.ICustomButtonProvider;
import appeng.helpers.ICustomButtonSource;
import appeng.helpers.IPrimaryGuiIconProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class WirelessInterfaceTerminalGuiObject
implements IInterfaceTerminal, IGuiItemObject, ICustomButtonProvider, IInventorySlotAware {
public class WirelessInterfaceTerminalGuiObject implements IInterfaceTerminal, IGuiItemObject, ICustomButtonProvider,
IInventorySlotAware, IPrimaryGuiIconProvider {
private boolean needsUpdate;
private final IGridNode node;
@@ -134,4 +135,9 @@ public class WirelessInterfaceTerminalGuiObject
public int getInventorySlot() {
return this.slotIndex;
}
@Override
public ItemStack getPrimaryGuiIcon() {
return this.is.copy();
}
}
@@ -14,14 +14,16 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
import appeng.api.AEApi;
import appeng.api.networking.events.MENetworkBootingStatusChange;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.parts.IInterfaceTerminal;
import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.helpers.IPrimaryGuiIconProvider;
import appeng.util.Platform;
public class PartInterfaceTerminal extends AbstractPartDisplay implements IInterfaceTerminal {
public class PartInterfaceTerminal extends AbstractPartDisplay implements IInterfaceTerminal, IPrimaryGuiIconProvider {
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartInterfaceTerm_Bright;
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartInterfaceTerm_Dark;
@@ -80,4 +82,9 @@ public class PartInterfaceTerminal extends AbstractPartDisplay implements IInter
this.needsUpdate = true;
}
}
@Override
public ItemStack getPrimaryGuiIcon() {
return AEApi.instance().definitions().parts().interfaceTerminal().maybeStack(1).orNull();
}
}