From bf44090f7795d9c757958971df65d9f8d9d2663d Mon Sep 17 00:00:00 2001 From: Wilhelm Schuster Date: Sat, 13 May 2023 17:39:49 +0200 Subject: Make sure the backpack is properly secured while it's open (#627) --- .../core/container/Container_BackpackBase.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/main/java/gtPlusPlus/core/container') diff --git a/src/main/java/gtPlusPlus/core/container/Container_BackpackBase.java b/src/main/java/gtPlusPlus/core/container/Container_BackpackBase.java index 5016a93280..1fc2981722 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_BackpackBase.java +++ b/src/main/java/gtPlusPlus/core/container/Container_BackpackBase.java @@ -7,6 +7,7 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.slots.SlotBlockedInv; import gtPlusPlus.core.slots.SlotItemBackpackInv; public class Container_BackpackBase extends Container { @@ -63,7 +64,11 @@ public class Container_BackpackBase extends Container { // PLAYER ACTION BAR - uses default locations for standard action bar texture file for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142)); + if (i == par1Player.inventory.currentItem) { + this.addSlotToContainer(new SlotBlockedInv(inventoryPlayer, i, 8 + (i * 18), 142)); + } else { + this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142)); + } } } @@ -164,6 +169,16 @@ public class Container_BackpackBase extends Container { if ((slot >= 0) && (this.getSlot(slot) != null) && (this.getSlot(slot).getStack() == player.getHeldItem())) { return null; } + + // Keybind for moving from hotbar slot to hovered slot, make we don't move the currently held backpack. + if (flag == 2 && button >= 0 && button < 9) { + int hotbarIndex = HOTBAR_START + button; + Slot hotbarSlot = getSlot(hotbarIndex); + if (hotbarSlot instanceof SlotBlockedInv) { + return null; + } + } + return super.slotClick(slot, button, flag, player); } } -- cgit