Don't hardcode a magic number for the hotbar slot ID offset
This commit is contained in:
parent
5ee5d2632a
commit
cbdb5f141c
@ -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
|
* 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)
|
* 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
|
|
||||||
|
@ -52,10 +52,12 @@ public class HotbarReplace implements ModInitializer {
|
|||||||
if (client != null) {
|
if (client != null) {
|
||||||
client.interactionManager.clickSlot(player.currentScreenHandler.syncId, i, GLFW.GLFW_MOUSE_BUTTON_1, SlotActionType.PICKUP, player);
|
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(() -> {
|
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);
|
}, 50, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user