mineflayer 4.12.0 → 4.13.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 +3 -3
- package/.github/workflows/npm-publish.yml +1 -1
- package/.gitpod.yml +0 -2
- package/README.md +23 -2
- package/docs/README.md +23 -2
- package/docs/history.md +7 -0
- package/examples/armor_stand.js +1 -1
- package/examples/chatterbox.js +5 -5
- package/examples/guard.js +1 -1
- package/examples/jumper.js +2 -2
- package/examples/python/chatterbox.py +5 -5
- package/index.js +2 -2
- package/lib/plugins/entities.js +0 -3
- package/lib/plugins/physics.js +3 -3
- package/package.json +2 -2
- package/.gitpod.DockerFile +0 -11
package/.github/workflows/ci.yml
CHANGED
|
@@ -12,10 +12,10 @@ jobs:
|
|
|
12
12
|
|
|
13
13
|
steps:
|
|
14
14
|
- uses: actions/checkout@v2
|
|
15
|
-
- name: Use Node.js
|
|
15
|
+
- name: Use Node.js 18.x
|
|
16
16
|
uses: actions/setup-node@v1.4.4
|
|
17
17
|
with:
|
|
18
|
-
node-version:
|
|
18
|
+
node-version: 18.x
|
|
19
19
|
- run: npm i && npm run lint
|
|
20
20
|
|
|
21
21
|
MinecraftServer:
|
|
@@ -46,7 +46,7 @@ jobs:
|
|
|
46
46
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
47
47
|
uses: actions/setup-node@v1.4.4
|
|
48
48
|
with:
|
|
49
|
-
node-version:
|
|
49
|
+
node-version: 18.x
|
|
50
50
|
- name: Setup Java JDK
|
|
51
51
|
uses: actions/setup-java@v1.4.3
|
|
52
52
|
with:
|
package/.gitpod.yml
CHANGED
package/README.md
CHANGED
|
@@ -80,11 +80,11 @@ const mineflayer = require('mineflayer')
|
|
|
80
80
|
|
|
81
81
|
const bot = mineflayer.createBot({
|
|
82
82
|
host: 'localhost', // minecraft server ip
|
|
83
|
-
username: '
|
|
83
|
+
username: 'Bot', // username or email, switch if you want to change accounts
|
|
84
84
|
auth: 'microsoft' // for offline mode servers, you can set this to 'offline'
|
|
85
85
|
// port: 25565, // only set if you need a port that isn't 25565
|
|
86
86
|
// version: false, // only set if you need a specific version or snapshot (ie: "1.8.9" or "1.16.5"), otherwise it's set automatically
|
|
87
|
-
// password: '12345678' // set if you want to use password-based auth (may be unreliable)
|
|
87
|
+
// password: '12345678' // set if you want to use password-based auth (may be unreliable). If specified, the `username` must be an email
|
|
88
88
|
})
|
|
89
89
|
|
|
90
90
|
bot.on('chat', (username, message) => {
|
|
@@ -97,6 +97,26 @@ bot.on('kicked', console.log)
|
|
|
97
97
|
bot.on('error', console.log)
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
If `auth` is set to `microsoft`, you will be prompted to login to microsoft.com with a code in your browser. After signing in on your browser,
|
|
101
|
+
the bot will automatically obtain and cache authentication tokens in the local file system so you don't have to sign-in again.
|
|
102
|
+
To switch the account, update the supplied `username`. By default, cached tokens will be stored in your user's .minecraft folder.
|
|
103
|
+
For more information on these options and others, see node-minecraft-protocol's [API doc](https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/docs/API.md#mccreateclientoptions).
|
|
104
|
+
|
|
105
|
+
#### Connecting to a Realm
|
|
106
|
+
|
|
107
|
+
To join a Realm that your Minecraft account has been invited to, you can pass a `realms` object with a selector function like below.
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
const client = mineflayer.createBot({
|
|
111
|
+
username: 'email@example.com', // minecraft username
|
|
112
|
+
realms: {
|
|
113
|
+
// This function is called with an array of Realms the account can join. It should return the one it wants to join.
|
|
114
|
+
pickRealm: (realms) => realms[0]
|
|
115
|
+
},
|
|
116
|
+
auth: 'microsoft'
|
|
117
|
+
})
|
|
118
|
+
```
|
|
119
|
+
|
|
100
120
|
### See what your bot is doing
|
|
101
121
|
|
|
102
122
|
Thanks to the [prismarine-viewer](https://github.com/PrismarineJS/prismarine-viewer) project, it's possible to display in a browser window what your bot is doing.
|
|
@@ -220,6 +240,7 @@ The most updated and useful are :
|
|
|
220
240
|
* [Chaoscraft](https://github.com/schematical/chaoscraft) - Minecraft bot using genetic algorithms, see [its youtube videos](https://www.youtube.com/playlist?list=PLLkpLgU9B5xJ7Qy4kOyBJl5J6zsDIMceH)
|
|
221
241
|
* [hexatester/minetelegram](https://github.com/hexatester/minetelegram) - Minecraft - Telegram bridge, build on top of mineflayer & telegraf.
|
|
222
242
|
* [PrismarineJS/mineflayer-builder](https://github.com/PrismarineJS/mineflayer-builder) - Prints minecraft schematics in survival, keeping orientation
|
|
243
|
+
* [SilkePilon/OpenDeliveryBot](https://github.com/SilkePilon/OpenDeliveryBot) - Minecraft bot in python to deliver items from place to place.
|
|
223
244
|
* [and hundreds more](https://github.com/PrismarineJS/mineflayer/network/dependents) - All the projects that github detected are using mineflayer
|
|
224
245
|
|
|
225
246
|
|
package/docs/README.md
CHANGED
|
@@ -80,11 +80,11 @@ const mineflayer = require('mineflayer')
|
|
|
80
80
|
|
|
81
81
|
const bot = mineflayer.createBot({
|
|
82
82
|
host: 'localhost', // minecraft server ip
|
|
83
|
-
username: '
|
|
83
|
+
username: 'Bot', // username or email, switch if you want to change accounts
|
|
84
84
|
auth: 'microsoft' // for offline mode servers, you can set this to 'offline'
|
|
85
85
|
// port: 25565, // only set if you need a port that isn't 25565
|
|
86
86
|
// version: false, // only set if you need a specific version or snapshot (ie: "1.8.9" or "1.16.5"), otherwise it's set automatically
|
|
87
|
-
// password: '12345678' // set if you want to use password-based auth (may be unreliable)
|
|
87
|
+
// password: '12345678' // set if you want to use password-based auth (may be unreliable). If specified, the `username` must be an email
|
|
88
88
|
})
|
|
89
89
|
|
|
90
90
|
bot.on('chat', (username, message) => {
|
|
@@ -97,6 +97,26 @@ bot.on('kicked', console.log)
|
|
|
97
97
|
bot.on('error', console.log)
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
If `auth` is set to `microsoft`, you will be prompted to login to microsoft.com with a code in your browser. After signing in on your browser,
|
|
101
|
+
the bot will automatically obtain and cache authentication tokens in the local file system so you don't have to sign-in again.
|
|
102
|
+
To switch the account, update the supplied `username`. By default, cached tokens will be stored in your user's .minecraft folder.
|
|
103
|
+
For more information on these options and others, see node-minecraft-protocol's [API doc](https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/docs/API.md#mccreateclientoptions).
|
|
104
|
+
|
|
105
|
+
#### Connecting to a Realm
|
|
106
|
+
|
|
107
|
+
To join a Realm that your Minecraft account has been invited to, you can pass a `realms` object with a selector function like below.
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
const client = mineflayer.createBot({
|
|
111
|
+
username: 'email@example.com', // minecraft username
|
|
112
|
+
realms: {
|
|
113
|
+
// This function is called with an array of Realms the account can join. It should return the one it wants to join.
|
|
114
|
+
pickRealm: (realms) => realms[0]
|
|
115
|
+
},
|
|
116
|
+
auth: 'microsoft'
|
|
117
|
+
})
|
|
118
|
+
```
|
|
119
|
+
|
|
100
120
|
### See what your bot is doing
|
|
101
121
|
|
|
102
122
|
Thanks to the [prismarine-viewer](https://github.com/PrismarineJS/prismarine-viewer) project, it's possible to display in a browser window what your bot is doing.
|
|
@@ -220,6 +240,7 @@ The most updated and useful are :
|
|
|
220
240
|
* [Chaoscraft](https://github.com/schematical/chaoscraft) - Minecraft bot using genetic algorithms, see [its youtube videos](https://www.youtube.com/playlist?list=PLLkpLgU9B5xJ7Qy4kOyBJl5J6zsDIMceH)
|
|
221
241
|
* [hexatester/minetelegram](https://github.com/hexatester/minetelegram) - Minecraft - Telegram bridge, build on top of mineflayer & telegraf.
|
|
222
242
|
* [PrismarineJS/mineflayer-builder](https://github.com/PrismarineJS/mineflayer-builder) - Prints minecraft schematics in survival, keeping orientation
|
|
243
|
+
* [SilkePilon/OpenDeliveryBot](https://github.com/SilkePilon/OpenDeliveryBot) - Minecraft bot in python to deliver items from place to place.
|
|
223
244
|
* [and hundreds more](https://github.com/PrismarineJS/mineflayer/network/dependents) - All the projects that github detected are using mineflayer
|
|
224
245
|
|
|
225
246
|
|
package/docs/history.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 4.13.0
|
|
2
|
+
* [Switch to entity.displayName (#3168)](https://github.com/PrismarineJS/mineflayer/commit/2409ad458b952173de669a7d9cfaeb770effe3ae) (thanks @lkwilson)
|
|
3
|
+
* [Update readme auth doc (#3169)](https://github.com/PrismarineJS/mineflayer/commit/f5d4a288a768ca6717fa4d22c72fb0267428c684) (thanks @extremeheat)
|
|
4
|
+
* [Add OpenDeliveryBot to "Projects Using Mineflayer" (#3162)](https://github.com/PrismarineJS/mineflayer/commit/ab3c0cf25d0cc28ccba89640b2ceff6ab6b4dace) (thanks @SilkePilon)
|
|
5
|
+
* [Use node 18 on CI (#3157)](https://github.com/PrismarineJS/mineflayer/commit/d3df34dcaa804a71bf0d8cc50a419990d4a2dce3) (thanks @extremeheat)
|
|
6
|
+
* [Fix ambigious function naming (#3161)](https://github.com/PrismarineJS/mineflayer/commit/9ecdf201794bfa350486839a01e318dfd94b3bfb) (thanks @frej4189)
|
|
7
|
+
|
|
1
8
|
## 4.12.0
|
|
2
9
|
* [Mineflayer physics refactor (#2492)](https://github.com/PrismarineJS/mineflayer/commit/d0eb3a1afe6cda7b04ae2f88052cd868ba0c0c4f) (thanks @U5B)
|
|
3
10
|
|
package/examples/armor_stand.js
CHANGED
|
@@ -26,7 +26,7 @@ bot.on('chat', async (username, message) => {
|
|
|
26
26
|
const [mainCommand, subCommand] = message.split(' ')
|
|
27
27
|
if (mainCommand !== 'equip' && mainCommand !== 'unequip') return
|
|
28
28
|
|
|
29
|
-
const armorStand = bot.nearestEntity(e => e.
|
|
29
|
+
const armorStand = bot.nearestEntity(e => e.displayName === 'Armor Stand' && bot.entity.position.distanceTo(e.position) < 4)
|
|
30
30
|
if (!armorStand) {
|
|
31
31
|
bot.chat('No armor stands nearby!')
|
|
32
32
|
return
|
package/examples/chatterbox.js
CHANGED
|
@@ -176,11 +176,11 @@ bot.on('playerCollect', (collector, collected) => {
|
|
|
176
176
|
|
|
177
177
|
bot.on('entitySpawn', (entity) => {
|
|
178
178
|
if (entity.type === 'mob') {
|
|
179
|
-
console.log(`Look out! A ${entity.
|
|
179
|
+
console.log(`Look out! A ${entity.displayName} spawned at ${entity.position}`)
|
|
180
180
|
} else if (entity.type === 'player') {
|
|
181
181
|
bot.chat(`Look who decided to show up: ${entity.username}`)
|
|
182
182
|
} else if (entity.type === 'object') {
|
|
183
|
-
console.log(`There's a ${entity.
|
|
183
|
+
console.log(`There's a ${entity.displayName} at ${entity.position}`)
|
|
184
184
|
} else if (entity.type === 'global') {
|
|
185
185
|
bot.chat('Ooh lightning!')
|
|
186
186
|
} else if (entity.type === 'orb') {
|
|
@@ -189,7 +189,7 @@ bot.on('entitySpawn', (entity) => {
|
|
|
189
189
|
})
|
|
190
190
|
bot.on('entityHurt', (entity) => {
|
|
191
191
|
if (entity.type === 'mob') {
|
|
192
|
-
bot.chat(`Haha! The ${entity.
|
|
192
|
+
bot.chat(`Haha! The ${entity.displayName} got hurt!`)
|
|
193
193
|
} else if (entity.type === 'player') {
|
|
194
194
|
bot.chat(`Aww, poor ${entity.username} got hurt. Maybe you shouldn't have a ping of ${bot.players[entity.username].ping}`)
|
|
195
195
|
}
|
|
@@ -214,12 +214,12 @@ bot.on('entityEat', (entity) => {
|
|
|
214
214
|
})
|
|
215
215
|
bot.on('entityAttach', (entity, vehicle) => {
|
|
216
216
|
if (entity.type === 'player' && vehicle.type === 'object') {
|
|
217
|
-
bot.chat(`Sweet, ${entity.username} is riding that ${vehicle.
|
|
217
|
+
bot.chat(`Sweet, ${entity.username} is riding that ${vehicle.displayName}`)
|
|
218
218
|
}
|
|
219
219
|
})
|
|
220
220
|
bot.on('entityDetach', (entity, vehicle) => {
|
|
221
221
|
if (entity.type === 'player' && vehicle.type === 'object') {
|
|
222
|
-
bot.chat(`Lame, ${entity.username} stopped riding the ${vehicle.
|
|
222
|
+
bot.chat(`Lame, ${entity.username} stopped riding the ${vehicle.displayName}`)
|
|
223
223
|
}
|
|
224
224
|
})
|
|
225
225
|
bot.on('entityEquipmentChange', (entity) => {
|
package/examples/guard.js
CHANGED
|
@@ -59,7 +59,7 @@ bot.on('physicsTick', () => {
|
|
|
59
59
|
|
|
60
60
|
// Only look for mobs within 16 blocks
|
|
61
61
|
const filter = e => e.type === 'mob' && e.position.distanceTo(bot.entity.position) < 16 &&
|
|
62
|
-
e.
|
|
62
|
+
e.displayName !== 'Armor Stand' // Mojang classifies armor stands as mobs for some reason?
|
|
63
63
|
|
|
64
64
|
const entity = bot.nearestEntity(filter)
|
|
65
65
|
if (entity) {
|
package/examples/jumper.js
CHANGED
|
@@ -108,9 +108,9 @@ bot.once('spawn', () => {
|
|
|
108
108
|
})
|
|
109
109
|
|
|
110
110
|
bot.on('mount', () => {
|
|
111
|
-
bot.chat(`mounted ${bot.vehicle.
|
|
111
|
+
bot.chat(`mounted ${bot.vehicle.displayName}`)
|
|
112
112
|
})
|
|
113
113
|
|
|
114
114
|
bot.on('dismount', (vehicle) => {
|
|
115
|
-
bot.chat(`dismounted ${vehicle.
|
|
115
|
+
bot.chat(`dismounted ${vehicle.displayName}`)
|
|
116
116
|
})
|
|
@@ -224,12 +224,12 @@ def playerCollect(this, collector, collected):
|
|
|
224
224
|
def entitySpawn(this, entity):
|
|
225
225
|
if entity.type == "mob":
|
|
226
226
|
p = entity.position
|
|
227
|
-
console.log(f"Look out! A {entity.
|
|
227
|
+
console.log(f"Look out! A {entity.displayName} spawned at {p.toString()}")
|
|
228
228
|
elif entity.type == "player":
|
|
229
229
|
bot.chat(f"Look who decided to show up: {entity.username}")
|
|
230
230
|
elif entity.type == "object":
|
|
231
231
|
p = entity.position
|
|
232
|
-
console.log(f"There's a {entity.
|
|
232
|
+
console.log(f"There's a {entity.displayName} at {p.toString()}")
|
|
233
233
|
elif entity.type == "global":
|
|
234
234
|
bot.chat("Ooh lightning!")
|
|
235
235
|
elif entity.type == "orb":
|
|
@@ -239,7 +239,7 @@ def entitySpawn(this, entity):
|
|
|
239
239
|
@On(bot, "entityHurt")
|
|
240
240
|
def entityHurt(this, entity):
|
|
241
241
|
if entity.type == "mob":
|
|
242
|
-
bot.chat(f"Haha! The ${entity.
|
|
242
|
+
bot.chat(f"Haha! The ${entity.displayName} got hurt!")
|
|
243
243
|
elif entity.type == "player":
|
|
244
244
|
if entity.username in bot.players:
|
|
245
245
|
ping = bot.players[entity.username].ping
|
|
@@ -279,13 +279,13 @@ def entityEat(this, entity):
|
|
|
279
279
|
@On(bot, "entityAttach")
|
|
280
280
|
def entityAttach(this, entity, vehicle):
|
|
281
281
|
if entity.type == "player" and vehicle.type == "object":
|
|
282
|
-
print(f"Sweet, {entity.username} is riding that {vehicle.
|
|
282
|
+
print(f"Sweet, {entity.username} is riding that {vehicle.displayName}")
|
|
283
283
|
|
|
284
284
|
|
|
285
285
|
@On(bot, "entityDetach")
|
|
286
286
|
def entityDetach(this, entity, vehicle):
|
|
287
287
|
if entity.type == "player" and vehicle.type == "object":
|
|
288
|
-
print(f"Lame, {entity.username} stopped riding the {vehicle.
|
|
288
|
+
print(f"Lame, {entity.username} stopped riding the {vehicle.displayName}")
|
|
289
289
|
|
|
290
290
|
|
|
291
291
|
@On(bot, "entityEquipmentChange")
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
if (typeof process !== 'undefined' && parseInt(process.versions.node.split('.')[0]) <
|
|
1
|
+
if (typeof process !== 'undefined' && parseInt(process.versions.node.split('.')[0]) < 18) {
|
|
2
2
|
console.error('Your node version is currently', process.versions.node)
|
|
3
|
-
console.error('Please update it to a version >=
|
|
3
|
+
console.error('Please update it to a version >= 18.x.x from https://nodejs.org/')
|
|
4
4
|
process.exit(1)
|
|
5
5
|
}
|
|
6
6
|
|
package/lib/plugins/entities.js
CHANGED
|
@@ -176,8 +176,6 @@ function inject (bot) {
|
|
|
176
176
|
entityData = entitiesArray.find(entity => entity.internalId === type)
|
|
177
177
|
}
|
|
178
178
|
if (entityData) {
|
|
179
|
-
entity.mobType = entityData.displayName
|
|
180
|
-
entity.objectType = entityData.displayName
|
|
181
179
|
entity.displayName = entityData.displayName
|
|
182
180
|
entity.entityType = entityData.id
|
|
183
181
|
entity.name = entityData.name
|
|
@@ -188,7 +186,6 @@ function inject (bot) {
|
|
|
188
186
|
// unknown entity
|
|
189
187
|
entity.type = 'other'
|
|
190
188
|
entity.entityType = type
|
|
191
|
-
entity.mobType = 'unknown'
|
|
192
189
|
entity.displayName = 'unknown'
|
|
193
190
|
entity.name = 'unknown'
|
|
194
191
|
entity.kind = 'unknown'
|
package/lib/plugins/physics.js
CHANGED
|
@@ -138,8 +138,8 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
138
138
|
return dYaw
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
// returns false if
|
|
142
|
-
function
|
|
141
|
+
// returns false if bot should send position packets
|
|
142
|
+
function isEntityRemoved () {
|
|
143
143
|
if (bot.isAlive === true) deadTicks = 0
|
|
144
144
|
if (bot.isAlive === false && deadTicks <= 20) deadTicks++
|
|
145
145
|
if (deadTicks >= 20) return true
|
|
@@ -148,7 +148,7 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
148
148
|
|
|
149
149
|
function updatePosition (now) {
|
|
150
150
|
// Only send updates for 20 ticks after death
|
|
151
|
-
if (
|
|
151
|
+
if (isEntityRemoved()) return
|
|
152
152
|
|
|
153
153
|
// Increment the yaw in baby steps so that notchian clients (not the server) can keep up.
|
|
154
154
|
const dYaw = deltaYaw(bot.entity.yaw, lastSentYaw)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mineflayer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "create minecraft bots with a stable, high level API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prismarine-block": "^1.17.0",
|
|
28
28
|
"prismarine-chat": "^1.7.1",
|
|
29
29
|
"prismarine-chunk": "^1.34.0",
|
|
30
|
-
"prismarine-entity": "^2.
|
|
30
|
+
"prismarine-entity": "^2.3.0",
|
|
31
31
|
"prismarine-item": "^1.14.0",
|
|
32
32
|
"prismarine-nbt": "^2.0.0",
|
|
33
33
|
"prismarine-physics": "^1.7.0",
|
package/.gitpod.DockerFile
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
FROM gitpod/workspace-full:latest
|
|
2
|
-
|
|
3
|
-
RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh \
|
|
4
|
-
&& sdk install java"
|
|
5
|
-
|
|
6
|
-
RUN bash -c ". .nvm/nvm.sh \
|
|
7
|
-
&& nvm install 14 \
|
|
8
|
-
&& nvm use 14 \
|
|
9
|
-
&& nvm alias default 14"
|
|
10
|
-
|
|
11
|
-
RUN echo "nvm use default &>/dev/null" >> ~/.bashrc.d/51-nvm-fix
|