mineflayer 3.13.0 → 3.15.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/FUNDING.yml +3 -0
- package/.github/workflows/ci.yml +2 -0
- package/README.md +10 -6
- package/docs/README.md +10 -6
- package/docs/api.md +8 -0
- package/docs/history.md +18 -0
- package/docs/zh/CONTRIBUTING.md +93 -0
- package/docs/zh/FAQ.md +169 -0
- package/docs/zh/README_ZH_CN.md +5 -5
- package/docs/zh/_sidebar.md +9 -0
- package/docs/zh/api.md +2132 -0
- package/docs/zh/demos.md +18 -0
- package/docs/zh/history.md +914 -0
- package/docs/zh/index.html +38 -0
- package/docs/zh/tutorial.md +718 -0
- package/examples/attack.js +45 -0
- package/index.d.ts +15 -8
- package/lib/features.json +37 -27
- package/lib/loader.js +1 -1
- package/lib/plugins/blocks.js +40 -24
- package/lib/plugins/entities.js +12 -5
- package/lib/plugins/game.js +6 -1
- package/lib/plugins/physics.js +1 -0
- package/lib/version.js +2 -2
- package/package.json +5 -5
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* A bot that attacks the player that sends a message or the nearest entity (excluding players)
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
const mineflayer = require('mineflayer')
|
|
7
|
+
|
|
8
|
+
if (process.argv.length < 4 || process.argv.length > 6) {
|
|
9
|
+
console.log('Usage : node attack.js <host> <port> [<name>] [<password>]')
|
|
10
|
+
process.exit(1)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const bot = mineflayer.createBot({
|
|
14
|
+
host: process.argv[2],
|
|
15
|
+
port: parseInt(process.argv[3]),
|
|
16
|
+
username: process.argv[4] ? process.argv[4] : 'attack',
|
|
17
|
+
password: process.argv[5]
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
bot.on('spawn', () => {
|
|
21
|
+
bot.on('chat', (username, message) => {
|
|
22
|
+
if (message === 'attack me') attackPlayer(username)
|
|
23
|
+
else if (message === 'attack') attackEntity()
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
function attackPlayer (username) {
|
|
28
|
+
const player = bot.players[username]
|
|
29
|
+
if (!player || !player.entity) {
|
|
30
|
+
bot.chat('I can\'t see you')
|
|
31
|
+
} else {
|
|
32
|
+
bot.chat(`Attacking ${player.username}`)
|
|
33
|
+
bot.attack(player.entity)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function attackEntity () {
|
|
38
|
+
const entity = bot.nearestEntity()
|
|
39
|
+
if (!entity) {
|
|
40
|
+
bot.chat('No nearby entities')
|
|
41
|
+
} else {
|
|
42
|
+
bot.chat(`Attacking ${entity.name ?? entity.username}`)
|
|
43
|
+
bot.attack(entity)
|
|
44
|
+
}
|
|
45
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -201,7 +201,7 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
201
201
|
blockInSight: (maxSteps: number, vectorLength: number) => Block | null
|
|
202
202
|
|
|
203
203
|
blockAtCursor: (maxDistance?: number, matcher?: Function) => Block | null
|
|
204
|
-
blockAtEntityCursor: (entity?:
|
|
204
|
+
blockAtEntityCursor: (entity?: Entity, maxDistance?: number, matcher?: Function) => Block | null
|
|
205
205
|
|
|
206
206
|
canSeeBlock: (block: Block) => boolean
|
|
207
207
|
|
|
@@ -343,6 +343,8 @@ export interface Bot extends TypedEmitter<BotEvents> {
|
|
|
343
343
|
callback?: (err?: Error) => void
|
|
344
344
|
) => Promise<void>
|
|
345
345
|
|
|
346
|
+
openContainer: (chest: Block | Entity) => Promise<Chest | Furnace | Dispenser>
|
|
347
|
+
|
|
346
348
|
openChest: (chest: Block | Entity) => Promise<Chest>
|
|
347
349
|
|
|
348
350
|
openFurnace: (furnace: Block) => Promise<Furnace>
|
|
@@ -740,13 +742,18 @@ export class Villager extends (EventEmitter as new () => TypedEmitter<Conditiona
|
|
|
740
742
|
}
|
|
741
743
|
|
|
742
744
|
export interface VillagerTrade {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
745
|
+
inputItem1: Item
|
|
746
|
+
outputItem: Item
|
|
747
|
+
inputItem2: Item | null
|
|
748
|
+
hasItem2: boolean
|
|
749
|
+
tradeDisabled: boolean
|
|
750
|
+
nbTradeUses: number
|
|
751
|
+
maximumNbTradeUses: number
|
|
752
|
+
xp?: number
|
|
753
|
+
specialPrice?: number
|
|
754
|
+
priceMultiplier?: number
|
|
755
|
+
demand?: number
|
|
756
|
+
realPrice?: number
|
|
750
757
|
}
|
|
751
758
|
|
|
752
759
|
export class ScoreBoard {
|
package/lib/features.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
{
|
|
8
8
|
"name": "spawner",
|
|
9
9
|
"description": "spawner is called spawner",
|
|
10
|
-
"versions": ["1.13", "1.
|
|
10
|
+
"versions": ["1.13", "1.18.1"]
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"name": "blockMetadata",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
{
|
|
18
18
|
"name": "blockStateId",
|
|
19
19
|
"description": "block metadata is encoded as state id",
|
|
20
|
-
"versions": ["1.13", "1.
|
|
20
|
+
"versions": ["1.13", "1.18.1"]
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"name": "creativeSleepNearMobs",
|
|
24
24
|
"description": "can sleep near mobs in creative",
|
|
25
|
-
"versions": ["1.13", "1.
|
|
25
|
+
"versions": ["1.13", "1.18.1"]
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
"name": "fixedPointPosition",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
{
|
|
33
33
|
"name": "doublePosition",
|
|
34
34
|
"description": "Entity positions are represented with double",
|
|
35
|
-
"versions": ["1.9", "1.
|
|
35
|
+
"versions": ["1.9", "1.18.1"]
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"name": "fixedPointDelta",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
{
|
|
43
43
|
"name": "fixedPointDelta128",
|
|
44
44
|
"description": "Delta of position are represented with fixed point numbers times 128",
|
|
45
|
-
"versions": ["1.9", "1.
|
|
45
|
+
"versions": ["1.9", "1.18.1"]
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"name": "customChannelMCPrefixed",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
{
|
|
53
53
|
"name": "customChannelIdentifier",
|
|
54
54
|
"description": "custom channel is an identifier starting in minecraft namespace",
|
|
55
|
-
"versions": ["1.13", "1.
|
|
55
|
+
"versions": ["1.13", "1.18.1"]
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": "dimensionDataIsAvailable",
|
|
59
59
|
"description": "dimensionData is available, providing an additional information about the current dimension",
|
|
60
|
-
"versions": ["1.17", "1.
|
|
60
|
+
"versions": ["1.17", "1.18.1"]
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
"name": "useItemWithBlockPlace",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
{
|
|
68
68
|
"name": "useItemWithOwnPacket",
|
|
69
69
|
"description": "use item is done with its own packet",
|
|
70
|
-
"versions": ["1.9", "1.
|
|
70
|
+
"versions": ["1.9", "1.18.1"]
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
"name": "blockPlaceHasHeldItem",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
{
|
|
88
88
|
"name": "blockPlaceHasInsideBlock",
|
|
89
89
|
"description": "block_place packet has inside block",
|
|
90
|
-
"versions": ["1.14", "1.
|
|
90
|
+
"versions": ["1.14", "1.18.1"]
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"name": "teleportUsesPositionPacket",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
{
|
|
103
103
|
"name": "teleportUsesOwnPacket",
|
|
104
104
|
"description": "teleport is done using its own packet",
|
|
105
|
-
"versions": ["1.9", "1.
|
|
105
|
+
"versions": ["1.9", "1.18.1"]
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
"name": "oneBlockForSeveralVariations",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
{
|
|
113
113
|
"name": "blockSchemeIsFlat",
|
|
114
114
|
"description": "all variations of a packet have their own id",
|
|
115
|
-
"versions": ["1.13", "1.
|
|
115
|
+
"versions": ["1.13", "1.18.1"]
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
"name": "tabCompleteHasNoToolTip",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
{
|
|
123
123
|
"name": "tabCompleteHasAToolTip",
|
|
124
124
|
"description": "tab complete has a tool tip",
|
|
125
|
-
"versions": ["1.13", "1.
|
|
125
|
+
"versions": ["1.13", "1.18.1"]
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
"name": "effectAreMinecraftPrefixed",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
{
|
|
133
133
|
"name": "effectAreNotPrefixed",
|
|
134
134
|
"description": "effect are not prefixed",
|
|
135
|
-
"versions": ["1.13", "1.
|
|
135
|
+
"versions": ["1.13", "1.18.1"]
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
"name": "itemsAreAlsoBlocks",
|
|
@@ -142,12 +142,12 @@
|
|
|
142
142
|
{
|
|
143
143
|
"name": "itemsAreNotBlocks",
|
|
144
144
|
"description": "items are not block",
|
|
145
|
-
"versions": ["1.13", "1.
|
|
145
|
+
"versions": ["1.13", "1.18.1"]
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
"name": "fishingBobberCorrectlyNamed",
|
|
149
149
|
"description": "the fishing hook entity is named fishing_bobber",
|
|
150
|
-
"versions": ["1.14", "1.
|
|
150
|
+
"versions": ["1.14", "1.18.1"]
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
"name": "editBookIsPluginChannel",
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
{
|
|
158
158
|
"name": "hasEditBookPacket",
|
|
159
159
|
"description": "book editing is handled through a packet",
|
|
160
|
-
"versions": ["1.13", "1.
|
|
160
|
+
"versions": ["1.13", "1.18.1"]
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"name": "clientUpdateBookIdWhenSign",
|
|
@@ -197,12 +197,12 @@
|
|
|
197
197
|
{
|
|
198
198
|
"name": "dimensionIsAWorld",
|
|
199
199
|
"description": "description is a world name (string)",
|
|
200
|
-
"versions": ["1.16.2", "1.
|
|
200
|
+
"versions": ["1.16.2", "1.18.1"]
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
203
|
"name": "dimensionDataIsAvailable",
|
|
204
204
|
"description": "dimensionData is available, describing additional dimension information",
|
|
205
|
-
"versions": ["1.17", "1.
|
|
205
|
+
"versions": ["1.17", "1.18.1"]
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
208
|
"name": "doesntHaveChestType",
|
|
@@ -227,22 +227,22 @@
|
|
|
227
227
|
{
|
|
228
228
|
"name": "hasAttackCooldown",
|
|
229
229
|
"description": "if there is a cooldown after attacks to deal full damage",
|
|
230
|
-
"versions": ["1.9", "1.
|
|
230
|
+
"versions": ["1.9", "1.18.1"]
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
233
|
"name": "usesLoginPacket",
|
|
234
234
|
"description": "uses the login packet as defined in mcData",
|
|
235
|
-
"versions": ["1.16", "1.
|
|
235
|
+
"versions": ["1.16", "1.18.1"]
|
|
236
236
|
},
|
|
237
237
|
{
|
|
238
238
|
"name": "usesMultiblockSingleLong",
|
|
239
239
|
"description": "in the multi_block_change packet is stored as a single number",
|
|
240
|
-
"versions": ["1.16.2", "1.
|
|
240
|
+
"versions": ["1.16.2", "1.18.1"]
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
"name": "usesMultiblock3DChunkCoords",
|
|
244
244
|
"description": "in the multi_block_change packet, all 3 axis coords are defined",
|
|
245
|
-
"versions": ["1.16.2", "1.
|
|
245
|
+
"versions": ["1.16.2", "1.18.1"]
|
|
246
246
|
},
|
|
247
247
|
{
|
|
248
248
|
"name": "setBlockUsesMetadataNumber",
|
|
@@ -257,7 +257,7 @@
|
|
|
257
257
|
{
|
|
258
258
|
"name": "selectingTradeMovesItems",
|
|
259
259
|
"description": "selecting a trade automatically puts the required items into trading slots",
|
|
260
|
-
"versions": ["1.14", "1.
|
|
260
|
+
"versions": ["1.14", "1.18.1"]
|
|
261
261
|
},
|
|
262
262
|
{
|
|
263
263
|
"name": "resourcePackUsesHash",
|
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
{
|
|
273
273
|
"name": "teamUsesChatComponents",
|
|
274
274
|
"description": "teams use chatcomponents for formatting",
|
|
275
|
-
"versions": ["1.13", "1.
|
|
275
|
+
"versions": ["1.13", "1.18.1"]
|
|
276
276
|
},
|
|
277
277
|
{
|
|
278
278
|
"name": "teamUsesScoreboard",
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
{
|
|
288
288
|
"name": "enderCrystalNameNoCapsWithUnderscore",
|
|
289
289
|
"description": "this is when the end_crystal's entity name is end_crystal",
|
|
290
|
-
"versions": ["1.14", "1.
|
|
290
|
+
"versions": ["1.14", "1.18.1"]
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
293
|
"name": "entityNameUpperCaseNoUnderscore",
|
|
@@ -307,7 +307,7 @@
|
|
|
307
307
|
{
|
|
308
308
|
"name": "stateIdUsed",
|
|
309
309
|
"description": "starting in 1.17.1, actionId has been replaced with stateId",
|
|
310
|
-
"versions": ["1.17.1", "1.
|
|
310
|
+
"versions": ["1.17.1", "1.18.1"]
|
|
311
311
|
},
|
|
312
312
|
{
|
|
313
313
|
"name": "actionIdUsed",
|
|
@@ -317,6 +317,16 @@
|
|
|
317
317
|
{
|
|
318
318
|
"name": "setSlotAsTransaction",
|
|
319
319
|
"description": "use setslot as transaction instead of just hoping it'll work",
|
|
320
|
-
"versions": ["1.17", "1.
|
|
320
|
+
"versions": ["1.17", "1.18.1"]
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"name": "armAnimationBeforeUse",
|
|
324
|
+
"description": "arm animation packet sent before use entity packet",
|
|
325
|
+
"versions": ["1.8", "1.8.9"]
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"name": "tallWorld",
|
|
329
|
+
"description": "world starts at -64 and ends at 384",
|
|
330
|
+
"versions": ["1.18", "1.18.1"]
|
|
321
331
|
}
|
|
322
332
|
]
|
package/lib/loader.js
CHANGED
|
@@ -63,7 +63,7 @@ function createBot (options = {}) {
|
|
|
63
63
|
options.username = options.username ?? 'Player'
|
|
64
64
|
options.version = options.version ?? false
|
|
65
65
|
options.plugins = options.plugins ?? {}
|
|
66
|
-
options.hideErrors = options.hideErrors ??
|
|
66
|
+
options.hideErrors = options.hideErrors ?? false
|
|
67
67
|
options.logErrors = options.logErrors ?? true
|
|
68
68
|
options.loadInternalPlugins = options.loadInternalPlugins ?? true
|
|
69
69
|
options.client = options.client ?? null
|
package/lib/plugins/blocks.js
CHANGED
|
@@ -42,13 +42,15 @@ function inject (bot, { version, storageBuilder }) {
|
|
|
42
42
|
delete paintingsByPos[painting.position]
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function addBlockEntity (nbtData) {
|
|
46
|
-
const blockEntity = nbt.simplify(nbtData)
|
|
47
|
-
const pos = new Vec3(blockEntity.x, blockEntity.y, blockEntity.z).floored()
|
|
45
|
+
function addBlockEntity (nbtData, x, y, z, type) {
|
|
46
|
+
const blockEntity = nbtData === undefined ? {} : nbt.simplify(nbtData)
|
|
47
|
+
const pos = (x !== undefined ? new Vec3(x, y, z) : new Vec3(blockEntity.x, blockEntity.y, blockEntity.z)).floored()
|
|
48
48
|
// Set raw nbt of blockEntity
|
|
49
49
|
blockEntity.raw = nbtData
|
|
50
|
+
blockEntity.type = type
|
|
51
|
+
const signType = 7
|
|
50
52
|
// Handle signs
|
|
51
|
-
if (blockEntity.id === 'minecraft:sign' || blockEntity.id === 'Sign') {
|
|
53
|
+
if (blockEntity.id === 'minecraft:sign' || blockEntity.id === 'Sign' || blockEntity.type === signType) {
|
|
52
54
|
const prepareJson = (i) => {
|
|
53
55
|
const data = blockEntity[`Text${i}`]
|
|
54
56
|
|
|
@@ -90,11 +92,7 @@ function inject (bot, { version, storageBuilder }) {
|
|
|
90
92
|
let column = bot.world.getColumn(args.x, args.z)
|
|
91
93
|
if (!column) {
|
|
92
94
|
// Allocates new chunk object while taking world's custom min/max height into account
|
|
93
|
-
|
|
94
|
-
column = new Chunk({ minY: bot.game.dimensionData.min_y, worldHeight: bot.game.dimensionData.height })
|
|
95
|
-
} else {
|
|
96
|
-
column = new Chunk()
|
|
97
|
-
}
|
|
95
|
+
column = new Chunk({ minY: bot.game.minY, worldHeight: bot.game.height })
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
try {
|
|
@@ -102,6 +100,9 @@ function inject (bot, { version, storageBuilder }) {
|
|
|
102
100
|
if (args.biomes !== undefined) {
|
|
103
101
|
column.loadBiomes(args.biomes)
|
|
104
102
|
}
|
|
103
|
+
if (args.skyLight !== undefined) {
|
|
104
|
+
column.loadParsedLight(args.skyLight, args.blockLight, args.skyLightMask, args.blockLightMask, args.emptySkyLightMask, args.emptyBlockLightMask)
|
|
105
|
+
}
|
|
105
106
|
bot.world.setColumn(args.x, args.z, column)
|
|
106
107
|
} catch (e) {
|
|
107
108
|
bot.emit('error', e)
|
|
@@ -206,13 +207,17 @@ function inject (bot, { version, storageBuilder }) {
|
|
|
206
207
|
let next = start
|
|
207
208
|
while (next) {
|
|
208
209
|
const column = bot.world.getColumn(next.x, next.z)
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
const sectionY = next.y + Math.abs(bot.game.minY >> 4)
|
|
211
|
+
const totalSections = bot.game.height >> 4
|
|
212
|
+
if (sectionY >= 0 && sectionY < totalSections && column && !visitedSections.has(next.toString())) {
|
|
213
|
+
const section = column.sections[sectionY]
|
|
211
214
|
if (useExtraInfo === true || isBlockInSection(section, matcher)) {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
const begin = new Vec3(next.x * 16, sectionY * 16 + bot.game.minY, next.z * 16)
|
|
216
|
+
const cursor = begin.clone()
|
|
217
|
+
const end = cursor.offset(16, 16, 16)
|
|
218
|
+
for (cursor.x = begin.x; cursor.x < end.x; cursor.x++) {
|
|
219
|
+
for (cursor.y = begin.y; cursor.y < end.y; cursor.y++) {
|
|
220
|
+
for (cursor.z = begin.z; cursor.z < end.z; cursor.z++) {
|
|
216
221
|
if (fullMatcher(cursor) && cursor.distanceTo(point) <= maxDistance) blocks.push(cursor.clone())
|
|
217
222
|
}
|
|
218
223
|
}
|
|
@@ -299,11 +304,7 @@ function inject (bot, { version, storageBuilder }) {
|
|
|
299
304
|
bot._client.on('update_light', (packet) => {
|
|
300
305
|
let column = bot.world.getColumn(packet.chunkX, packet.chunkZ)
|
|
301
306
|
if (!column) {
|
|
302
|
-
|
|
303
|
-
column = new Chunk({ minY: bot.game.dimensionData.min_y, worldHeight: bot.game.dimensionData.height })
|
|
304
|
-
} else {
|
|
305
|
-
column = new Chunk()
|
|
306
|
-
}
|
|
307
|
+
column = new Chunk({ minY: bot.game.minY, worldHeight: bot.game.height })
|
|
307
308
|
bot.world.setColumn(packet.chunkX, packet.chunkZ, column)
|
|
308
309
|
}
|
|
309
310
|
|
|
@@ -323,12 +324,23 @@ function inject (bot, { version, storageBuilder }) {
|
|
|
323
324
|
biomes: packet.biomes,
|
|
324
325
|
skyLightSent: bot.game.dimension === 'minecraft:overworld',
|
|
325
326
|
groundUp: packet.groundUp,
|
|
326
|
-
data: packet.chunkData
|
|
327
|
+
data: packet.chunkData,
|
|
328
|
+
trustEdges: packet.trustEdges,
|
|
329
|
+
skyLightMask: packet.skyLightMask,
|
|
330
|
+
blockLightMask: packet.blockLightMask,
|
|
331
|
+
emptySkyLightMask: packet.emptySkyLightMask,
|
|
332
|
+
emptyBlockLightMask: packet.emptyBlockLightMask,
|
|
333
|
+
skyLight: packet.skyLight,
|
|
334
|
+
blockLight: packet.blockLight
|
|
327
335
|
})
|
|
328
336
|
|
|
329
337
|
if (typeof packet.blockEntities !== 'undefined') {
|
|
330
|
-
for (const
|
|
331
|
-
|
|
338
|
+
for (const blockEntity of packet.blockEntities) {
|
|
339
|
+
if (blockEntity.x !== undefined) {
|
|
340
|
+
addBlockEntity(blockEntity.nbtData, blockEntity.x, blockEntity.y, blockEntity.z, blockEntity.type)
|
|
341
|
+
} else {
|
|
342
|
+
addBlockEntity(blockEntity)
|
|
343
|
+
}
|
|
332
344
|
}
|
|
333
345
|
}
|
|
334
346
|
})
|
|
@@ -448,7 +460,11 @@ function inject (bot, { version, storageBuilder }) {
|
|
|
448
460
|
})
|
|
449
461
|
|
|
450
462
|
bot._client.on('tile_entity_data', (packet) => {
|
|
451
|
-
|
|
463
|
+
if (packet.location !== undefined) {
|
|
464
|
+
addBlockEntity(packet.nbtData, packet.location.x, packet.location.y, packet.location.z, packet.action)
|
|
465
|
+
} else {
|
|
466
|
+
addBlockEntity(packet.nbtData)
|
|
467
|
+
}
|
|
452
468
|
})
|
|
453
469
|
|
|
454
470
|
bot.updateSign = (block, text) => {
|
package/lib/plugins/entities.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { Vec3 } = require('vec3')
|
|
2
|
-
const Entity = require('prismarine-entity')
|
|
3
2
|
const conv = require('../conversions')
|
|
4
3
|
const NAMED_ENTITY_HEIGHT = 1.62
|
|
5
4
|
const NAMED_ENTITY_WIDTH = 0.6
|
|
@@ -26,6 +25,7 @@ const entityStatusEvents = {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
function inject (bot, { version }) {
|
|
28
|
+
const Entity = require('prismarine-entity')(version)
|
|
29
29
|
const objects = require('minecraft-data')(version).objects
|
|
30
30
|
const mobs = require('minecraft-data')(version).mobs
|
|
31
31
|
const entitiesArray = require('minecraft-data')(version).entitiesArray
|
|
@@ -548,11 +548,18 @@ function inject (bot, { version }) {
|
|
|
548
548
|
}
|
|
549
549
|
|
|
550
550
|
function attack (target, swing = true) {
|
|
551
|
-
// arm animation comes before the use_entity packet
|
|
552
|
-
if (
|
|
553
|
-
|
|
551
|
+
// arm animation comes before the use_entity packet on 1.8
|
|
552
|
+
if (bot.supportFeature('armAnimationBeforeUse')) {
|
|
553
|
+
if (swing) {
|
|
554
|
+
swingArm()
|
|
555
|
+
}
|
|
556
|
+
useEntity(target, 1)
|
|
557
|
+
} else {
|
|
558
|
+
useEntity(target, 1)
|
|
559
|
+
if (swing) {
|
|
560
|
+
swingArm()
|
|
561
|
+
}
|
|
554
562
|
}
|
|
555
|
-
useEntity(target, 1)
|
|
556
563
|
}
|
|
557
564
|
|
|
558
565
|
function mount (target) {
|
package/lib/plugins/game.js
CHANGED
|
@@ -37,7 +37,12 @@ function inject (bot, options) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
if (bot.supportFeature('dimensionDataIsAvailable')) {
|
|
40
|
-
|
|
40
|
+
const dimensionData = nbt.simplify(packet.dimension)
|
|
41
|
+
bot.game.minY = dimensionData.min_y
|
|
42
|
+
bot.game.height = dimensionData.height
|
|
43
|
+
} else {
|
|
44
|
+
bot.game.minY = 0
|
|
45
|
+
bot.game.height = 256
|
|
41
46
|
}
|
|
42
47
|
if (packet.difficulty) {
|
|
43
48
|
bot.game.difficulty = difficultyNames[packet.difficulty]
|
package/lib/plugins/physics.js
CHANGED
package/lib/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
supportedVersions: ['1.8', '1.9', '1.10', '1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17'],
|
|
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']
|
|
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.1']
|
|
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.
|
|
3
|
+
"version": "3.15.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,13 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"minecraft-data": "^2.
|
|
24
|
+
"minecraft-data": "^2.109.0",
|
|
25
25
|
"minecraft-protocol": "^1.26.5",
|
|
26
26
|
"prismarine-biome": "^1.1.1",
|
|
27
27
|
"prismarine-block": "^1.10.3",
|
|
28
28
|
"prismarine-chat": "^1.3.3",
|
|
29
|
-
"prismarine-chunk": "^1.
|
|
30
|
-
"prismarine-entity": "^
|
|
29
|
+
"prismarine-chunk": "^1.28.1",
|
|
30
|
+
"prismarine-entity": "^2.0.0",
|
|
31
31
|
"prismarine-item": "^1.11.0",
|
|
32
32
|
"prismarine-nbt": "^2.0.0",
|
|
33
33
|
"prismarine-physics": "^1.3.1",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"prismarine-windows": "^2.4.2",
|
|
36
36
|
"prismarine-world": "^3.6.0",
|
|
37
37
|
"protodef": "^1.14.0",
|
|
38
|
-
"typed-emitter": "^
|
|
38
|
+
"typed-emitter": "^2.0.0",
|
|
39
39
|
"vec3": "^0.1.7"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|