@@ -479,6 +479,20 @@ function inject (bot, { hideErrors }) {
479
479
}
480
480
}
481
481
482
+ function getChangedSlots ( oldSlots , newSlots ) {
483
+ assert . equal ( oldSlots . length , newSlots . length )
484
+
485
+ const changedSlots = [ ]
486
+
487
+ for ( let i = 0 ; i < newSlots . length ; i ++ ) {
488
+ if ( ! Item . equal ( oldSlots [ i ] , newSlots [ i ] ) ) {
489
+ changedSlots . push ( i )
490
+ }
491
+ }
492
+
493
+ return changedSlots
494
+ }
495
+
482
496
async function clickWindow ( slot , mouseButton , mode ) {
483
497
// if you click on the quick bar and have dug recently,
484
498
// wait a bit
@@ -506,7 +520,33 @@ function inject (bot, { hideErrors }) {
506
520
if ( bot . supportFeature ( 'transactionPacketExists' ) ) {
507
521
windowClickQueue . push ( click )
508
522
} else {
509
- changedSlots = window . acceptClick ( click )
523
+ if (
524
+ // this array indicates the clicks that return changedSlots
525
+ [
526
+ 0 ,
527
+ // 1,
528
+ // 2,
529
+ 3 ,
530
+ 4
531
+ // 5,
532
+ // 6
533
+ ] . includes ( click . mode ) ) {
534
+ changedSlots = window . acceptClick ( click )
535
+ } else {
536
+ // this is used as a fallback
537
+ const oldSlots = JSON . parse ( JSON . stringify ( window . slots ) )
538
+
539
+ window . acceptClick ( click )
540
+
541
+ changedSlots = getChangedSlots ( oldSlots , window . slots )
542
+ }
543
+
544
+ changedSlots = changedSlots . map ( slot => {
545
+ return {
546
+ location : slot ,
547
+ item : Item . toNotch ( window . slots [ slot ] )
548
+ }
549
+ } )
510
550
}
511
551
512
552
// WHEN ADDING SUPPORT FOR OTHER CLICKS, MAKE SURE TO CHANGE changedSlots TO SUPPORT THEM
0 commit comments