diff --git a/lib/plugins/inventory.js b/lib/plugins/inventory.js index f4ef1d00d..291d6dcf1 100644 --- a/lib/plugins/inventory.js +++ b/lib/plugins/inventory.js @@ -549,6 +549,10 @@ function inject (bot, { hideErrors }) { return changedSlots } + // 1.21.5+ clicks claim slot contents by hash; the server resends any slot + // whose claim doesn't match its own state. + const toClickNotch = bot.registry.protocol.types.HashedSlot ? Item.toHashedNotch : Item.toNotch + async function clickWindow (slot, mouseButton, mode) { // if you click on the quick bar and have dug recently, // wait a bit @@ -600,7 +604,7 @@ function inject (bot, { hideErrors }) { changedSlots = changedSlots.map(slot => { return { location: slot, - item: Item.toNotch(window.slots[slot]) + item: toClickNotch(window.slots[slot]) } }) } @@ -614,7 +618,7 @@ function inject (bot, { hideErrors }) { mouseButton, mode, changedSlots, - cursorItem: Item.toNotch(window.selectedItem) + cursorItem: toClickNotch(window.selectedItem) }) } else if (bot.supportFeature('actionIdUsed')) { // <= 1.16.5 bot._client.write('window_click', { @@ -834,7 +838,7 @@ function inject (bot, { hideErrors }) { mouseButton: 2, // end of a drag that never started mode: 5, changedSlots: [], - cursorItem: Item.toNotch(window.selectedItem) + cursorItem: toClickNotch(window.selectedItem) }) await synced }