@@ -43,8 +43,26 @@ function inject (bot, { hideErrors }) {
43
43
bot . quickBarSlot = null
44
44
bot . inventory = windows . createWindow ( 0 , 'minecraft:inventory' , 'Inventory' )
45
45
bot . currentWindow = null
46
- bot . heldItem = null
47
46
bot . usingHeldItem = false
47
+ Object . defineProperty ( bot , 'heldItem' , {
48
+ get : function ( ) {
49
+ return bot . inventory . slots [ bot . QUICK_BAR_START + bot . quickBarSlot ]
50
+ }
51
+ } )
52
+
53
+ bot . on ( 'spawn' , ( ) => {
54
+ Object . defineProperty ( bot . entity , 'equipment' , {
55
+ get : bot . supportFeature ( 'doesntHaveOffHandSlot' )
56
+ ? function ( ) {
57
+ return [ bot . heldItem , bot . inventory . slots [ 8 ] , bot . inventory . slots [ 7 ] ,
58
+ bot . inventory . slots [ 6 ] , bot . inventory . slots [ 5 ] ]
59
+ }
60
+ : function ( ) {
61
+ return [ bot . heldItem , bot . inventory . slots [ 45 ] , bot . inventory . slots [ 8 ] ,
62
+ bot . inventory . slots [ 7 ] , bot . inventory . slots [ 6 ] , bot . inventory . slots [ 5 ] ]
63
+ }
64
+ } )
65
+ } )
48
66
49
67
bot . _client . on ( 'entity_status' , ( packet ) => {
50
68
if ( packet . entityId === bot . entity . id && packet . entityStatus === 9 && ! eatingTask . done ) {
@@ -364,9 +382,7 @@ function inject (bot, { hideErrors }) {
364
382
}
365
383
366
384
function updateHeldItem ( ) {
367
- bot . heldItem = bot . inventory . slots [ bot . QUICK_BAR_START + bot . quickBarSlot ]
368
- bot . entity . heldItem = bot . heldItem
369
- bot . emit ( 'heldItemChanged' , bot . entity . heldItem )
385
+ bot . emit ( 'heldItemChanged' , bot . heldItem )
370
386
}
371
387
372
388
function closeWindow ( window ) {
0 commit comments