Skip to content

Commit f1780eb

Browse files
committed
fix: Fix a crash when refilling to the offhand slot
1 parent e163644 commit f1780eb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/main/java/de/siphalor/mousewheelie/client/inventory/StackPicker.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class StackPicker {
4040
private static final int HOTBAR_INVENTORY_START_SLOT = 0;
4141
private static final int MAIN_INVENTORY_START_SLOT = Inventory.getSelectionSize();
4242
private static final int HOTBAR_CONTAINER_START_SLOT = InventoryMenu.USE_ROW_SLOT_START;
43+
private static final int HOTBAR_CONTAINER_END_SLOT = InventoryMenu.USE_ROW_SLOT_END;
4344
private static final int MAIN_INVENTORY_CONTAINER_START_SLOT = InventoryMenu.INV_SLOT_START;
4445

4546
private final Player player;
@@ -199,7 +200,8 @@ private int findNextFreeHotbarInventorySlot() {
199200
}
200201

201202
private void swapWithTargetContainerSlot(int targetContainerSlot) {
202-
if (InventoryMenu.isHotbarSlot(targetContainerSlot)) {
203+
// InventoryMenu#isHotbarSlot for some reason includes the offhand slot
204+
if (targetContainerSlot >= HOTBAR_CONTAINER_START_SLOT && targetContainerSlot < HOTBAR_CONTAINER_END_SLOT) {
203205
int hotbarSlot = targetContainerSlot - HOTBAR_CONTAINER_START_SLOT;
204206
if (hotbarSlot != getSelectedHotbarSlot()) {
205207
selectHotbarSlot(hotbarSlot);

0 commit comments

Comments
 (0)