diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index 7d3a105c1..1a87a138b 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -363,7 +363,7 @@ public enum GuiBridge implements IGuiHandler { } else if (x >= 0 && x < player.inventory.mainInventory.size()) { it = player.inventory.getStackInSlot(x); } - } else if (y == 1 && z == 0) { + } else if (y == 1 && z == Integer.MIN_VALUE) { if (stem) { if (player.openContainer instanceof IInventorySlotAware) { int slot = ((IInventorySlotAware) player.openContainer).getInventorySlot(); diff --git a/src/main/java/appeng/core/sync/packets/PacketTerminalUse.java b/src/main/java/appeng/core/sync/packets/PacketTerminalUse.java index 62de87ebd..0e813bed1 100644 --- a/src/main/java/appeng/core/sync/packets/PacketTerminalUse.java +++ b/src/main/java/appeng/core/sync/packets/PacketTerminalUse.java @@ -32,16 +32,17 @@ public class PacketTerminalUse extends AppEngPacket { @Override public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player) { NonNullList mainInventory = player.inventory.mainInventory; - for (ItemStack is : mainInventory) { + for (int i = 0; i < mainInventory.size(); i++) { + ItemStack is = mainInventory.get(i); if (terminal.getItemDefinition().isSameAs(is)) { - Platform.openGUI(player, null, AEPartLocation.INTERNAL, terminal.getBridge()); + Platform.openGUI(player, i, terminal.getBridge(), false); return; } } for (int i = 0; i < BaublesApi.getBaublesHandler(player).getSlots(); i++) { ItemStack is = BaublesApi.getBaublesHandler(player).getStackInSlot(i); if (terminal.getItemDefinition().isSameAs(is)) { - Platform.openGUI(player, null, AEPartLocation.INTERNAL, terminal.getBridge()); + Platform.openGUI(player, i, terminal.getBridge(), true); break; } } diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index d59e0290e..386aaed3f 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -323,28 +323,19 @@ public class Platform { return; } - int x; - int y; - int z; + int x = 0; + int y = 0; + int z = Integer.MIN_VALUE; if (tile != null) { x = tile.getPos().getX(); y = tile.getPos().getY(); z = tile.getPos().getZ(); - } else { - if (p.openContainer instanceof IInventorySlotAware) { - x = ((IInventorySlotAware) p.openContainer).getInventorySlot(); - y = ((IInventorySlotAware) p.openContainer).isBaubleSlot() ? 1 : 0; - } else { - x = p.inventory.currentItem; - y = 0; - } - z = Integer.MIN_VALUE; } if ((type.getType().isItem() && tile == null) || type.hasPermissions(tile, x, y, z, side, p)) { if (tile == null && type.getType() == GuiHostType.ITEM) { - p.openGui(AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), x, 0, 0); + p.openGui(AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), x, y, z); } else if (tile == null || type.getType() == GuiHostType.ITEM) { p.openGui(AppEng.instance(), type.ordinal() << 4 | (1 << 3), p.getEntityWorld(), x, y, z); } else { @@ -353,6 +344,19 @@ public class Platform { } } + public static void openGUI(@Nonnull final EntityPlayer p, int slot, @Nonnull final GuiBridge type, boolean isBauble) { + if (isClient()) { + return; + } + + if (type.getType().isItem()) { + if (type.getType() == GuiHostType.ITEM) { + p.openGui(AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), slot, isBauble ? 1 : 0, Integer.MIN_VALUE); + } + } + } + + /* * returns true if the code is on the client. */