mineflayer 4.31.0 → 4.32.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/docs/history.md +4 -0
- package/lib/loader.js +4 -0
- package/lib/plugins/bed.js +1 -1
- package/lib/plugins/game.js +2 -2
- package/lib/plugins/physics.js +23 -8
- package/lib/plugins/rain.js +6 -4
- package/lib/plugins/team.js +52 -39
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/docs/history.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 4.32.0
|
|
2
|
+
* [1.21.6 (#3713)](https://github.com/PrismarineJS/mineflayer/commit/01f537c394fc78bf2e765b28a8b24a30c1d1fd2e) (thanks @extremeheat)
|
|
3
|
+
* [Fix knockback physics crash (#3715)](https://github.com/PrismarineJS/mineflayer/commit/e3f89d17418ece9e9fac4b111d8243dfe1a5d376) (thanks @Omena0)
|
|
4
|
+
|
|
1
5
|
## 4.31.0
|
|
2
6
|
* [Cursor 1 21 5 (#3701)](https://github.com/PrismarineJS/mineflayer/commit/8770129d26a85f9b077d2a8969d45436fa09c3f3) (thanks @rom1504)
|
|
3
7
|
|
package/lib/loader.js
CHANGED
|
@@ -74,6 +74,10 @@ function createBot (options = {}) {
|
|
|
74
74
|
const bot = new EventEmitter()
|
|
75
75
|
bot._client = options.client
|
|
76
76
|
bot.end = (reason) => bot._client.end(reason)
|
|
77
|
+
bot._warn = function (...message) {
|
|
78
|
+
if (options.hideErrors) return
|
|
79
|
+
console.warn('[mineflayer]', ...message)
|
|
80
|
+
}
|
|
77
81
|
if (options.logErrors) {
|
|
78
82
|
bot.on('error', err => {
|
|
79
83
|
if (!options.hideErrors) {
|
package/lib/plugins/bed.js
CHANGED
|
@@ -167,7 +167,7 @@ function inject (bot) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
bot._client.on('game_state_change', (packet) => {
|
|
170
|
-
if (packet.reason === 0) {
|
|
170
|
+
if (packet.reason === 0 || packet.reason === 'no_respawn_block_available') {
|
|
171
171
|
// occurs when you can't spawn in your bed and your spawn point gets reset
|
|
172
172
|
bot.emit('spawnReset')
|
|
173
173
|
}
|
package/lib/plugins/game.js
CHANGED
|
@@ -116,10 +116,10 @@ function inject (bot, options) {
|
|
|
116
116
|
})
|
|
117
117
|
|
|
118
118
|
bot._client.on('game_state_change', (packet) => {
|
|
119
|
-
if (packet
|
|
119
|
+
if ((packet.reason === 4 || packet.reason === 'win_game') && packet.gameMode === 1) {
|
|
120
120
|
bot._client.write('client_command', { action: 0 })
|
|
121
121
|
}
|
|
122
|
-
if (packet.reason === 3) {
|
|
122
|
+
if ((packet.reason === 3) || (packet.reason === 'change_game_mode')) {
|
|
123
123
|
bot.game.gameMode = parseGameMode(packet.gameMode)
|
|
124
124
|
bot.emit('game')
|
|
125
125
|
}
|
package/lib/plugins/physics.js
CHANGED
|
@@ -232,7 +232,7 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
232
232
|
}
|
|
233
233
|
bot._client.write('entity_action', {
|
|
234
234
|
entityId: bot.entity.id,
|
|
235
|
-
actionId: 8,
|
|
235
|
+
actionId: bot.supportFeature('entityActionUsesStringMapper') ? 'start_elytra_flying' : 8,
|
|
236
236
|
jumpBoost: 0
|
|
237
237
|
})
|
|
238
238
|
}
|
|
@@ -247,15 +247,27 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
247
247
|
} else if (control === 'sprint') {
|
|
248
248
|
bot._client.write('entity_action', {
|
|
249
249
|
entityId: bot.entity.id,
|
|
250
|
-
actionId:
|
|
250
|
+
actionId: bot.supportFeature('entityActionUsesStringMapper')
|
|
251
|
+
? (state ? 'start_sprinting' : 'stop_sprinting')
|
|
252
|
+
: (state ? 3 : 4),
|
|
251
253
|
jumpBoost: 0
|
|
252
254
|
})
|
|
253
255
|
} else if (control === 'sneak') {
|
|
254
|
-
bot.
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
if (bot.supportFeature('newPlayerInputPacket')) {
|
|
257
|
+
// In 1.21.6+, sneak is handled via player_input packet
|
|
258
|
+
bot._client.write('player_input', {
|
|
259
|
+
inputs: {
|
|
260
|
+
shift: state
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
} else {
|
|
264
|
+
// Legacy entity_action approach for older versions
|
|
265
|
+
bot._client.write('entity_action', {
|
|
266
|
+
entityId: bot.entity.id,
|
|
267
|
+
actionId: state ? 0 : 1,
|
|
268
|
+
jumpBoost: 0
|
|
269
|
+
})
|
|
270
|
+
}
|
|
259
271
|
}
|
|
260
272
|
}
|
|
261
273
|
|
|
@@ -296,7 +308,10 @@ function inject (bot, { physicsEnabled, maxCatchupTicks }) {
|
|
|
296
308
|
// TODO: emit an explosion event with more info
|
|
297
309
|
if (bot.physicsEnabled && bot.game.gameMode !== 'creative') {
|
|
298
310
|
if (explosion.playerKnockback) { // 1.21.3+
|
|
299
|
-
|
|
311
|
+
// Fixes issue #3635
|
|
312
|
+
bot.entity.velocity.x += explosion.playerKnockback.x
|
|
313
|
+
bot.entity.velocity.y += explosion.playerKnockback.y
|
|
314
|
+
bot.entity.velocity.z += explosion.playerKnockback.z
|
|
300
315
|
}
|
|
301
316
|
if ('playerMotionX' in explosion) {
|
|
302
317
|
bot.entity.velocity.x += explosion.playerMotionX
|
package/lib/plugins/rain.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
module.exports = inject
|
|
2
|
+
const states = ['no_respawn_block_available', 'start_raining', 'stop_raining', 'change_game_mode', 'win_game', 'demo_event', 'play_arrow_hit_sound', 'rain_level_change', 'thunder_level_change', 'puffer_fish_sting', 'guardian_elder_effect', 'immediate_respawn', 'limited_crafting', 'level_chunks_load_start']
|
|
2
3
|
|
|
3
4
|
function inject (bot) {
|
|
4
5
|
bot.isRaining = false
|
|
5
6
|
bot.thunderState = 0
|
|
6
7
|
bot.rainState = 0
|
|
7
8
|
bot._client.on('game_state_change', (packet) => {
|
|
8
|
-
|
|
9
|
+
const reason = states[packet.reason] ?? packet.reason
|
|
10
|
+
if (reason === 'start_raining') {
|
|
9
11
|
bot.isRaining = true
|
|
10
12
|
bot.emit('rain')
|
|
11
|
-
} else if (
|
|
13
|
+
} else if (reason === 'stop_raining') {
|
|
12
14
|
bot.isRaining = false
|
|
13
15
|
bot.emit('rain')
|
|
14
|
-
} else if (
|
|
16
|
+
} else if (reason === 'rain_level_change') {
|
|
15
17
|
bot.rainState = packet.gameMode
|
|
16
18
|
bot.emit('weatherUpdate')
|
|
17
|
-
} else if (
|
|
19
|
+
} else if (reason === 'thunder_level_change') {
|
|
18
20
|
bot.thunderState = packet.gameMode
|
|
19
21
|
bot.emit('weatherUpdate')
|
|
20
22
|
}
|
package/lib/plugins/team.js
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
module.exports = inject
|
|
2
2
|
|
|
3
|
+
// TODO: apply this to all versions and rename scoreboard_team -> teams in minecraft-data
|
|
4
|
+
const TEAM_MODES = ['add', 'remove', 'change', 'join', 'leave']
|
|
5
|
+
|
|
3
6
|
function inject (bot) {
|
|
4
7
|
const Team = require('../team')(bot.registry)
|
|
5
8
|
const teams = {}
|
|
6
9
|
|
|
7
10
|
function teamHandler (packet) {
|
|
8
|
-
const { team: teamName,
|
|
11
|
+
const { team: teamName, players = [] } = packet
|
|
12
|
+
const mode = typeof packet.mode === 'number' ? TEAM_MODES[packet.mode] : packet.mode
|
|
13
|
+
|
|
9
14
|
let team = teams[teamName]
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
|
|
16
|
+
switch (mode) {
|
|
17
|
+
case 'add':
|
|
18
|
+
team = new Team(
|
|
19
|
+
teamName,
|
|
20
|
+
packet.name,
|
|
21
|
+
packet.friendlyFire,
|
|
22
|
+
packet.nameTagVisibility,
|
|
23
|
+
packet.collisionRule,
|
|
24
|
+
packet.formatting,
|
|
25
|
+
packet.prefix,
|
|
26
|
+
packet.suffix
|
|
27
|
+
)
|
|
28
|
+
for (const player of players) {
|
|
23
29
|
team.add(player)
|
|
24
30
|
bot.teamMap[player] = team
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
team.members.forEach(member => {
|
|
31
|
+
}
|
|
32
|
+
teams[teamName] = team
|
|
33
|
+
bot.emit('teamCreated', teams[teamName])
|
|
34
|
+
break
|
|
35
|
+
|
|
36
|
+
case 'remove':
|
|
37
|
+
if (!team) break
|
|
38
|
+
team.members.forEach((member) => {
|
|
33
39
|
delete bot.teamMap[member]
|
|
34
40
|
})
|
|
35
41
|
delete teams[teamName]
|
|
36
42
|
bot.emit('teamRemoved', teams[teamName])
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
break
|
|
44
|
+
|
|
45
|
+
case 'change':
|
|
46
|
+
if (!team) break
|
|
39
47
|
team.update(
|
|
40
48
|
packet.name,
|
|
41
49
|
packet.friendlyFire,
|
|
@@ -46,23 +54,28 @@ function inject (bot) {
|
|
|
46
54
|
packet.suffix
|
|
47
55
|
)
|
|
48
56
|
bot.emit('teamUpdated', teams[teamName])
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
bot.emit('teamMemberAdded', teams[teamName])
|
|
57
|
+
break
|
|
58
|
+
|
|
59
|
+
case 'join':
|
|
60
|
+
if (!team) break
|
|
61
|
+
for (const player of players) {
|
|
62
|
+
team.add(player)
|
|
63
|
+
bot.teamMap[player] = team
|
|
57
64
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
bot.emit('teamMemberAdded', teams[teamName])
|
|
66
|
+
break
|
|
67
|
+
|
|
68
|
+
case 'leave':
|
|
69
|
+
if (!team) break
|
|
70
|
+
for (const player of players) {
|
|
71
|
+
team.remove(player)
|
|
72
|
+
delete bot.teamMap[player]
|
|
64
73
|
}
|
|
65
|
-
|
|
74
|
+
bot.emit('teamMemberRemoved', teams[teamName])
|
|
75
|
+
break
|
|
76
|
+
|
|
77
|
+
default:
|
|
78
|
+
bot._warn(`Unknown team mode handling team update: ${mode}`)
|
|
66
79
|
}
|
|
67
80
|
}
|
|
68
81
|
|
package/lib/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const 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', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21.1', '1.21.3', '1.21.4', '1.21.5']
|
|
1
|
+
const 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', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21.1', '1.21.3', '1.21.4', '1.21.5', '1.21.6']
|
|
2
2
|
module.exports = {
|
|
3
3
|
|
|
4
4
|
testedVersions,
|