diff options
| author | IndigoPolecat <115671621+IndigoPolecat@users.noreply.github.com> | 2024-08-04 08:04:09 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-04 16:04:09 +0200 |
| commit | 30fea5f435098d2089444952d8bc02db5dcf41e7 (patch) | |
| tree | ca50b2ffbe890f5b8921821a2079b527cfc27bab | |
| parent | 3ce20a6e3f644719c47358c422021f6e926a4b1b (diff) | |
| download | notenoughupdates-30fea5f435098d2089444952d8bc02db5dcf41e7.tar.gz notenoughupdates-30fea5f435098d2089444952d8bc02db5dcf41e7.tar.bz2 notenoughupdates-30fea5f435098d2089444952d8bc02db5dcf41e7.zip | |
Fix slot binding in chest or non-player GUIs (#1189)
Co-authored-by: nopo <nopotheemail@gmail.com>
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java index c3313375..f67ece5a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java @@ -495,15 +495,23 @@ public class SlotLocking { LockedSlot boundLocked = getLockedSlot(boundSlot); + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) { + return; + } + GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen; + int size = container.inventorySlots.inventorySlots.size(); + int from, to; int id = slotClickEvent.slot.getSlotIndex(); - if (id >= 9 && 0 <= locked.boundTo && locked.boundTo < 8 && !boundLocked.locked) { - from = id; + int idChest = id + (size - 45); // adjust the id of the clicked slot to align with the current inventory's number of slots + + if (idChest >= 9 && 0 <= locked.boundTo && locked.boundTo < 8 && !boundLocked.locked) { + from = idChest; to = locked.boundTo; if (boundLocked == DEFAULT_LOCKED_SLOT) { LockedSlot[] lockedSlots = getDataForProfile(); lockedSlots[locked.boundTo] = new LockedSlot(); - lockedSlots[locked.boundTo].boundTo = id; + lockedSlots[locked.boundTo].boundTo = idChest; } else { boundLocked.boundTo = id; } |
