Skip to content

Commit 6564eee

Browse files
authored
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
1 parent 68e2b82 commit 6564eee

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
@@ -42,6 +42,7 @@
4242
import net.minecraft.world.entity.player.Inventory;
4343
import net.minecraft.world.entity.player.Player;
4444
import net.minecraft.world.inventory.AbstractContainerMenu;
45+
import net.minecraft.world.inventory.ClickType;
4546
import net.minecraft.world.inventory.MenuType;
4647
import net.minecraft.world.inventory.Slot;
4748
import net.minecraft.world.item.ItemStack;
@@ -212,6 +213,16 @@ protected final void createPlayerInventorySlots(Inventory playerInventory) {
212213
}
213214
}
214215

216+
@Override
217+
public void clicked(int slotId, int button, ClickType clickType, Player player) {
218+
// Do not allow swapping with off-hand if the off-hand slot is locked
219+
if (clickType == ClickType.SWAP && isPlayerInventorySlotLocked(Inventory.SLOT_OFFHAND)) {
220+
return;
221+
}
222+
223+
super.clicked(slotId, button, clickType, player);
224+
}
225+
215226
protected Slot addSlot(Slot slot, SlotSemantic semantic) {
216227
slot = this.addSlot(slot);
217228

0 commit comments

Comments
 (0)