mineflayer 3.18.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/docs/README.md +1 -1
- package/docs/es/README_ES.md +6 -6
- package/docs/history.md +5 -0
- package/lib/plugins/anvil.js +4 -4
- package/lib/plugins/bed.js +2 -3
- package/lib/plugins/blocks.js +2 -2
- package/lib/plugins/book.js +4 -5
- package/lib/plugins/chat.js +1 -20
- package/lib/plugins/chest.js +3 -4
- package/lib/plugins/craft.js +1 -2
- package/lib/plugins/creative.js +4 -4
- package/lib/plugins/digging.js +2 -25
- package/lib/plugins/enchantment_table.js +5 -6
- package/lib/plugins/entities.js +3 -2
- package/lib/plugins/fishing.js +2 -2
- package/lib/plugins/furnace.js +6 -7
- package/lib/plugins/inventory.js +14 -14
- package/lib/plugins/physics.js +5 -5
- package/lib/plugins/place_block.js +2 -2
- package/lib/plugins/simple_inventory.js +4 -5
- package/lib/plugins/villager.js +2 -3
- package/lib/promise_utils.js +1 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
|
|
|
17
17
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
|
-
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 and 1.18.
|
|
20
|
+
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 and 1.18.
|
|
21
21
|
* Entity knowledge and tracking.
|
|
22
22
|
* Block knowledge. You can query the world around you. Milliseconds to find any block.
|
|
23
23
|
* Physics and movement - handle all bounding boxes
|
package/docs/README.md
CHANGED
|
@@ -17,7 +17,7 @@ First time using Node.js? You may want to start with the [tutorial](tutorial.md)
|
|
|
17
17
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
|
-
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 and 1.18.
|
|
20
|
+
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 and 1.18.
|
|
21
21
|
* Entity knowledge and tracking.
|
|
22
22
|
* Block knowledge. You can query the world around you. Milliseconds to find any block.
|
|
23
23
|
* Physics and movement - handle all bounding boxes
|
package/docs/es/README_ES.md
CHANGED
|
@@ -17,7 +17,7 @@ Crea bots para Minecraft con una API de JavaScript potente, estable y de alto ni
|
|
|
17
17
|
|
|
18
18
|
## Características
|
|
19
19
|
|
|
20
|
-
* Soporta Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15 y 1.
|
|
20
|
+
* Soporta Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17 y 1.18.
|
|
21
21
|
* Rastreo e información de entidades.
|
|
22
22
|
* Información sobre bloques. Puedes solicitar información de todo lo que te rodea. Encuentra bloques en milisegundos
|
|
23
23
|
* Físicas y movimientos básicos - maneja todos los cuadros de colisión
|
|
@@ -34,6 +34,7 @@ Crea bots para Minecraft con una API de JavaScript potente, estable y de alto ni
|
|
|
34
34
|
Echa un vistazo a nuestros [proyectos actuales](https://github.com/PrismarineJS/mineflayer/wiki/Big-Prismarine-projects)
|
|
35
35
|
|
|
36
36
|
## Instalación
|
|
37
|
+
Primero instala Node.js >= 14 desde [nodejs.org](https://nodejs.org/)
|
|
37
38
|
|
|
38
39
|
`npm install mineflayer`
|
|
39
40
|
|
|
@@ -66,10 +67,9 @@ Si quieres aprender más, puedes mirar [aquí, ](https://www.youtube.com/playlis
|
|
|
66
67
|
|
|
67
68
|
**Empezando**
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
Por ejemplo `version:" 1.8 "`.
|
|
70
|
+
Si no se especifica una versión, la versión del servidor se detectará automáticamente. Si no se especifica ningún tipo de autenticación, se utilizará el login de Mojang automáticamente.
|
|
71
71
|
|
|
72
|
-
### Ejemplo
|
|
72
|
+
### Ejemplo: echo
|
|
73
73
|
```js
|
|
74
74
|
const mineflayer = require('mineflayer')
|
|
75
75
|
|
|
@@ -92,7 +92,7 @@ bot.on('kicked', (reason, loggedIn) => console.log(reason, loggedIn))
|
|
|
92
92
|
bot.on('error', err => console.log(err))
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
### Mira lo que tu bot
|
|
95
|
+
### Mira lo que hace tu bot
|
|
96
96
|
|
|
97
97
|
Gracias al proyecto [prismarine-viewer](https://github.com/PrismarineJS/prismarine-viewer), puedes ver en una pestaña del navegador qué está haciendo tu bot.
|
|
98
98
|
Solo tienes que ejecutar `npm install prismarine-viewer` y añadir lo siguiente a tu bot:
|
|
@@ -124,7 +124,7 @@ Más ejemplos en la carpeta de [ejemplos](https://github.com/PrismarineJS/minefl
|
|
|
124
124
|
|
|
125
125
|
### Módulos
|
|
126
126
|
|
|
127
|
-
La mayoría del desarrollo se
|
|
127
|
+
La mayoría del desarrollo se está produciendo dentro de pequeños módulos npm que son usados por mineflayer
|
|
128
128
|
|
|
129
129
|
#### The Node Way™
|
|
130
130
|
|
package/docs/history.md
CHANGED
package/lib/plugins/anvil.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
|
-
const {
|
|
2
|
+
const { sleep } = require('../promise_utils')
|
|
3
3
|
const { once } = require('events')
|
|
4
4
|
|
|
5
5
|
module.exports = inject
|
|
@@ -105,11 +105,11 @@ function inject (bot) {
|
|
|
105
105
|
await bot.transfer(options)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
anvil.combine =
|
|
109
|
-
anvil.rename =
|
|
108
|
+
anvil.combine = combine
|
|
109
|
+
anvil.rename = rename
|
|
110
110
|
|
|
111
111
|
return anvil
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
bot.openAnvil =
|
|
114
|
+
bot.openAnvil = openAnvil
|
|
115
115
|
}
|
package/lib/plugins/bed.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { Vec3 } = require('vec3')
|
|
2
|
-
const { callbackify } = require('../promise_utils')
|
|
3
2
|
|
|
4
3
|
module.exports = inject
|
|
5
4
|
|
|
@@ -174,7 +173,7 @@ function inject (bot) {
|
|
|
174
173
|
})
|
|
175
174
|
|
|
176
175
|
bot.parseBedMetadata = parseBedMetadata
|
|
177
|
-
bot.wake =
|
|
178
|
-
bot.sleep =
|
|
176
|
+
bot.wake = wake
|
|
177
|
+
bot.sleep = sleep
|
|
179
178
|
bot.isABed = isABed
|
|
180
179
|
}
|
package/lib/plugins/blocks.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Vec3 } = require('vec3')
|
|
2
2
|
const assert = require('assert')
|
|
3
3
|
const Painting = require('../painting')
|
|
4
|
-
const { onceWithCleanup
|
|
4
|
+
const { onceWithCleanup } = require('../promise_utils')
|
|
5
5
|
|
|
6
6
|
const { OctahedronIterator } = require('prismarine-world').iterators
|
|
7
7
|
|
|
@@ -548,7 +548,7 @@ function inject (bot, { version, storageBuilder }) {
|
|
|
548
548
|
bot.canSeeBlock = canSeeBlock
|
|
549
549
|
bot.blockAt = blockAt
|
|
550
550
|
bot._updateBlockState = updateBlockState
|
|
551
|
-
bot.waitForChunksToLoad =
|
|
551
|
+
bot.waitForChunksToLoad = waitForChunksToLoad
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
function onesInShort (n) {
|
package/lib/plugins/book.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const { once } = require('events')
|
|
3
|
-
const { callbackify } = require('../promise_utils')
|
|
4
3
|
|
|
5
4
|
module.exports = inject
|
|
6
5
|
|
|
@@ -83,11 +82,11 @@ function inject (bot, { version }) {
|
|
|
83
82
|
return book
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
bot.writeBook =
|
|
85
|
+
bot.writeBook = async (slot, pages) => {
|
|
87
86
|
await write(slot, pages, null, null, false)
|
|
88
|
-
}
|
|
87
|
+
}
|
|
89
88
|
|
|
90
|
-
bot.signBook =
|
|
89
|
+
bot.signBook = async (slot, pages, author, title) => {
|
|
91
90
|
await write(slot, pages, author, title, true)
|
|
92
|
-
}
|
|
91
|
+
}
|
|
93
92
|
}
|
package/lib/plugins/chat.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { once } = require('events')
|
|
2
|
-
const { printCallbackDepreciation } = require('../promise_utils')
|
|
3
2
|
|
|
4
3
|
module.exports = inject
|
|
5
4
|
|
|
@@ -170,7 +169,7 @@ function inject (bot, options) {
|
|
|
170
169
|
chatWithHeader('', message)
|
|
171
170
|
}
|
|
172
171
|
|
|
173
|
-
bot.tabComplete =
|
|
172
|
+
bot.tabComplete = tabComplete
|
|
174
173
|
|
|
175
174
|
function addDefaultPatterns () {
|
|
176
175
|
if (!defaultChatPatterns) return
|
|
@@ -194,21 +193,3 @@ function inject (bot, options) {
|
|
|
194
193
|
}
|
|
195
194
|
bot.awaitMessage = awaitMessage
|
|
196
195
|
}
|
|
197
|
-
|
|
198
|
-
function callbackify (f) { // specifically for this function because cb isn't the last parameter
|
|
199
|
-
return function (...args) {
|
|
200
|
-
const cb = args[1]
|
|
201
|
-
args.splice(1, 1)
|
|
202
|
-
return f(...args).then(r => {
|
|
203
|
-
if (cb) {
|
|
204
|
-
printCallbackDepreciation()
|
|
205
|
-
cb(undefined, r)
|
|
206
|
-
} return r
|
|
207
|
-
}, err => {
|
|
208
|
-
if (cb) {
|
|
209
|
-
printCallbackDepreciation()
|
|
210
|
-
cb(err)
|
|
211
|
-
} else throw err
|
|
212
|
-
})
|
|
213
|
-
}
|
|
214
|
-
}
|
package/lib/plugins/chest.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { callbackify } = require('../promise_utils')
|
|
2
1
|
|
|
3
2
|
module.exports = inject
|
|
4
3
|
|
|
@@ -26,7 +25,7 @@ function inject (bot) {
|
|
|
26
25
|
return chest
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
bot.openContainer =
|
|
30
|
-
bot.openChest =
|
|
31
|
-
bot.openDispenser =
|
|
28
|
+
bot.openContainer = openContainer
|
|
29
|
+
bot.openChest = openContainer
|
|
30
|
+
bot.openDispenser = openContainer
|
|
32
31
|
}
|
package/lib/plugins/craft.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const { once } = require('events')
|
|
3
|
-
const { callbackify } = require('../promise_utils')
|
|
4
3
|
|
|
5
4
|
module.exports = inject
|
|
6
5
|
|
|
@@ -226,7 +225,7 @@ function inject (bot, { version }) {
|
|
|
226
225
|
return true
|
|
227
226
|
}
|
|
228
227
|
|
|
229
|
-
bot.craft =
|
|
228
|
+
bot.craft = craft
|
|
230
229
|
bot.recipesFor = recipesFor
|
|
231
230
|
bot.recipesAll = recipesAll
|
|
232
231
|
}
|
package/lib/plugins/creative.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const { Vec3 } = require('vec3')
|
|
3
|
-
const {
|
|
3
|
+
const { sleep } = require('../promise_utils')
|
|
4
4
|
const { once } = require('events')
|
|
5
5
|
|
|
6
6
|
module.exports = inject
|
|
@@ -10,8 +10,8 @@ function inject (bot, { version }) {
|
|
|
10
10
|
|
|
11
11
|
// these features only work when you are in creative mode.
|
|
12
12
|
bot.creative = {
|
|
13
|
-
setInventorySlot:
|
|
14
|
-
flyTo:
|
|
13
|
+
setInventorySlot: setInventorySlot,
|
|
14
|
+
flyTo: flyTo,
|
|
15
15
|
startFlying,
|
|
16
16
|
stopFlying
|
|
17
17
|
}
|
|
@@ -23,7 +23,7 @@ function inject (bot, { version }) {
|
|
|
23
23
|
}
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
// WARN: This method should not be called twice on the same slot before first
|
|
26
|
+
// WARN: This method should not be called twice on the same slot before first promise succeeds
|
|
27
27
|
async function setInventorySlot (slot, item) {
|
|
28
28
|
assert(slot >= 0 && slot <= 44)
|
|
29
29
|
|
package/lib/plugins/digging.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { performance } = require('perf_hooks')
|
|
2
|
-
const { createDoneTask, createTask
|
|
2
|
+
const { createDoneTask, createTask } = require('../promise_utils')
|
|
3
3
|
const BlockFaces = require('prismarine-world').iterators.BlockFace
|
|
4
4
|
const { Vec3 } = require('vec3')
|
|
5
5
|
|
|
@@ -198,35 +198,12 @@ function inject (bot) {
|
|
|
198
198
|
return block.digTime(type, creative, bot.entity.isInWater, !bot.entity.onGround, enchantments, bot.entity.effects)
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
bot.dig =
|
|
201
|
+
bot.dig = dig
|
|
202
202
|
bot.stopDigging = noop
|
|
203
203
|
bot.canDigBlock = canDigBlock
|
|
204
204
|
bot.digTime = digTime
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
function callbackify (f) { // specifically for this function because cb could be the non-last parameter
|
|
208
|
-
return function (...args) {
|
|
209
|
-
const cbIndex = typeof args[1] === 'function' ? 1 : (typeof args[2] === 'function' ? 2 : 3)
|
|
210
|
-
const cb = args[cbIndex]
|
|
211
|
-
|
|
212
|
-
if (cbIndex === 1) args[1] = true
|
|
213
|
-
else if (typeof args[1] === 'string') args[1] = args[1] === 'ignore' ? args[1] : false
|
|
214
|
-
else args[1] = !!args[1] // coerce to boolean
|
|
215
|
-
|
|
216
|
-
return f(...args).then(r => {
|
|
217
|
-
if (cb) {
|
|
218
|
-
printCallbackDepreciation()
|
|
219
|
-
cb(undefined, r)
|
|
220
|
-
} return r
|
|
221
|
-
}, err => {
|
|
222
|
-
if (cb) {
|
|
223
|
-
printCallbackDepreciation()
|
|
224
|
-
cb(err)
|
|
225
|
-
} else throw err
|
|
226
|
-
})
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
207
|
function noop (err) {
|
|
231
208
|
if (err) throw err
|
|
232
209
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const { once } = require('events')
|
|
3
|
-
const { callbackify } = require('../promise_utils')
|
|
4
3
|
|
|
5
4
|
module.exports = inject
|
|
6
5
|
|
|
@@ -15,10 +14,10 @@ function inject (bot) {
|
|
|
15
14
|
|
|
16
15
|
resetEnchantmentOptions()
|
|
17
16
|
|
|
18
|
-
enchantmentTable.enchant =
|
|
19
|
-
enchantmentTable.takeTargetItem =
|
|
20
|
-
enchantmentTable.putTargetItem =
|
|
21
|
-
enchantmentTable.putLapis =
|
|
17
|
+
enchantmentTable.enchant = enchant
|
|
18
|
+
enchantmentTable.takeTargetItem = takeTargetItem
|
|
19
|
+
enchantmentTable.putTargetItem = putTargetItem
|
|
20
|
+
enchantmentTable.putLapis = putLapis
|
|
22
21
|
enchantmentTable.targetItem = function () { return this.slots[0] }
|
|
23
22
|
|
|
24
23
|
bot._client.on('craft_progress_bar', onUpdateWindowProperty)
|
|
@@ -100,5 +99,5 @@ function inject (bot) {
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
bot.openEnchantmentTable =
|
|
102
|
+
bot.openEnchantmentTable = openEnchantmentTable
|
|
104
103
|
}
|
package/lib/plugins/entities.js
CHANGED
|
@@ -588,6 +588,7 @@ function inject (bot, { version }) {
|
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
function useEntity (target, leftClick, x, y, z) {
|
|
591
|
+
const sneaking = bot.getControlState('sneak')
|
|
591
592
|
if (x && y && z) {
|
|
592
593
|
bot._client.write('use_entity', {
|
|
593
594
|
target: target.id,
|
|
@@ -595,13 +596,13 @@ function inject (bot, { version }) {
|
|
|
595
596
|
x,
|
|
596
597
|
y,
|
|
597
598
|
z,
|
|
598
|
-
sneaking
|
|
599
|
+
sneaking
|
|
599
600
|
})
|
|
600
601
|
} else {
|
|
601
602
|
bot._client.write('use_entity', {
|
|
602
603
|
target: target.id,
|
|
603
604
|
mouse: leftClick,
|
|
604
|
-
sneaking
|
|
605
|
+
sneaking
|
|
605
606
|
})
|
|
606
607
|
}
|
|
607
608
|
}
|
package/lib/plugins/fishing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { Vec3 } = require('vec3')
|
|
2
|
-
const {
|
|
2
|
+
const { createDoneTask, createTask } = require('../promise_utils')
|
|
3
3
|
|
|
4
4
|
module.exports = inject
|
|
5
5
|
|
|
@@ -54,5 +54,5 @@ function inject (bot) {
|
|
|
54
54
|
await fishingTask.promise
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
bot.fish =
|
|
57
|
+
bot.fish = fish
|
|
58
58
|
}
|
package/lib/plugins/furnace.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
|
-
const { callbackify } = require('../promise_utils')
|
|
3
2
|
|
|
4
3
|
module.exports = inject
|
|
5
4
|
|
|
@@ -25,11 +24,11 @@ function inject (bot) {
|
|
|
25
24
|
furnace.totalProgress = null
|
|
26
25
|
furnace.progress = null
|
|
27
26
|
furnace.progressSeconds = null
|
|
28
|
-
furnace.takeInput =
|
|
29
|
-
furnace.takeFuel =
|
|
30
|
-
furnace.takeOutput =
|
|
31
|
-
furnace.putInput =
|
|
32
|
-
furnace.putFuel =
|
|
27
|
+
furnace.takeInput = takeInput
|
|
28
|
+
furnace.takeFuel = takeFuel
|
|
29
|
+
furnace.takeOutput = takeOutput
|
|
30
|
+
furnace.putInput = putInput
|
|
31
|
+
furnace.putFuel = putFuel
|
|
33
32
|
furnace.inputItem = function () { return this.slots[0] }
|
|
34
33
|
furnace.fuelItem = function () { return this.slots[1] }
|
|
35
34
|
furnace.outputItem = function () { return this.slots[2] }
|
|
@@ -118,5 +117,5 @@ function inject (bot) {
|
|
|
118
117
|
return ticks * 0.05
|
|
119
118
|
}
|
|
120
119
|
|
|
121
|
-
bot.openFurnace =
|
|
120
|
+
bot.openFurnace = openFurnace
|
|
122
121
|
}
|
package/lib/plugins/inventory.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const { Vec3 } = require('vec3')
|
|
3
3
|
const { once } = require('events')
|
|
4
|
-
const {
|
|
4
|
+
const { sleep, createDoneTask, createTask, withTimeout } = require('../promise_utils')
|
|
5
5
|
|
|
6
6
|
module.exports = inject
|
|
7
7
|
|
|
@@ -306,7 +306,7 @@ function inject (bot, { version, hideErrors }) {
|
|
|
306
306
|
window.emit('close')
|
|
307
307
|
closeWindow(window)
|
|
308
308
|
}
|
|
309
|
-
window.withdraw =
|
|
309
|
+
window.withdraw = async (itemType, metadata, count) => {
|
|
310
310
|
if (bot.inventory.emptySlotCount() === 0) {
|
|
311
311
|
throw new Error('Unable to withdraw, Bot inventory is full.')
|
|
312
312
|
}
|
|
@@ -322,8 +322,8 @@ function inject (bot, { version, hideErrors }) {
|
|
|
322
322
|
destEnd: window.inventoryEnd
|
|
323
323
|
}
|
|
324
324
|
await transfer(options)
|
|
325
|
-
}
|
|
326
|
-
window.deposit =
|
|
325
|
+
}
|
|
326
|
+
window.deposit = async (itemType, metadata, count) => {
|
|
327
327
|
const options = {
|
|
328
328
|
window: window,
|
|
329
329
|
itemType,
|
|
@@ -335,7 +335,7 @@ function inject (bot, { version, hideErrors }) {
|
|
|
335
335
|
destEnd: window.inventoryStart
|
|
336
336
|
}
|
|
337
337
|
await transfer(options)
|
|
338
|
-
}
|
|
338
|
+
}
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
async function openBlock (block) {
|
|
@@ -643,21 +643,21 @@ function inject (bot, { version, hideErrors }) {
|
|
|
643
643
|
bot.emit(`setWindowItems:${window.id}`)
|
|
644
644
|
})
|
|
645
645
|
|
|
646
|
-
bot.activateBlock =
|
|
647
|
-
bot.activateEntity =
|
|
648
|
-
bot.activateEntityAt =
|
|
649
|
-
bot.consume =
|
|
646
|
+
bot.activateBlock = activateBlock
|
|
647
|
+
bot.activateEntity = activateEntity
|
|
648
|
+
bot.activateEntityAt = activateEntityAt
|
|
649
|
+
bot.consume = consume
|
|
650
650
|
bot.activateItem = activateItem
|
|
651
651
|
bot.deactivateItem = deactivateItem
|
|
652
652
|
|
|
653
653
|
// not really in the public API
|
|
654
|
-
bot.clickWindow =
|
|
654
|
+
bot.clickWindow = clickWindow
|
|
655
655
|
bot.putSelectedItemRange = putSelectedItemRange
|
|
656
656
|
bot.putAway = putAway
|
|
657
657
|
bot.closeWindow = closeWindow
|
|
658
|
-
bot.transfer =
|
|
659
|
-
bot.openBlock =
|
|
660
|
-
bot.openEntity =
|
|
661
|
-
bot.moveSlotItem =
|
|
658
|
+
bot.transfer = transfer
|
|
659
|
+
bot.openBlock = openBlock
|
|
660
|
+
bot.openEntity = openEntity
|
|
661
|
+
bot.moveSlotItem = moveSlotItem
|
|
662
662
|
bot.updateHeldItem = updateHeldItem
|
|
663
663
|
}
|
package/lib/plugins/physics.js
CHANGED
|
@@ -3,7 +3,7 @@ const assert = require('assert')
|
|
|
3
3
|
const math = require('../math')
|
|
4
4
|
const conv = require('../conversions')
|
|
5
5
|
const { performance } = require('perf_hooks')
|
|
6
|
-
const {
|
|
6
|
+
const { createDoneTask, createTask } = require('../promise_utils')
|
|
7
7
|
|
|
8
8
|
const { Physics, PlayerState } = require('prismarine-physics')
|
|
9
9
|
|
|
@@ -223,7 +223,7 @@ function inject (bot, { physicsEnabled }) {
|
|
|
223
223
|
}
|
|
224
224
|
})
|
|
225
225
|
|
|
226
|
-
bot.look =
|
|
226
|
+
bot.look = async (yaw, pitch, force) => {
|
|
227
227
|
if (!lookingTask.done) {
|
|
228
228
|
lookingTask.finish() // finish the previous one
|
|
229
229
|
}
|
|
@@ -245,15 +245,15 @@ function inject (bot, { physicsEnabled }) {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
await lookingTask.promise
|
|
248
|
-
}
|
|
248
|
+
}
|
|
249
249
|
|
|
250
|
-
bot.lookAt =
|
|
250
|
+
bot.lookAt = async (point, force) => {
|
|
251
251
|
const delta = point.minus(bot.entity.position.offset(0, bot.entity.height, 0))
|
|
252
252
|
const yaw = Math.atan2(-delta.x, -delta.z)
|
|
253
253
|
const groundDistance = Math.sqrt(delta.x * delta.x + delta.z * delta.z)
|
|
254
254
|
const pitch = Math.atan2(delta.y, groundDistance)
|
|
255
255
|
await bot.look(yaw, pitch, force)
|
|
256
|
-
}
|
|
256
|
+
}
|
|
257
257
|
|
|
258
258
|
// player position and look (clientbound)
|
|
259
259
|
bot._client.on('position', (packet) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { onceWithCleanup
|
|
1
|
+
const { onceWithCleanup } = require('../promise_utils')
|
|
2
2
|
|
|
3
3
|
module.exports = inject
|
|
4
4
|
|
|
@@ -24,6 +24,6 @@ function inject (bot) {
|
|
|
24
24
|
await placeBlockWithOptions(referenceBlock, faceVector, { swingArm: 'right' })
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
bot.placeBlock =
|
|
27
|
+
bot.placeBlock = placeBlock
|
|
28
28
|
bot._placeBlockWithOptions = placeBlockWithOptions
|
|
29
29
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
|
-
const { callbackify } = require('../promise_utils')
|
|
3
2
|
|
|
4
3
|
module.exports = inject
|
|
5
4
|
|
|
@@ -144,10 +143,10 @@ function inject (bot) {
|
|
|
144
143
|
return bot.clickWindow(slot, 1, 0)
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
bot.equip =
|
|
148
|
-
bot.unequip =
|
|
149
|
-
bot.toss =
|
|
150
|
-
bot.tossStack =
|
|
146
|
+
bot.equip = equip
|
|
147
|
+
bot.unequip = unequip
|
|
148
|
+
bot.toss = toss
|
|
149
|
+
bot.tossStack = tossStack
|
|
151
150
|
bot.setQuickBarSlot = setQuickBarSlot
|
|
152
151
|
bot.getEquipmentDestSlot = getDestSlot
|
|
153
152
|
bot.simpleClick = { leftMouse, rightMouse }
|
package/lib/plugins/villager.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const { once } = require('events')
|
|
3
|
-
const { callbackify } = require('../promise_utils')
|
|
4
3
|
|
|
5
4
|
module.exports = inject
|
|
6
5
|
|
|
@@ -249,6 +248,6 @@ function inject (bot, { version }) {
|
|
|
249
248
|
await bot.transfer(options)
|
|
250
249
|
}
|
|
251
250
|
|
|
252
|
-
bot.openVillager =
|
|
253
|
-
bot.trade =
|
|
251
|
+
bot.openVillager = openVillager
|
|
252
|
+
bot.trade = trade
|
|
254
253
|
}
|
package/lib/promise_utils.js
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
function printCallbackDepreciation () {
|
|
2
|
-
console.log('[depreciation notice] Callback are deprecated with mineflayer, use promise instead. They will be removed in version 4.0.0.')
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function callbackify (f) {
|
|
6
|
-
return function (...args) {
|
|
7
|
-
const cb = args[f.length]
|
|
8
|
-
return f(...args).then(r => {
|
|
9
|
-
if (cb) {
|
|
10
|
-
printCallbackDepreciation()
|
|
11
|
-
cb(undefined, r)
|
|
12
|
-
}
|
|
13
|
-
return r
|
|
14
|
-
}, err => {
|
|
15
|
-
if (cb) {
|
|
16
|
-
printCallbackDepreciation()
|
|
17
|
-
cb(err)
|
|
18
|
-
} else throw err
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
1
|
function sleep (ms) {
|
|
24
2
|
return new Promise(resolve => setTimeout(resolve, ms))
|
|
25
3
|
}
|
|
@@ -104,11 +82,9 @@ function withTimeout (promise, timeout) {
|
|
|
104
82
|
}
|
|
105
83
|
|
|
106
84
|
module.exports = {
|
|
107
|
-
callbackify,
|
|
108
85
|
sleep,
|
|
109
86
|
createTask,
|
|
110
87
|
createDoneTask,
|
|
111
88
|
onceWithCleanup,
|
|
112
|
-
withTimeout
|
|
113
|
-
printCallbackDepreciation
|
|
89
|
+
withTimeout
|
|
114
90
|
}
|