(slot, mouseButton, mode)
| 541 | } |
| 542 | |
| 543 | async function clickWindow (slot, mouseButton, mode) { |
| 544 | // if you click on the quick bar and have dug recently, |
| 545 | // wait a bit |
| 546 | if (slot >= bot.QUICK_BAR_START && bot.lastDigTime != null) { |
| 547 | let timeSinceLastDig |
| 548 | while ((timeSinceLastDig = new Date() - bot.lastDigTime) < DIG_CLICK_TIMEOUT) { |
| 549 | await sleep(DIG_CLICK_TIMEOUT - timeSinceLastDig) |
| 550 | } |
| 551 | } |
| 552 | const window = bot.currentWindow || bot.inventory |
| 553 | |
| 554 | assert.ok(mode >= 0 && mode <= 6) |
| 555 | const actionId = createActionNumber() |
| 556 | |
| 557 | const click = { |
| 558 | slot, |
| 559 | mouseButton, |
| 560 | mode, |
| 561 | id: actionId, |
| 562 | windowId: window.id, |
| 563 | item: slot === -999 ? null : window.slots[slot] |
| 564 | } |
| 565 | |
| 566 | let changedSlots |
| 567 | if (bot.supportFeature('transactionPacketExists')) { |
| 568 | windowClickQueue.push(click) |
| 569 | } else { |
| 570 | if ( |
| 571 | // this array indicates the clicks that return changedSlots |
| 572 | [ |
| 573 | 0, |
| 574 | // 1, |
| 575 | // 2, |
| 576 | 3, |
| 577 | 4 |
| 578 | // 5, |
| 579 | // 6 |
| 580 | ].includes(click.mode)) { |
| 581 | changedSlots = window.acceptClick(click) |
| 582 | } else { |
| 583 | // this is used as a fallback |
| 584 | const oldSlots = JSON.parse(JSON.stringify(window.slots)) |
| 585 | |
| 586 | window.acceptClick(click) |
| 587 | |
| 588 | changedSlots = getChangedSlots(oldSlots, window.slots) |
| 589 | } |
| 590 | |
| 591 | changedSlots = changedSlots.map(slot => { |
| 592 | return { |
| 593 | location: slot, |
| 594 | item: Item.toNotch(window.slots[slot]) |
| 595 | } |
| 596 | }) |
| 597 | } |
| 598 | |
| 599 | // WHEN ADDING SUPPORT FOR OTHER CLICKS, MAKE SURE TO CHANGE changedSlots TO SUPPORT THEM |
| 600 | if (bot.supportFeature('stateIdUsed')) { // 1.17.1 + |
no test coverage detected
searching dependent graphs…