mineflayer 4.4.0 → 4.5.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 +2 -0
- package/README.md +1 -1
- package/docs/README.md +1 -1
- package/docs/api.md +18 -9
- package/docs/history.md +25 -17
- package/docs/ru/FAQ_RU.md +1 -1
- package/docs/zh/README_ZH_CN.md +1 -1
- package/examples/anvil.js +4 -8
- package/examples/auto_totem.js +2 -3
- package/examples/block_entity.js +2 -7
- package/examples/blockfinder.js +2 -4
- package/examples/chest.js +6 -11
- package/examples/collectblock.js +1 -7
- package/examples/command_block.js +1 -6
- package/examples/digger.js +1 -2
- package/examples/farmer.js +3 -8
- package/examples/fisherman.js +2 -7
- package/examples/graffiti.js +2 -7
- package/examples/guard.js +1 -2
- package/examples/inventory.js +4 -6
- package/examples/jumper.js +1 -1
- package/examples/pathfinder/gps.js +1 -2
- package/examples/place_end_crystal/index.js +2 -9
- package/examples/python/basic.py +1 -2
- package/examples/python/chatterbox.py +1 -1
- package/examples/trader.js +4 -8
- package/index.d.ts +17 -24
- package/lib/bossbar.js +2 -2
- package/lib/loader.js +2 -2
- package/lib/plugins/anvil.js +1 -1
- package/lib/plugins/blocks.js +3 -3
- package/lib/plugins/book.js +1 -1
- package/lib/plugins/boss_bar.js +1 -1
- package/lib/plugins/chat.js +63 -12
- package/lib/plugins/chest.js +1 -2
- package/lib/plugins/craft.js +3 -3
- package/lib/plugins/creative.js +1 -1
- package/lib/plugins/entities.js +24 -7
- package/lib/plugins/game.js +14 -5
- package/lib/plugins/generic_place.js +1 -1
- package/lib/plugins/inventory.js +2 -2
- package/lib/plugins/place_entity.js +1 -1
- package/lib/plugins/tablist.js +1 -1
- package/lib/plugins/team.js +1 -1
- package/lib/plugins/villager.js +9 -7
- package/lib/scoreboard.js +1 -1
- package/lib/team.js +2 -2
- package/lib/version.js +2 -2
- package/package.json +10 -10
package/.github/workflows/ci.yml
CHANGED
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.
|
|
20
|
+
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18 and 1.19.
|
|
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.
|
|
20
|
+
* Supports Minecraft 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18 and 1.19.
|
|
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/api.md
CHANGED
|
@@ -150,9 +150,9 @@
|
|
|
150
150
|
- [Events](#events)
|
|
151
151
|
- ["chat" (username, message, translate, jsonMsg, matches)](#chat-username-message-translate-jsonmsg-matches)
|
|
152
152
|
- ["whisper" (username, message, translate, jsonMsg, matches)](#whisper-username-message-translate-jsonmsg-matches)
|
|
153
|
-
- ["actionBar" (jsonMsg)](#actionbar-jsonmsg)
|
|
154
|
-
- ["message" (jsonMsg, position)](#message-jsonmsg-position)
|
|
155
|
-
- ["messagestr" (message, messagePosition, jsonMsg)](#messagestr-message-messageposition-jsonmsg)
|
|
153
|
+
- ["actionBar" (jsonMsg, verified)](#actionbar-jsonmsg-verified)
|
|
154
|
+
- ["message" (jsonMsg, position, sender, verified)](#message-jsonmsg-position-sender-verified)
|
|
155
|
+
- ["messagestr" (message, messagePosition, jsonMsg, sender, verified)](#messagestr-message-messageposition-jsonmsg-sender-verified)
|
|
156
156
|
- ["inject_allowed"](#inject_allowed)
|
|
157
157
|
- ["login"](#login)
|
|
158
158
|
- ["spawn"](#spawn)
|
|
@@ -209,8 +209,8 @@
|
|
|
209
209
|
- ["noteHeard" (block, instrument, pitch)](#noteheard-block-instrument-pitch)
|
|
210
210
|
- ["pistonMove" (block, isPulling, direction)](#pistonmove-block-ispulling-direction)
|
|
211
211
|
- ["chestLidMove" (block, isOpen, block2)](#chestlidmove-block-isopen-block2)
|
|
212
|
-
- ["blockBreakProgressObserved" (block, destroyStage)](#blockbreakprogressobserved-block-destroystage)
|
|
213
|
-
- ["blockBreakProgressEnd" (block)](#blockbreakprogressend-block)
|
|
212
|
+
- ["blockBreakProgressObserved" (block, destroyStage, entity)](#blockbreakprogressobserved-block-destroystage-entity)
|
|
213
|
+
- ["blockBreakProgressEnd" (block, entity)](#blockbreakprogressend-block-entity)
|
|
214
214
|
- ["diggingCompleted" (block)](#diggingcompleted-block)
|
|
215
215
|
- ["diggingAborted" (block)](#diggingaborted-block)
|
|
216
216
|
- ["move"](#move)
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
- [bot.waitForChunksToLoad()](#botwaitforchunkstoload)
|
|
245
245
|
- [bot.blockInSight(maxSteps, vectorLength)](#botblockinsightmaxsteps-vectorlength)
|
|
246
246
|
- [bot.blockAtCursor(maxDistance=256)](#botblockatcursormaxdistance256)
|
|
247
|
-
- [bot.entityAtCursor(maxDistance
|
|
247
|
+
- [bot.entityAtCursor(maxDistance=3.5)](#botentityatcursormaxdistance35)
|
|
248
248
|
- [bot.blockAtEntityCursor(entity=bot.entity, maxDistance=256)](#botblockatentitycursorentitybotentity-maxdistance256)
|
|
249
249
|
- [bot.canSeeBlock(block)](#botcanseeblockblock)
|
|
250
250
|
- [bot.findBlocks(options)](#botfindblocksoptions)
|
|
@@ -1106,13 +1106,14 @@ Only emitted when a player chats to you privately.
|
|
|
1106
1106
|
* `jsonMsg` - unmodified JSON message from the server
|
|
1107
1107
|
* `matches` - array of returned matches from regular expressions. May be null
|
|
1108
1108
|
|
|
1109
|
-
#### "actionBar" (jsonMsg)
|
|
1109
|
+
#### "actionBar" (jsonMsg, verified)
|
|
1110
1110
|
|
|
1111
1111
|
Emitted for every server message which appears on the Action Bar.
|
|
1112
1112
|
|
|
1113
1113
|
* `jsonMsg` - unmodified JSON message from the server
|
|
1114
|
+
* `verified` -> null if non signed, true if signed and correct, false if signed and incorrect
|
|
1114
1115
|
|
|
1115
|
-
#### "message" (jsonMsg, position)
|
|
1116
|
+
#### "message" (jsonMsg, position, sender, verified)
|
|
1116
1117
|
|
|
1117
1118
|
Emitted for every server message, including chats.
|
|
1118
1119
|
|
|
@@ -1123,10 +1124,18 @@ Emitted for every server message, including chats.
|
|
|
1123
1124
|
* system
|
|
1124
1125
|
* game_info
|
|
1125
1126
|
|
|
1126
|
-
|
|
1127
|
+
* `sender` - UUID of sender if known (1.16+), else null
|
|
1128
|
+
|
|
1129
|
+
* `verified` -> null if non signed, true if signed and correct, false if signed and incorrect
|
|
1130
|
+
|
|
1131
|
+
#### "messagestr" (message, messagePosition, jsonMsg, sender, verified)
|
|
1127
1132
|
|
|
1128
1133
|
Alias for the "message" event but it calls .toString() on the message object to get a string for the message before emitting.
|
|
1129
1134
|
|
|
1135
|
+
* `sender` - UUID of sender if known (1.16+), else null
|
|
1136
|
+
|
|
1137
|
+
* `verified` -> null if non signed, true if signed and correct, false if signed and incorrect
|
|
1138
|
+
|
|
1130
1139
|
#### "inject_allowed"
|
|
1131
1140
|
Fires when the index file has been loaded, you can load mcData and plugins here but it's better to wait for "spawn" event.
|
|
1132
1141
|
|
package/docs/history.md
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
|
+
## 4.5.0
|
|
2
|
+
|
|
3
|
+
* 1.19 support (@extremeheat @rom1504 @FCKJohni @Shorent)
|
|
4
|
+
* refactoring examples to use bot.registry (@Epirito)
|
|
5
|
+
* Added barrel and coloured shulker boxes to openable windows (@lazydancer)
|
|
6
|
+
* types: Fix return type for openBlock and openEntity (@sefirosweb)
|
|
7
|
+
* Update activateEntity and activateEntityAt types (@amoraschi)
|
|
8
|
+
|
|
1
9
|
## 4.4.0
|
|
2
10
|
|
|
3
|
-
* Fix chatterbox example not getting dropped item
|
|
4
|
-
* Fix 404d link to license [#2601](https://github.com/PrismarineJS/mineflayer/pull/2601)
|
|
5
|
-
* Add bot.clickWindow mode disclaimer [#2595](https://github.com/PrismarineJS/mineflayer/pull/2595)
|
|
6
|
-
* Add spectator to GameMode types [#2627](https://github.com/PrismarineJS/mineflayer/pull/2627)
|
|
7
|
-
* Update types for isABed [#2628](https://github.com/PrismarineJS/mineflayer/pull/2628)
|
|
8
|
-
* Replace openChest with openContainer in docs and examples [#2656](https://github.com/PrismarineJS/mineflayer/pull/2656)
|
|
9
|
-
* Add ender chests as a chest type [#2642](https://github.com/PrismarineJS/mineflayer/pull/2642)
|
|
10
|
-
* Added method to wait until sleep function is in reality sleeping [#2617](https://github.com/PrismarineJS/mineflayer/pull/2617)
|
|
11
|
-
* Added type on move event [#2712](https://github.com/PrismarineJS/mineflayer/pull/2712)
|
|
12
|
-
* Added thunderState type [#2711](https://github.com/PrismarineJS/mineflayer/pull/2711)
|
|
13
|
-
* Fix type error on chest open [#2684](https://github.com/PrismarineJS/mineflayer/pull/2684)
|
|
14
|
-
* Add support for repeating and chain command blocks. [#2669](https://github.com/PrismarineJS/mineflayer/pull/2669)
|
|
15
|
-
* Add player object to blockBreakProgressEnd & observed. [#2647](https://github.com/PrismarineJS/mineflayer/pull/2647)
|
|
16
|
-
* Add entity to blockBreakProgress [#2648](https://github.com/PrismarineJS/mineflayer/pull/2648)
|
|
17
|
-
* Add direction support to activateBlock, openBlock [#2039](https://github.com/PrismarineJS/mineflayer/pull/2039)
|
|
18
|
-
* Add entityAtCursor function [#2077](https://github.com/PrismarineJS/mineflayer/pull/2077)
|
|
19
|
-
* Fix regex dos [#2350](https://github.com/PrismarineJS/mineflayer/pull/2350)
|
|
11
|
+
* Fix chatterbox example not getting dropped item (@u9g) [commit](https://github.com/PrismarineJS/mineflayer/commit/f860eac01a0418f4a3de749482d8cab681acc48a)
|
|
12
|
+
* Fix 404d link to license (@BalaM314) [#2601](https://github.com/PrismarineJS/mineflayer/pull/2601)
|
|
13
|
+
* Add bot.clickWindow mode disclaimer (@IceTank) [#2595](https://github.com/PrismarineJS/mineflayer/pull/2595)
|
|
14
|
+
* Add spectator to GameMode types (@IceTank) [#2627](https://github.com/PrismarineJS/mineflayer/pull/2627)
|
|
15
|
+
* Update types for isABed (@amoraschi) [#2628](https://github.com/PrismarineJS/mineflayer/pull/2628)
|
|
16
|
+
* Replace openChest with openContainer in docs and examples (@slightly-imperfect) [#2656](https://github.com/PrismarineJS/mineflayer/pull/2656)
|
|
17
|
+
* Add ender chests as a chest type (@RoseChilds) [#2642](https://github.com/PrismarineJS/mineflayer/pull/2642)
|
|
18
|
+
* Added method to wait until sleep function is in reality sleeping (@sefirosweb) [#2617](https://github.com/PrismarineJS/mineflayer/pull/2617)
|
|
19
|
+
* Added type on move event (@sefirosweb) [#2712](https://github.com/PrismarineJS/mineflayer/pull/2712)
|
|
20
|
+
* Added thunderState type (@sefirosweb) [#2711](https://github.com/PrismarineJS/mineflayer/pull/2711)
|
|
21
|
+
* Fix type error on chest open (@IceTank) [#2684](https://github.com/PrismarineJS/mineflayer/pull/2684)
|
|
22
|
+
* Add support for repeating and chain command blocks. (@mirkokral) [#2669](https://github.com/PrismarineJS/mineflayer/pull/2669)
|
|
23
|
+
* Add player object to blockBreakProgressEnd & observed. (@JackCrispy) [#2647](https://github.com/PrismarineJS/mineflayer/pull/2647)
|
|
24
|
+
* Add entity to blockBreakProgress (@JackCrispy ) [#2648](https://github.com/PrismarineJS/mineflayer/pull/2648)
|
|
25
|
+
* Add direction support to activateBlock, openBlock (@IceTank) [#2039](https://github.com/PrismarineJS/mineflayer/pull/2039)
|
|
26
|
+
* Add entityAtCursor function (@O-of) [#2077](https://github.com/PrismarineJS/mineflayer/pull/2077)
|
|
27
|
+
* Fix regex dos (@IceTank) [#2350](https://github.com/PrismarineJS/mineflayer/pull/2350)
|
|
20
28
|
|
|
21
29
|
## 4.3.0
|
|
22
30
|
|
package/docs/ru/FAQ_RU.md
CHANGED
|
@@ -54,7 +54,7 @@ function getLore (item) {
|
|
|
54
54
|
if (item.nbt == null) return message
|
|
55
55
|
|
|
56
56
|
const nbt = require('prismarine-nbt')
|
|
57
|
-
const ChatMessage = require('prismarine-chat')(bot.
|
|
57
|
+
const ChatMessage = require('prismarine-chat')(bot.registry)
|
|
58
58
|
|
|
59
59
|
const data = nbt.simplify(item.nbt)
|
|
60
60
|
const display = data.display
|
package/docs/zh/README_ZH_CN.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
[](https://gitpod.io/#https://github.com/PrismarineJS/mineflayer)
|
|
11
11
|
[](https://colab.research.google.com/github/PrismarineJS/mineflayer/blob/master/docs/mineflayer.ipynb)
|
|
12
12
|
|
|
13
|
-
| <sub>EN</sub> [English](README.md) | <sub>RU</sub> [русский](ru/README_RU.md) | <sub>ES</sub> [Español](es/README_ES.md) | <sub>FR</sub> [Français](fr/README_FR.md) | <sub>TR</sub> [Türkçe](tr/README_TR.md) | <sub>ZH</sub> [中文](zh/README_ZH_CN.md)
|
|
13
|
+
| <sub>EN</sub> [English](../README.md) | <sub>RU</sub> [русский](../ru/README_RU.md) | <sub>ES</sub> [Español](../es/README_ES.md) | <sub>FR</sub> [Français](../fr/README_FR.md) | <sub>TR</sub> [Türkçe](../tr/README_TR.md) | <sub>ZH</sub> [中文](../zh/README_ZH_CN.md)
|
|
14
14
|
|-------------------------|----------------------------|----------------------------|----------------------------|----------------------------|----------------------------|
|
|
15
15
|
|
|
16
16
|
使用强大、稳定、高级的JavaScript [API](../api.md) 来开发Minecraft机器人,同时支持 Python。
|
package/examples/anvil.js
CHANGED
|
@@ -29,10 +29,6 @@ const bot = mineflayer.createBot({
|
|
|
29
29
|
password: process.argv[5]
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
-
let mcData
|
|
33
|
-
|
|
34
|
-
bot.on('spawn', () => { mcData = require('minecraft-data')(bot.version) })
|
|
35
|
-
|
|
36
32
|
bot.on('chat', async (username, message) => {
|
|
37
33
|
const command = message.split(' ')
|
|
38
34
|
|
|
@@ -105,10 +101,10 @@ function sayItems (items = bot.inventory.items()) {
|
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
function getAnvilIds () {
|
|
108
|
-
const matchingBlocks = [
|
|
109
|
-
if (
|
|
110
|
-
matchingBlocks.push(
|
|
111
|
-
matchingBlocks.push(
|
|
104
|
+
const matchingBlocks = [bot.registry.blocksByName.anvil.id]
|
|
105
|
+
if (bot.registry.blocksByName?.chipped_anvil) {
|
|
106
|
+
matchingBlocks.push(bot.registry.blocksByName.chipped_anvil.id)
|
|
107
|
+
matchingBlocks.push(bot.registry.blocksByName.damaged_anvil.id)
|
|
112
108
|
}
|
|
113
109
|
return matchingBlocks
|
|
114
110
|
}
|
package/examples/auto_totem.js
CHANGED
|
@@ -17,9 +17,8 @@ const bot = mineflayer.createBot({
|
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
bot.on('spawn', () => {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
if (mcData.itemsByName.totem_of_undying) {
|
|
20
|
+
const totemId = bot.registry.itemsByName.totem_of_undying.id // Get the correct id
|
|
21
|
+
if (bot.registry.itemsByName.totem_of_undying) {
|
|
23
22
|
setInterval(() => {
|
|
24
23
|
const totem = bot.inventory.findInventoryItem(totemId, null)
|
|
25
24
|
if (totem) {
|
package/examples/block_entity.js
CHANGED
|
@@ -16,11 +16,6 @@ const bot = mineflayer.createBot({
|
|
|
16
16
|
password: process.argv[5]
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
let mcData
|
|
20
|
-
bot.on('inject_allowed', () => {
|
|
21
|
-
mcData = require('minecraft-data')(bot.version)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
19
|
bot.on('message', (cm) => {
|
|
25
20
|
if (cm.toString().includes('spawner')) {
|
|
26
21
|
spawner()
|
|
@@ -30,9 +25,9 @@ bot.on('message', (cm) => {
|
|
|
30
25
|
function spawner () {
|
|
31
26
|
let blockName
|
|
32
27
|
if (bot.supportFeature('mobSpawner')) {
|
|
33
|
-
blockName =
|
|
28
|
+
blockName = bot.registry.blocksByName.mob_spawner.id
|
|
34
29
|
} else if (bot.supportFeature('spawner')) {
|
|
35
|
-
blockName =
|
|
30
|
+
blockName = bot.registry.blocksByName.spawner.id
|
|
36
31
|
}
|
|
37
32
|
const block = bot.findBlock({
|
|
38
33
|
matching: blockName,
|
package/examples/blockfinder.js
CHANGED
|
@@ -20,8 +20,6 @@ const bot = mineflayer.createBot({
|
|
|
20
20
|
bot.on('chat', async (username, message) => {
|
|
21
21
|
if (username === bot.username) return
|
|
22
22
|
|
|
23
|
-
const mcData = require('minecraft-data')(bot.version)
|
|
24
|
-
|
|
25
23
|
if (message === 'loaded') {
|
|
26
24
|
console.log(bot.entity.position)
|
|
27
25
|
await bot.waitForChunksToLoad()
|
|
@@ -30,11 +28,11 @@ bot.on('chat', async (username, message) => {
|
|
|
30
28
|
|
|
31
29
|
if (message.startsWith('find')) {
|
|
32
30
|
const name = message.split(' ')[1]
|
|
33
|
-
if (
|
|
31
|
+
if (bot.registry.blocksByName[name] === undefined) {
|
|
34
32
|
bot.chat(`${name} is not a block name`)
|
|
35
33
|
return
|
|
36
34
|
}
|
|
37
|
-
const ids = [
|
|
35
|
+
const ids = [bot.registry.blocksByName[name].id]
|
|
38
36
|
|
|
39
37
|
const startTime = performance.now()
|
|
40
38
|
const blocks = bot.findBlocks({ matching: ids, maxDistance: 128, count: 10 })
|
package/examples/chest.js
CHANGED
|
@@ -33,11 +33,6 @@ const bot = mineflayer.createBot({
|
|
|
33
33
|
password: process.argv[5]
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
let mcData
|
|
37
|
-
bot.once('inject_allowed', () => {
|
|
38
|
-
mcData = require('minecraft-data')(bot.version)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
36
|
bot.on('experience', () => {
|
|
42
37
|
bot.chat(`I am level ${bot.experience.level}`)
|
|
43
38
|
})
|
|
@@ -86,7 +81,7 @@ async function watchChest (minecart, blocks = []) {
|
|
|
86
81
|
let chestToOpen
|
|
87
82
|
if (minecart) {
|
|
88
83
|
chestToOpen = Object.keys(bot.entities)
|
|
89
|
-
.map(id => bot.entities[id]).find(e => e.entityType ===
|
|
84
|
+
.map(id => bot.entities[id]).find(e => e.entityType === bot.registry.entitiesByName.chest_minecart &&
|
|
90
85
|
e.objectData.intField === 1 &&
|
|
91
86
|
bot.entity.position.distanceTo(e.position) < 3)
|
|
92
87
|
if (!chestToOpen) {
|
|
@@ -95,7 +90,7 @@ async function watchChest (minecart, blocks = []) {
|
|
|
95
90
|
}
|
|
96
91
|
} else {
|
|
97
92
|
chestToOpen = bot.findBlock({
|
|
98
|
-
matching: blocks.map(name =>
|
|
93
|
+
matching: blocks.map(name => bot.registry.blocksByName[name].id),
|
|
99
94
|
maxDistance: 6
|
|
100
95
|
})
|
|
101
96
|
if (!chestToOpen) {
|
|
@@ -170,7 +165,7 @@ async function watchChest (minecart, blocks = []) {
|
|
|
170
165
|
|
|
171
166
|
async function watchFurnace () {
|
|
172
167
|
const furnaceBlock = bot.findBlock({
|
|
173
|
-
matching: ['furnace', 'lit_furnace'].filter(name =>
|
|
168
|
+
matching: ['furnace', 'lit_furnace'].filter(name => bot.registry.blocksByName[name] !== undefined).map(name => bot.registry.blocksByName[name].id),
|
|
174
169
|
maxDistance: 6
|
|
175
170
|
})
|
|
176
171
|
if (!furnaceBlock) {
|
|
@@ -256,7 +251,7 @@ async function watchFurnace () {
|
|
|
256
251
|
|
|
257
252
|
async function watchEnchantmentTable () {
|
|
258
253
|
const enchantTableBlock = bot.findBlock({
|
|
259
|
-
matching: ['enchanting_table'].map(name =>
|
|
254
|
+
matching: ['enchanting_table'].map(name => bot.registry.blocksByName[name].id),
|
|
260
255
|
maxDistance: 6
|
|
261
256
|
})
|
|
262
257
|
if (!enchantTableBlock) {
|
|
@@ -322,8 +317,8 @@ async function watchEnchantmentTable () {
|
|
|
322
317
|
}
|
|
323
318
|
|
|
324
319
|
async function addLapis () {
|
|
325
|
-
const item = itemByType(table.window.items(), ['dye', 'purple_dye', 'lapis_lazuli'].filter(name =>
|
|
326
|
-
.map(name =>
|
|
320
|
+
const item = itemByType(table.window.items(), ['dye', 'purple_dye', 'lapis_lazuli'].filter(name => bot.registry.itemByName[name] !== undefined)
|
|
321
|
+
.map(name => bot.registry.itemByName[name].id))
|
|
327
322
|
if (item) {
|
|
328
323
|
try {
|
|
329
324
|
await table.putLapis(item)
|
package/examples/collectblock.js
CHANGED
|
@@ -26,19 +26,13 @@ const bot = mineflayer.createBot({
|
|
|
26
26
|
bot.loadPlugin(pathfinder)
|
|
27
27
|
bot.loadPlugin(collectBlock)
|
|
28
28
|
|
|
29
|
-
// Load mc data
|
|
30
|
-
let mcData
|
|
31
|
-
bot.once('spawn', () => {
|
|
32
|
-
mcData = require('minecraft-data')(bot.version)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
29
|
// Listen for when a player says "collect [something]" in chat
|
|
36
30
|
bot.on('chat', (username, message) => {
|
|
37
31
|
const args = message.split(' ')
|
|
38
32
|
if (args[0] !== 'collect') return
|
|
39
33
|
|
|
40
34
|
// Get the correct block type
|
|
41
|
-
const blockType =
|
|
35
|
+
const blockType = bot.registry.blocksByName[args[1]]
|
|
42
36
|
if (!blockType) {
|
|
43
37
|
bot.chat("I don't know any blocks with that name.")
|
|
44
38
|
return
|
|
@@ -16,18 +16,13 @@ const bot = mineflayer.createBot({
|
|
|
16
16
|
password: process.argv[5]
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
let mcData
|
|
20
|
-
bot.once('inject_allowed', () => {
|
|
21
|
-
mcData = require('minecraft-data')(bot.version)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
19
|
bot.on('chat', (username, message) => {
|
|
25
20
|
if (username === bot.username) return
|
|
26
21
|
const command = message.split(' ')
|
|
27
22
|
switch (true) {
|
|
28
23
|
case /^setCommandBlock (.+)$/.test(message): {
|
|
29
24
|
const commandBlock = bot.findBlock({
|
|
30
|
-
matching:
|
|
25
|
+
matching: bot.registry.blocksByName.command_block.id
|
|
31
26
|
})
|
|
32
27
|
bot.setCommandBlock(commandBlock.position, command[1], false)
|
|
33
28
|
break
|
package/examples/digger.js
CHANGED
|
@@ -104,7 +104,6 @@ function build () {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
async function equipDirt () {
|
|
107
|
-
const mcData = require('minecraft-data')(bot.version)
|
|
108
107
|
let itemsByName
|
|
109
108
|
if (bot.supportFeature('itemsAreNotBlocks')) {
|
|
110
109
|
itemsByName = 'itemsByName'
|
|
@@ -112,7 +111,7 @@ async function equipDirt () {
|
|
|
112
111
|
itemsByName = 'blocksByName'
|
|
113
112
|
}
|
|
114
113
|
try {
|
|
115
|
-
await bot.equip(
|
|
114
|
+
await bot.equip(bot.registry[itemsByName].dirt.id, 'hand')
|
|
116
115
|
bot.chat('equipped dirt')
|
|
117
116
|
} catch (err) {
|
|
118
117
|
bot.chat(`unable to equip dirt: ${err.message}`)
|
package/examples/farmer.js
CHANGED
|
@@ -13,18 +13,13 @@ const bot = mineflayer.createBot({
|
|
|
13
13
|
password: process.argv[5]
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
let mcData
|
|
17
|
-
bot.on('inject_allowed', () => {
|
|
18
|
-
mcData = require('minecraft-data')(bot.version)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
16
|
// To fish we have to give bot the seeds
|
|
22
17
|
// /give farmer wheat_seeds 64
|
|
23
18
|
|
|
24
19
|
function blockToSow () {
|
|
25
20
|
return bot.findBlock({
|
|
26
21
|
point: bot.entity.position,
|
|
27
|
-
matching:
|
|
22
|
+
matching: bot.registry.blocksByName.farmland.id,
|
|
28
23
|
maxDistance: 6,
|
|
29
24
|
useExtraInfo: (block) => {
|
|
30
25
|
const blockAbove = bot.blockAt(block.position.offset(0, 1, 0))
|
|
@@ -38,7 +33,7 @@ function blockToHarvest () {
|
|
|
38
33
|
point: bot.entity.position,
|
|
39
34
|
maxDistance: 6,
|
|
40
35
|
matching: (block) => {
|
|
41
|
-
return block && block.type ===
|
|
36
|
+
return block && block.type === bot.registry.blocksByName.wheat.id && block.metadata === 7
|
|
42
37
|
}
|
|
43
38
|
})
|
|
44
39
|
}
|
|
@@ -56,7 +51,7 @@ async function loop () {
|
|
|
56
51
|
while (1) {
|
|
57
52
|
const toSow = blockToSow()
|
|
58
53
|
if (toSow) {
|
|
59
|
-
await bot.equip(
|
|
54
|
+
await bot.equip(bot.registry.itemsByName.wheat_seeds.id, 'hand')
|
|
60
55
|
await bot.placeBlock(toSow, new Vec3(0, 1, 0))
|
|
61
56
|
} else {
|
|
62
57
|
break
|
package/examples/fisherman.js
CHANGED
|
@@ -12,11 +12,6 @@ const bot = mineflayer.createBot({
|
|
|
12
12
|
password: process.argv[5]
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
let mcData
|
|
16
|
-
bot.on('inject_allowed', () => {
|
|
17
|
-
mcData = require('minecraft-data')(bot.version)
|
|
18
|
-
})
|
|
19
|
-
|
|
20
15
|
// To fish we have to give bot the fishing rod and teleport bot to the water
|
|
21
16
|
// /give fisherman fishing_rod 1
|
|
22
17
|
// /teleport fisherman ~ ~ ~
|
|
@@ -50,7 +45,7 @@ function onCollect (player, entity) {
|
|
|
50
45
|
async function startFishing () {
|
|
51
46
|
bot.chat('Fishing')
|
|
52
47
|
try {
|
|
53
|
-
await bot.equip(
|
|
48
|
+
await bot.equip(bot.registry.itemsByName.fishing_rod.id, 'hand')
|
|
54
49
|
} catch (err) {
|
|
55
50
|
return bot.chat(err.message)
|
|
56
51
|
}
|
|
@@ -78,7 +73,7 @@ async function eat () {
|
|
|
78
73
|
stopFishing()
|
|
79
74
|
|
|
80
75
|
try {
|
|
81
|
-
await bot.equip(
|
|
76
|
+
await bot.equip(bot.registry.itemsByName.fish.id, 'hand')
|
|
82
77
|
} catch (err) {
|
|
83
78
|
return bot.chat(err.message)
|
|
84
79
|
}
|
package/examples/graffiti.js
CHANGED
|
@@ -23,11 +23,6 @@ const bot = mineflayer.createBot({
|
|
|
23
23
|
password: process.argv[5]
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
let mcData
|
|
27
|
-
bot.once('inject_allowed', () => {
|
|
28
|
-
mcData = require('minecraft-data')(bot.version)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
26
|
bot.on('chat', (username, message) => {
|
|
32
27
|
if (username === bot.username) return
|
|
33
28
|
switch (true) {
|
|
@@ -49,7 +44,7 @@ function watchPaintingOrSign () {
|
|
|
49
44
|
}
|
|
50
45
|
})
|
|
51
46
|
const signBlock = bot.findBlock({
|
|
52
|
-
matching: ['painting', 'sign'].map(name =>
|
|
47
|
+
matching: ['painting', 'sign'].map(name => bot.registry.blocksByName[name].id)
|
|
53
48
|
})
|
|
54
49
|
if (signBlock) {
|
|
55
50
|
bot.chat(`The sign says: ${signBlock.signText}`)
|
|
@@ -62,7 +57,7 @@ function watchPaintingOrSign () {
|
|
|
62
57
|
|
|
63
58
|
function updateSign (message) {
|
|
64
59
|
const signBlock = bot.findBlock({
|
|
65
|
-
matching: ['painting', 'sign'].map(name =>
|
|
60
|
+
matching: ['painting', 'sign'].map(name => bot.registry.blocksByName[name].id)
|
|
66
61
|
})
|
|
67
62
|
if (signBlock) {
|
|
68
63
|
bot.updateSign(signBlock, message.split(' ').slice(1).join(' '))
|
package/examples/guard.js
CHANGED
|
@@ -42,8 +42,7 @@ function stopGuarding () {
|
|
|
42
42
|
|
|
43
43
|
// Pathfinder to the guard position
|
|
44
44
|
function moveToGuardPos () {
|
|
45
|
-
|
|
46
|
-
bot.pathfinder.setMovements(new Movements(bot, mcData))
|
|
45
|
+
bot.pathfinder.setMovements(new Movements(bot))
|
|
47
46
|
bot.pathfinder.setGoal(new goals.GoalBlock(guardPos.x, guardPos.y, guardPos.z))
|
|
48
47
|
}
|
|
49
48
|
|
package/examples/inventory.js
CHANGED
|
@@ -67,7 +67,7 @@ bot.on('chat', async (username, message) => {
|
|
|
67
67
|
function sayItems (items = null) {
|
|
68
68
|
if (!items) {
|
|
69
69
|
items = bot.inventory.items()
|
|
70
|
-
if (
|
|
70
|
+
if (bot.registry.isNewerOrEqualTo('1.9') && bot.inventory.slots[45]) items.push(bot.inventory.slots[45])
|
|
71
71
|
}
|
|
72
72
|
const output = items.map(itemToString).join(', ')
|
|
73
73
|
if (output) {
|
|
@@ -127,10 +127,8 @@ function useEquippedItem () {
|
|
|
127
127
|
|
|
128
128
|
async function craftItem (name, amount) {
|
|
129
129
|
amount = parseInt(amount, 10)
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const item = mcData.itemsByName[name]
|
|
133
|
-
const craftingTableID = mcData.blocksByName.crafting_table.id
|
|
130
|
+
const item = bot.registry.itemsByName[name]
|
|
131
|
+
const craftingTableID = bot.registry.blocksByName.crafting_table.id
|
|
134
132
|
|
|
135
133
|
const craftingTable = bot.findBlock({
|
|
136
134
|
matching: craftingTableID
|
|
@@ -164,6 +162,6 @@ function itemToString (item) {
|
|
|
164
162
|
|
|
165
163
|
function itemByName (name) {
|
|
166
164
|
const items = bot.inventory.items()
|
|
167
|
-
if (
|
|
165
|
+
if (bot.registry.isNewerOrEqualTo('1.9') && bot.inventory.slots[45]) items.push(bot.inventory.slots[45])
|
|
168
166
|
return items.filter(item => item.name === name)[0]
|
|
169
167
|
}
|
package/examples/jumper.js
CHANGED
|
@@ -63,7 +63,7 @@ bot.on('chat', (username, message) => {
|
|
|
63
63
|
}
|
|
64
64
|
break
|
|
65
65
|
case 'mount':
|
|
66
|
-
entity = bot.nearestEntity((entity) => { return entity.
|
|
66
|
+
entity = bot.nearestEntity((entity) => { return entity.name === 'minecart' })
|
|
67
67
|
if (entity) {
|
|
68
68
|
bot.mount(entity)
|
|
69
69
|
} else {
|
|
@@ -20,8 +20,7 @@ const RANGE_GOAL = 1 // get within this radius of the player
|
|
|
20
20
|
bot.loadPlugin(pathfinder)
|
|
21
21
|
|
|
22
22
|
bot.once('spawn', () => {
|
|
23
|
-
const
|
|
24
|
-
const defaultMove = new Movements(bot, mcData)
|
|
23
|
+
const defaultMove = new Movements(bot)
|
|
25
24
|
|
|
26
25
|
bot.on('chat', (username, message) => {
|
|
27
26
|
if (username === bot.username) return
|
|
@@ -22,14 +22,7 @@ const bot = mineflayer.createBot({
|
|
|
22
22
|
|
|
23
23
|
const MAX_DIST_FROM_BLOCK_TO_PLACE = 4
|
|
24
24
|
|
|
25
|
-
let mcData = null
|
|
26
|
-
bot.once('spawn', () => {
|
|
27
|
-
mcData = require('minecraft-data')(bot.version)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
25
|
bot.on('chat', async (ign, msg) => {
|
|
31
|
-
if (!mcData) mcData = require('minecraft-data')(bot.version)
|
|
32
|
-
|
|
33
26
|
// solve where the bot will place the crystal near
|
|
34
27
|
let findBlocksNearPoint = null
|
|
35
28
|
if (msg === 'place crystal near bot') {
|
|
@@ -44,13 +37,13 @@ bot.on('chat', async (ign, msg) => {
|
|
|
44
37
|
}
|
|
45
38
|
|
|
46
39
|
// find end crystal(s) in inventory
|
|
47
|
-
const item = bot.inventory.findInventoryItem(
|
|
40
|
+
const item = bot.inventory.findInventoryItem(bot.registry.itemsByName.end_crystal.id)
|
|
48
41
|
if (!item) bot.chat("I don't have any ender crystals")
|
|
49
42
|
|
|
50
43
|
// find the crystal
|
|
51
44
|
const block = bot.findBlock({
|
|
52
45
|
point: findBlocksNearPoint,
|
|
53
|
-
matching: ['bedrock', 'obsidian'].map(blockName =>
|
|
46
|
+
matching: ['bedrock', 'obsidian'].map(blockName => bot.registry.blocksByName[blockName].id),
|
|
54
47
|
useExtraInfo: block => {
|
|
55
48
|
const hasAirAbove = bot.blockAt(block.position.offset(0, 1, 0)).name === 'air'
|
|
56
49
|
const botNotStandingOnBlock = block.position.xzDistanceTo(bot.entity.position) > 2
|
package/examples/python/basic.py
CHANGED
|
@@ -17,8 +17,7 @@ print("Started mineflayer")
|
|
|
17
17
|
@On(bot, 'spawn')
|
|
18
18
|
def handle(*args):
|
|
19
19
|
print("I spawned 👋")
|
|
20
|
-
|
|
21
|
-
movements = pathfinder.Movements(bot, mcData)
|
|
20
|
+
movements = pathfinder.Movements(bot)
|
|
22
21
|
|
|
23
22
|
@On(bot, 'chat')
|
|
24
23
|
def handleMsg(this, sender, message, *args):
|
package/examples/trader.js
CHANGED
|
@@ -25,10 +25,6 @@ const bot = mineflayer.createBot({
|
|
|
25
25
|
username: process.argv[4] ? process.argv[4] : 'trader',
|
|
26
26
|
password: process.argv[5]
|
|
27
27
|
})
|
|
28
|
-
let mcData
|
|
29
|
-
bot.once('inject_allowed', () => {
|
|
30
|
-
mcData = require('minecraft-data')(bot.version)
|
|
31
|
-
})
|
|
32
28
|
|
|
33
29
|
bot.on('chat', (username, message) => {
|
|
34
30
|
if (username === bot.username) return
|
|
@@ -50,7 +46,7 @@ bot.on('chat', (username, message) => {
|
|
|
50
46
|
})
|
|
51
47
|
|
|
52
48
|
function showVillagers () {
|
|
53
|
-
const villagers = Object.keys(bot.entities).map(id => bot.entities[id]).filter(e => e.entityType ===
|
|
49
|
+
const villagers = Object.keys(bot.entities).map(id => bot.entities[id]).filter(e => e.entityType === bot.registry.entitiesByName.villager.id)
|
|
54
50
|
const closeVillagersId = villagers.filter(e => bot.entity.position.distanceTo(e.position) < 3).map(e => e.id)
|
|
55
51
|
bot.chat(`found ${villagers.length} villagers`)
|
|
56
52
|
bot.chat(`villager(s) you can trade with: ${closeVillagersId.join(', ')}`)
|
|
@@ -69,7 +65,7 @@ async function showTrades (id) {
|
|
|
69
65
|
case !e:
|
|
70
66
|
bot.chat(`cant find entity with id ${id}`)
|
|
71
67
|
break
|
|
72
|
-
case e.entityType !==
|
|
68
|
+
case e.entityType !== bot.registry.entitiesByName.villager.id:
|
|
73
69
|
bot.chat('entity is not a villager')
|
|
74
70
|
break
|
|
75
71
|
case bot.entity.position.distanceTo(e.position) > 3:
|
|
@@ -91,7 +87,7 @@ async function trade (id, index, count) {
|
|
|
91
87
|
case !e:
|
|
92
88
|
bot.chat(`cant find entity with id ${id}`)
|
|
93
89
|
break
|
|
94
|
-
case e.entityType !==
|
|
90
|
+
case e.entityType !== bot.registry.entitiesByName.villager.id:
|
|
95
91
|
bot.chat('entity is not a villager')
|
|
96
92
|
break
|
|
97
93
|
case bot.entity.position.distanceTo(e.position) > 3:
|
|
@@ -168,7 +164,7 @@ function stringifyItem (item) {
|
|
|
168
164
|
text += ` enchanted with ${(ench || StoredEnchantments).value.value.map((e) => {
|
|
169
165
|
const lvl = e.lvl.value
|
|
170
166
|
const id = e.id.value
|
|
171
|
-
return
|
|
167
|
+
return bot.registry.enchantments[id].displayName + ' ' + lvl
|
|
172
168
|
}).join(' ')}`
|
|
173
169
|
}
|
|
174
170
|
}
|