diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index e48de9eeb..2f3134f42 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -232,9 +232,12 @@ public enum GuiBridge implements IGuiHandler { public Object getServerGuiElement(final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z) { final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07); final GuiBridge ID = values()[ordinal >> 4]; + final boolean usingItemOnTile = ((ordinal >> 3) & 1) == 1; if (ID.type.isItem()) { ItemStack it = ItemStack.EMPTY; - if (y == 0) { + if (usingItemOnTile) { + it = player.inventory.getCurrentItem(); + } else if (y == 0) { if (x >= 0 && x < player.inventory.mainInventory.size()) { it = player.inventory.getStackInSlot(x); } @@ -344,9 +347,13 @@ public enum GuiBridge implements IGuiHandler { public Object getClientGuiElement(final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z) { final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07); final GuiBridge ID = values()[ordinal >> 4]; + final boolean usingItemOnTile = ((ordinal >> 3) & 1) == 1; + if (ID.type.isItem()) { ItemStack it = ItemStack.EMPTY; - if (y == 0) { + if (usingItemOnTile) { + it = player.inventory.getCurrentItem(); + } else if (y == 0) { if (x >= 0 && x < player.inventory.mainInventory.size()) { it = player.inventory.getStackInSlot(x); } diff --git a/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java b/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java index 6c20d09b4..b6b69d5ab 100644 --- a/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java +++ b/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java @@ -27,6 +27,7 @@ import appeng.api.networking.security.IActionHost; import appeng.container.ContainerOpenContext; import appeng.container.implementations.ContainerCraftAmount; import appeng.container.implementations.ContainerCraftConfirm; +import appeng.container.interfaces.IInventorySlotAware; import appeng.core.AELog; import appeng.core.sync.AppEngPacket; import appeng.core.sync.GuiBridge; @@ -91,7 +92,14 @@ public class PacketCraftRequest extends AppEngPacket { final ContainerOpenContext context = cca.getOpenContext(); if (context != null) { final TileEntity te = context.getTile(); - Platform.openGUI(player, te, cca.getOpenContext().getSide(), GuiBridge.GUI_CRAFTING_CONFIRM); + if (te != null) { + Platform.openGUI(player, te, cca.getOpenContext().getSide(), GuiBridge.GUI_CRAFTING_CONFIRM); + } else { + if (ah instanceof IInventorySlotAware) { + IInventorySlotAware i = ((IInventorySlotAware) ah); + Platform.openGUI(player, i.getInventorySlot(), GuiBridge.GUI_CRAFTING_CONFIRM, i.isBaubleSlot()); + } + } if (player.openContainer instanceof ContainerCraftConfirm) { final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer; diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index 7188e66d6..c08959aa2 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -344,7 +344,11 @@ public class Platform { if (tile == null && type.getType() == GuiHostType.ITEM) { p.openGui(AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), x, 0, 0); } else if (tile == null || type.getType() == GuiHostType.ITEM) { - p.openGui(AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), x, y, z); + if (tile != null) { + p.openGui(AppEng.instance(), type.ordinal() << 4 | (1 << 3), p.getEntityWorld(), x, y, z); + } else { + p.openGui(AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), x, y, z); + } } else { p.openGui(AppEng.instance(), type.ordinal() << 4 | (side.ordinal()), tile.getWorld(), x, y, z); } @@ -357,9 +361,7 @@ public class Platform { } 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); - } + p.openGui(AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), slot, isBauble ? 1 : 0, Integer.MIN_VALUE); } }