(window, slot)
| 449 | } |
| 450 | |
| 451 | async function waitForWindowUpdate (window, slot) { |
| 452 | if (window.type === 'minecraft:inventory') { |
| 453 | if (slot >= 1 && slot <= 4) { |
| 454 | await once(bot.inventory, 'updateSlot:0') |
| 455 | } |
| 456 | } else if (window.type === 'minecraft:crafting') { |
| 457 | if (slot >= 1 && slot <= 9) { |
| 458 | await once(bot.currentWindow, 'updateSlot:0') |
| 459 | } |
| 460 | } else if (window.type === 'minecraft:merchant') { |
| 461 | const toUpdate = [] |
| 462 | if (slot <= 1 && !window.selectedTrade.tradeDisabled && expectTradeUpdate(window)) { |
| 463 | toUpdate.push(once(bot.currentWindow, 'updateSlot:2')) |
| 464 | } |
| 465 | if (slot === 2) { |
| 466 | for (const item of bot.currentWindow.containerItems()) { |
| 467 | toUpdate.push(once(bot.currentWindow, `updateSlot:${item.slot}`)) |
| 468 | } |
| 469 | } |
| 470 | await Promise.all(toUpdate) |
| 471 | |
| 472 | if (slot === 2 && !window.selectedTrade.tradeDisabled && expectTradeUpdate(window)) { |
| 473 | // After the trade goes through, if the inputs are still satisfied, |
| 474 | // expect another update in slot 2 |
| 475 | await once(bot.currentWindow, 'updateSlot:2') |
| 476 | } |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | function confirmTransaction (windowId, actionId, accepted) { |
| 481 | // drop the queue entries for all the clicks that the server did not send |
no test coverage detected
searching dependent graphs…