diff --git a/README.md b/README.md index 24ee82f..19199c6 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,3 @@ HotbarReplace is a Minecraft mod for the Fabric modding framework which replaces * The mod won't refill your hotbar slot with other stacks in other hotbar slots * Make the mod more resilient to network delay and packet loss (don't hardcode a 50 ms delay) -* Don't hardcode an offset for the hotbar slot IDs diff --git a/src/main/java/io/github/twokilohertz/hotbarreplace/HotbarReplace.java b/src/main/java/io/github/twokilohertz/hotbarreplace/HotbarReplace.java index 965b722..a838f8c 100644 --- a/src/main/java/io/github/twokilohertz/hotbarreplace/HotbarReplace.java +++ b/src/main/java/io/github/twokilohertz/hotbarreplace/HotbarReplace.java @@ -52,10 +52,12 @@ public class HotbarReplace implements ModInitializer { if (client != null) { client.interactionManager.clickSlot(player.currentScreenHandler.syncId, i, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, player); - // Wait 50 seconds (on another thread) before attempting to move the new stack - // The magic number 36 is the offset to get the hotbar slotId + /* + Wait 50 seconds (on another thread) before attempting to move the new stack + PlayerInventory.MAIN_SIZE added to the selected slot (hotbar slot) is the correct slot ID + */ scheduler.schedule(() -> { - client.interactionManager.clickSlot(player.currentScreenHandler.syncId, inventory.selectedSlot + 36, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, player); + client.interactionManager.clickSlot(player.currentScreenHandler.syncId, inventory.selectedSlot + PlayerInventory.MAIN_SIZE, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, player); }, 50, TimeUnit.MILLISECONDS); }