@@ -26,6 +26,7 @@ function inject (bot, { hideErrors }) {
26
26
const windows = require ( 'prismarine-windows' ) ( bot . version )
27
27
28
28
let eatingTask = createDoneTask ( )
29
+ let sequence = 0
29
30
30
31
let nextActionNumber = 0 // < 1.17
31
32
let stateId = - 1
@@ -43,6 +44,7 @@ function inject (bot, { hideErrors }) {
43
44
bot . inventory = windows . createWindow ( 0 , 'minecraft:inventory' , 'Inventory' )
44
45
bot . currentWindow = null
45
46
bot . usingHeldItem = false
47
+
46
48
Object . defineProperty ( bot , 'heldItem' , {
47
49
get : function ( ) {
48
50
return bot . inventory . slots [ bot . QUICK_BAR_START + bot . quickBarSlot ]
@@ -111,6 +113,8 @@ function inject (bot, { hideErrors }) {
111
113
112
114
function activateItem ( offHand = false ) {
113
115
bot . usingHeldItem = true
116
+ sequence ++
117
+
114
118
if ( bot . supportFeature ( 'useItemWithBlockPlace' ) ) {
115
119
bot . _client . write ( 'block_place' , {
116
120
location : new Vec3 ( - 1 , 255 , - 1 ) ,
@@ -123,17 +127,26 @@ function inject (bot, { hideErrors }) {
123
127
} else if ( bot . supportFeature ( 'useItemWithOwnPacket' ) ) {
124
128
bot . _client . write ( 'use_item' , {
125
129
hand : offHand ? 1 : 0 ,
130
+ sequence,
126
131
rotation : { x : 0 , y : 0 }
127
132
} )
128
133
}
129
134
}
130
135
131
136
function deactivateItem ( ) {
132
- bot . _client . write ( 'block_dig' , {
137
+ const body = {
133
138
status : 5 ,
134
139
location : new Vec3 ( 0 , 0 , 0 ) ,
135
140
face : 5
136
- } )
141
+ }
142
+
143
+ if ( bot . supportFeature ( 'useItemWithOwnPacket' ) ) {
144
+ body . face = 0
145
+ body . sequence = 0
146
+ }
147
+
148
+ bot . _client . write ( 'block_dig' , body )
149
+
137
150
bot . usingHeldItem = false
138
151
}
139
152
0 commit comments