From f9e3f80f6b2dce8555effc5d76056e9d5c1d59f2 Mon Sep 17 00:00:00 2001 From: zy <854865755@163.com> Date: Fri, 16 Sep 2022 22:34:00 +0800 Subject: [PATCH] fix crafting terminal crash fix in crafting terminal use hot key to transfer current crafting terminal item to craft slot crash --- .../container/ContainerWirelessCraftingTerminal.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerWirelessCraftingTerminal.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerWirelessCraftingTerminal.java index 9a4f70b..5f9632f 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerWirelessCraftingTerminal.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerWirelessCraftingTerminal.java @@ -224,7 +224,11 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer // Add hotbar slots for (int i = 0; i < 9; ++i) { - hotbarSlot[i] = new SlotPlayerHotBar(this.inventoryPlayer, i, i * 18 + 8, 58); + if (player.inventory.getStackInSlot(i) != null && player.inventory.getStackInSlot(i).getItem() == this.thisItem) { + hotbarSlot[i] = new SlotDisabled(this.inventoryPlayer, i, i * 18 + 8, 58); + } else { + hotbarSlot[i] = new SlotPlayerHotBar(this.inventoryPlayer, i, i * 18 + 8, 58); + } this.addSlotToContainer(hotbarSlot[i]); } @@ -233,7 +237,11 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer // Add player inventory slots for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { - inventorySlot[k] = new SlotPlayerInv(this.inventoryPlayer, j + i * 9 + 9, j * 18 + 8, i * 18); + if (player.inventory.getStackInSlot(j + i * 9 + 9) != null && player.inventory.getStackInSlot(j + i * 9 + 9).getItem() == this.thisItem) { + inventorySlot[k] = new SlotDisabled(this.inventoryPlayer, j + i * 9 + 9, j * 18 + 8, i * 18); + } else { + inventorySlot[k] = new SlotPlayerInv(this.inventoryPlayer, j + i * 9 + 9, j * 18 + 8, i * 18); + } this.addSlotToContainer(inventorySlot[k]); k++; }