diff --git a/lib/plugins/inventory.js b/lib/plugins/inventory.js index 47a4db07a..13142057f 100644 --- a/lib/plugins/inventory.js +++ b/lib/plugins/inventory.js @@ -479,6 +479,20 @@ function inject (bot, { hideErrors }) { } } + function getChangedSlots (oldSlots, newSlots) { + assert.equal(oldSlots.length, newSlots.length) + + const changedSlots = [] + + for (let i = 0; i < newSlots.length; i++) { + if (!Item.equal(oldSlots[i], newSlots[i])) { + changedSlots.push(i) + } + } + + return changedSlots + } + async function clickWindow (slot, mouseButton, mode) { // if you click on the quick bar and have dug recently, // wait a bit @@ -506,7 +520,33 @@ function inject (bot, { hideErrors }) { if (bot.supportFeature('transactionPacketExists')) { windowClickQueue.push(click) } else { - changedSlots = window.acceptClick(click) + if ( + // this array indicates the clicks that return changedSlots + [ + 0, + // 1, + // 2, + 3, + 4 + // 5, + // 6 + ].includes(click.mode)) { + changedSlots = window.acceptClick(click) + } else { + // this is used as a fallback + const oldSlots = JSON.parse(JSON.stringify(window.slots)) + + window.acceptClick(click) + + changedSlots = getChangedSlots(oldSlots, window.slots) + } + + changedSlots = changedSlots.map(slot => { + return { + location: slot, + item: Item.toNotch(window.slots[slot]) + } + }) } // WHEN ADDING SUPPORT FOR OTHER CLICKS, MAKE SURE TO CHANGE changedSlots TO SUPPORT THEM diff --git a/package.json b/package.json index dc82648d6..918b0a3a9 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "prismarine-physics": "^1.7.0", "prismarine-recipe": "^1.3.0", "prismarine-registry": "^1.5.0", - "prismarine-windows": "^2.5.0", + "prismarine-windows": "^2.8.0", "prismarine-world": "^3.6.0", "protodef": "^1.14.0", "typed-emitter": "^1.0.0",