Skip to content

Commit f794157

Browse files
committed
Do not allow swapping an opened GUI item (i.e. terminals) out of the off-hand slot (#8593)
Fixes potential loss of item or dupes Fixes #8257 (cherry picked from commit 6564eee)
1 parent 8aa0c6b commit f794157

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/main/java/appeng/menu/AEBaseMenu.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import net.minecraft.world.entity.player.Inventory;
4141
import net.minecraft.world.entity.player.Player;
4242
import net.minecraft.world.inventory.AbstractContainerMenu;
43+
import net.minecraft.world.inventory.ClickType;
4344
import net.minecraft.world.inventory.MenuType;
4445
import net.minecraft.world.inventory.Slot;
4546
import net.minecraft.world.item.ItemStack;
@@ -200,6 +201,16 @@ protected final void createPlayerInventorySlots(Inventory playerInventory) {
200201
}
201202
}
202203

204+
@Override
205+
public void clicked(int slotId, int button, ClickType clickType, Player player) {
206+
// Do not allow swapping with off-hand if the off-hand slot is locked
207+
if (clickType == ClickType.SWAP && isPlayerInventorySlotLocked(Inventory.SLOT_OFFHAND)) {
208+
return;
209+
}
210+
211+
super.clicked(slotId, button, clickType, player);
212+
}
213+
203214
protected Slot addSlot(Slot slot, SlotSemantic semantic) {
204215
slot = this.addSlot(slot);
205216

0 commit comments

Comments
 (0)