aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/core/container
diff options
context:
space:
mode:
authorWilhelm Schuster <dev@rot13.io>2023-05-13 17:39:49 +0200
committerGitHub <noreply@github.com>2023-05-13 17:39:49 +0200
commitbf44090f7795d9c757958971df65d9f8d9d2663d (patch)
treebff0fd25d74bbc92cdd76512f4912db6072dd73e /src/main/java/gtPlusPlus/core/container
parentaefb6dce11384bc72dd340fa0fb1037988e35916 (diff)
downloadGT5-Unofficial-bf44090f7795d9c757958971df65d9f8d9d2663d.tar.gz
GT5-Unofficial-bf44090f7795d9c757958971df65d9f8d9d2663d.tar.bz2
GT5-Unofficial-bf44090f7795d9c757958971df65d9f8d9d2663d.zip
Make sure the backpack is properly secured while it's open (#627)
Diffstat (limited to 'src/main/java/gtPlusPlus/core/container')
-rw-r--r--src/main/java/gtPlusPlus/core/container/Container_BackpackBase.java17
1 files changed, 16 insertions, 1 deletions
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);
}
}