mineflayer 3.17.0 → 4.1.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/.github/workflows/ci.yml +1 -1
- package/README.md +1 -5
- package/docs/README.md +1 -5
- package/docs/api.md +135 -159
- package/docs/es/README_ES.md +6 -6
- package/docs/history.md +14 -0
- package/docs/tutorial.md +27 -78
- package/index.d.ts +39 -58
- package/lib/features.json +28 -28
- 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 +17 -15
- package/lib/plugins/physics.js +5 -5
- package/lib/plugins/place_block.js +2 -2
- package/lib/plugins/settings.js +24 -4
- package/lib/plugins/simple_inventory.js +4 -5
- package/lib/plugins/villager.js +2 -3
- package/lib/promise_utils.js +1 -25
- package/lib/version.js +1 -1
- package/package.json +3 -3
|
@@ -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
|
}
|
package/lib/plugins/settings.js
CHANGED
|
@@ -23,13 +23,27 @@ const viewDistanceToBits = {
|
|
|
23
23
|
function inject (bot, options) {
|
|
24
24
|
function setSettings (settings) {
|
|
25
25
|
extend(bot.settings, settings)
|
|
26
|
+
|
|
27
|
+
// chat
|
|
26
28
|
const chatBits = chatToBits[bot.settings.chat]
|
|
27
29
|
assert.ok(chatBits != null, `invalid chat setting: ${bot.settings.chat}`)
|
|
28
|
-
|
|
30
|
+
|
|
31
|
+
// view distance
|
|
32
|
+
let viewDistanceBits = null
|
|
33
|
+
if (typeof bot.settings.viewDistance === 'string') {
|
|
34
|
+
viewDistanceBits = viewDistanceToBits[bot.settings.viewDistance]
|
|
35
|
+
} else if (typeof bot.settings.viewDistance === 'number' && bot.settings.viewDistance > 0) { // Make sure view distance is a valid # || should be 2 or more
|
|
36
|
+
viewDistanceBits = bot.settings.viewDistance
|
|
37
|
+
}
|
|
29
38
|
assert.ok(viewDistanceBits != null, `invalid view distance setting: ${bot.settings.viewDistance}`)
|
|
39
|
+
|
|
40
|
+
// hand
|
|
30
41
|
const handBits = handToBits[bot.settings.mainHand]
|
|
31
42
|
assert.ok(handBits != null, `invalid main hand: ${bot.settings.mainHand}`)
|
|
32
|
-
|
|
43
|
+
|
|
44
|
+
// skin
|
|
45
|
+
// cape is inverted, not used at all (legacy?)
|
|
46
|
+
// bot.settings.showCape = !!bot.settings.showCape
|
|
33
47
|
const skinParts = bot.settings.skinParts.showCape << 0 |
|
|
34
48
|
bot.settings.skinParts.showJacket << 1 |
|
|
35
49
|
bot.settings.skinParts.showLeftSleeve << 2 |
|
|
@@ -37,13 +51,17 @@ function inject (bot, options) {
|
|
|
37
51
|
bot.settings.skinParts.showLeftPants << 4 |
|
|
38
52
|
bot.settings.skinParts.showRightPants << 5 |
|
|
39
53
|
bot.settings.skinParts.showHat << 6
|
|
54
|
+
|
|
55
|
+
// write the packet
|
|
40
56
|
bot._client.write('settings', {
|
|
41
57
|
locale: bot.settings.locale || 'en_US',
|
|
42
58
|
viewDistance: viewDistanceBits,
|
|
43
59
|
chatFlags: chatBits,
|
|
44
60
|
chatColors: bot.settings.colorsEnabled,
|
|
45
61
|
skinParts: skinParts,
|
|
46
|
-
mainHand: handBits
|
|
62
|
+
mainHand: handBits,
|
|
63
|
+
enableTextFiltering: bot.settings.enableTextFiltering,
|
|
64
|
+
enableServerListing: bot.settings.enableServerListing
|
|
47
65
|
})
|
|
48
66
|
}
|
|
49
67
|
|
|
@@ -67,7 +85,9 @@ function inject (bot, options) {
|
|
|
67
85
|
showHat: true
|
|
68
86
|
}
|
|
69
87
|
: options.skinParts,
|
|
70
|
-
mainHand: options.mainHand || 'right'
|
|
88
|
+
mainHand: options.mainHand || 'right',
|
|
89
|
+
enableTextFiltering: options.enableTextFiltering || false,
|
|
90
|
+
enableServerListing: options.enableServerListing || true
|
|
71
91
|
}
|
|
72
92
|
|
|
73
93
|
bot._client.once('login', () => {
|
|
@@ -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
|
}
|
package/lib/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
supportedVersions: ['1.8', '1.9', '1.10', '1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17', '1.18'],
|
|
3
|
-
testedVersions: ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.
|
|
3
|
+
testedVersions: ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2']
|
|
4
4
|
} // when updating testedVersions, make sure to update CI.yml
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mineflayer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "create minecraft bots with a stable, high level API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"minecraft-data": "^2.
|
|
25
|
-
"minecraft-protocol": "^1.
|
|
24
|
+
"minecraft-data": "^2.114.1",
|
|
25
|
+
"minecraft-protocol": "^1.31.0",
|
|
26
26
|
"prismarine-biome": "^1.1.1",
|
|
27
27
|
"prismarine-block": "^1.13.1",
|
|
28
28
|
"prismarine-chat": "^1.3.3",
|