mineflayer 4.3.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 +2 -2
- package/docs/README.md +2 -2
- package/docs/api.md +50 -20
- package/docs/es/api_es.md +1 -1
- package/docs/history.md +28 -0
- package/docs/ru/FAQ_RU.md +1 -1
- package/docs/ru/api_ru.md +2 -2
- package/docs/zh/README_ZH_CN.md +1 -1
- package/docs/zh/api.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/chatterbox.js +2 -3
- package/examples/chest.js +7 -12
- package/examples/collectblock.js +1 -7
- package/examples/command_block.js +1 -6
- package/examples/digger.js +1 -2
- package/examples/discord.js +1 -1
- 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 +23 -29
- package/lib/bossbar.js +2 -2
- package/lib/loader.js +2 -2
- package/lib/plugins/anvil.js +1 -1
- package/lib/plugins/bed.js +16 -1
- package/lib/plugins/block_actions.js +4 -3
- 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 +6 -4
- package/lib/plugins/command_block.js +1 -1
- package/lib/plugins/craft.js +3 -3
- package/lib/plugins/creative.js +2 -2
- package/lib/plugins/entities.js +25 -8
- package/lib/plugins/game.js +14 -5
- package/lib/plugins/generic_place.js +1 -1
- package/lib/plugins/inventory.js +50 -25
- package/lib/plugins/place_entity.js +1 -1
- package/lib/plugins/ray_trace.js +36 -0
- package/lib/plugins/settings.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 +15 -16
package/lib/plugins/creative.js
CHANGED
|
@@ -6,12 +6,12 @@ const { once } = require('events')
|
|
|
6
6
|
module.exports = inject
|
|
7
7
|
|
|
8
8
|
function inject (bot) {
|
|
9
|
-
const Item = require('prismarine-item')(bot.
|
|
9
|
+
const Item = require('prismarine-item')(bot.registry)
|
|
10
10
|
|
|
11
11
|
// these features only work when you are in creative mode.
|
|
12
12
|
bot.creative = {
|
|
13
13
|
setInventorySlot,
|
|
14
|
-
flyTo
|
|
14
|
+
flyTo,
|
|
15
15
|
startFlying,
|
|
16
16
|
stopFlying,
|
|
17
17
|
clearSlot: slotNum => setInventorySlot(slotNum, null),
|
package/lib/plugins/entities.js
CHANGED
|
@@ -25,10 +25,10 @@ const entityStatusEvents = {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function inject (bot) {
|
|
28
|
-
const {
|
|
29
|
-
const Entity = require('prismarine-entity')(bot.version)
|
|
28
|
+
const { mobs, entitiesArray } = bot.registry
|
|
29
|
+
const Entity = require('prismarine-entity')(bot.version)
|
|
30
30
|
const Item = require('prismarine-item')(bot.version)
|
|
31
|
-
const ChatMessage = require('prismarine-chat')(bot.
|
|
31
|
+
const ChatMessage = require('prismarine-chat')(bot.registry)
|
|
32
32
|
|
|
33
33
|
// ONLY 1.17 has this destroy_entity packet which is the same thing as entity_destroy packet except the entity is singular
|
|
34
34
|
// 1.17.1 reverted this change so this is just a simpler fix
|
|
@@ -69,6 +69,8 @@ function inject (bot) {
|
|
|
69
69
|
bot.uuidToUsername = {}
|
|
70
70
|
bot.entities = {}
|
|
71
71
|
|
|
72
|
+
bot._playerFromUUID = (uuid) => Object.values(bot.players).find(player => player.uuid === uuid)
|
|
73
|
+
|
|
72
74
|
bot.nearestEntity = (match = (entity) => { return true }) => {
|
|
73
75
|
let best = null
|
|
74
76
|
let bestDistance = Number.MAX_VALUE
|
|
@@ -192,18 +194,20 @@ function inject (bot) {
|
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
|
|
197
|
+
// spawn object/vehicle on versions < 1.19, on versions > 1.19 handles all non-player entities
|
|
195
198
|
bot._client.on('spawn_entity', (packet) => {
|
|
196
|
-
// spawn object/vehicle
|
|
197
199
|
const entity = fetchEntity(packet.entityId)
|
|
198
|
-
const entityData =
|
|
200
|
+
const entityData = bot.registry.entities[packet.type]
|
|
199
201
|
|
|
200
|
-
entity.type = 'object'
|
|
202
|
+
entity.type = entityData.type || 'object'
|
|
201
203
|
setEntityData(entity, packet.type, entityData)
|
|
202
204
|
|
|
203
205
|
if (bot.supportFeature('fixedPointPosition')) {
|
|
204
206
|
entity.position.set(packet.x / 32, packet.y / 32, packet.z / 32)
|
|
205
207
|
} else if (bot.supportFeature('doublePosition')) {
|
|
206
208
|
entity.position.set(packet.x, packet.y, packet.z)
|
|
209
|
+
} else if (bot.supportFeature('consolidatedEntitySpawnPacket')) {
|
|
210
|
+
entity.headPitch = conv.fromNotchianPitchByte(packet.headPitch)
|
|
207
211
|
}
|
|
208
212
|
|
|
209
213
|
entity.uuid = packet.objectUUID
|
|
@@ -230,6 +234,7 @@ function inject (bot) {
|
|
|
230
234
|
bot.emit('entitySpawn', entity)
|
|
231
235
|
})
|
|
232
236
|
|
|
237
|
+
// This packet is removed since 1.19 and merged into spawn_entity
|
|
233
238
|
bot._client.on('spawn_entity_living', (packet) => {
|
|
234
239
|
// spawn mob
|
|
235
240
|
const entity = fetchEntity(packet.entityId)
|
|
@@ -450,7 +455,13 @@ function inject (bot) {
|
|
|
450
455
|
username: item.name,
|
|
451
456
|
ping: item.ping,
|
|
452
457
|
uuid: item.UUID,
|
|
453
|
-
displayName: new ChatMessage({ text: '', extra: [{ text: item.name }] })
|
|
458
|
+
displayName: new ChatMessage({ text: '', extra: [{ text: item.name }] }),
|
|
459
|
+
profileKeys: item.crypto
|
|
460
|
+
? {
|
|
461
|
+
publicKey: item.crypto.publicKey, // DER-encoded public key
|
|
462
|
+
signature: item.crypto.signature // Signature
|
|
463
|
+
}
|
|
464
|
+
: null
|
|
454
465
|
}
|
|
455
466
|
|
|
456
467
|
bot.uuidToUsername[item.UUID] = item.name
|
|
@@ -460,6 +471,12 @@ function inject (bot) {
|
|
|
460
471
|
// Just an Update
|
|
461
472
|
player.gamemode = item.gamemode
|
|
462
473
|
player.ping = item.ping
|
|
474
|
+
if (item.crypto) {
|
|
475
|
+
player.profileKeys = {
|
|
476
|
+
publicKey: item.crypto.publicKey,
|
|
477
|
+
signature: item.crypto.signature
|
|
478
|
+
}
|
|
479
|
+
}
|
|
463
480
|
}
|
|
464
481
|
|
|
465
482
|
if (item.displayName) {
|
|
@@ -569,7 +586,7 @@ function inject (bot) {
|
|
|
569
586
|
function moveVehicle (left, forward) {
|
|
570
587
|
bot._client.write('steer_vehicle', {
|
|
571
588
|
sideways: left,
|
|
572
|
-
forward
|
|
589
|
+
forward,
|
|
573
590
|
jump: 0x01
|
|
574
591
|
})
|
|
575
592
|
}
|
package/lib/plugins/game.js
CHANGED
|
@@ -36,7 +36,20 @@ function inject (bot, options) {
|
|
|
36
36
|
throw new Error('Unsupported dimension type in login packet')
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
if (
|
|
39
|
+
if (packet.dimensionCodec) {
|
|
40
|
+
bot.registry.loadDimensionCodec(packet.dimensionCodec)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (bot.supportFeature('dimensionDataInCodec')) { // 1.19+
|
|
44
|
+
if (packet.worldType) { // login
|
|
45
|
+
bot.game.dimension = packet.worldType.replace('minecraft:', '')
|
|
46
|
+
const { minY, height } = bot.registry.dimensionsByName[bot.game.dimension]
|
|
47
|
+
bot.game.minY = minY
|
|
48
|
+
bot.game.height = height
|
|
49
|
+
} else if (packet.dimension) { // respawn
|
|
50
|
+
bot.game.dimension = packet.dimension.replace('minecraft:', '')
|
|
51
|
+
}
|
|
52
|
+
} else if (bot.supportFeature('dimensionDataIsAvailable')) { // 1.18
|
|
40
53
|
const dimensionData = nbt.simplify(packet.dimension)
|
|
41
54
|
bot.game.minY = dimensionData.min_y
|
|
42
55
|
bot.game.height = dimensionData.height
|
|
@@ -70,10 +83,6 @@ function inject (bot, options) {
|
|
|
70
83
|
|
|
71
84
|
// varint length-prefixed string as data
|
|
72
85
|
bot._client.writeChannel(brandChannel, options.brand)
|
|
73
|
-
|
|
74
|
-
if (packet.dimensionCodec) {
|
|
75
|
-
bot.registry.loadDimensionCodec(packet.dimensionCodec)
|
|
76
|
-
}
|
|
77
86
|
})
|
|
78
87
|
|
|
79
88
|
bot._client.on('respawn', (packet) => {
|
|
@@ -2,7 +2,7 @@ const assert = require('assert')
|
|
|
2
2
|
module.exports = inject
|
|
3
3
|
|
|
4
4
|
function inject (bot) {
|
|
5
|
-
const Item = require('prismarine-item')(bot.
|
|
5
|
+
const Item = require('prismarine-item')(bot.registry)
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @param {import('prismarine-block').Block} referenceBlock
|
package/lib/plugins/inventory.js
CHANGED
|
@@ -21,8 +21,8 @@ const ALWAYS_CONSUMABLES = [
|
|
|
21
21
|
]
|
|
22
22
|
|
|
23
23
|
function inject (bot, { hideErrors }) {
|
|
24
|
-
const Item = require('prismarine-item')(bot.
|
|
25
|
-
const windows = require('prismarine-windows')(bot.version)
|
|
24
|
+
const Item = require('prismarine-item')(bot.registry)
|
|
25
|
+
const windows = require('prismarine-windows')(bot.version)
|
|
26
26
|
|
|
27
27
|
let eatingTask = createDoneTask()
|
|
28
28
|
|
|
@@ -150,45 +150,48 @@ function inject (bot, { hideErrors }) {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
async function activateBlock (block) {
|
|
153
|
+
async function activateBlock (block, direction, cursorPos) {
|
|
154
|
+
direction = direction ?? new Vec3(0, 1, 0)
|
|
155
|
+
const directionNum = vectorToDirection(direction) // The packet needs a number as the direction
|
|
156
|
+
cursorPos = cursorPos ?? new Vec3(0.5, 0.5, 0.5)
|
|
154
157
|
// TODO: tell the server that we are not sneaking while doing this
|
|
155
158
|
await bot.lookAt(block.position.offset(0.5, 0.5, 0.5), false)
|
|
156
159
|
// place block message
|
|
157
160
|
if (bot.supportFeature('blockPlaceHasHeldItem')) {
|
|
158
161
|
bot._client.write('block_place', {
|
|
159
162
|
location: block.position,
|
|
160
|
-
direction:
|
|
163
|
+
direction: directionNum,
|
|
161
164
|
heldItem: Item.toNotch(bot.heldItem),
|
|
162
|
-
cursorX:
|
|
163
|
-
cursorY:
|
|
164
|
-
cursorZ:
|
|
165
|
+
cursorX: cursorPos.scaled(16).x,
|
|
166
|
+
cursorY: cursorPos.scaled(16).y,
|
|
167
|
+
cursorZ: cursorPos.scaled(16).z
|
|
165
168
|
})
|
|
166
169
|
} else if (bot.supportFeature('blockPlaceHasHandAndIntCursor')) {
|
|
167
170
|
bot._client.write('block_place', {
|
|
168
171
|
location: block.position,
|
|
169
|
-
direction:
|
|
172
|
+
direction: directionNum,
|
|
170
173
|
hand: 0,
|
|
171
|
-
cursorX:
|
|
172
|
-
cursorY:
|
|
173
|
-
cursorZ:
|
|
174
|
+
cursorX: cursorPos.scaled(16).x,
|
|
175
|
+
cursorY: cursorPos.scaled(16).y,
|
|
176
|
+
cursorZ: cursorPos.scaled(16).z
|
|
174
177
|
})
|
|
175
178
|
} else if (bot.supportFeature('blockPlaceHasHandAndFloatCursor')) {
|
|
176
179
|
bot._client.write('block_place', {
|
|
177
180
|
location: block.position,
|
|
178
|
-
direction:
|
|
181
|
+
direction: directionNum,
|
|
179
182
|
hand: 0,
|
|
180
|
-
cursorX:
|
|
181
|
-
cursorY:
|
|
182
|
-
cursorZ:
|
|
183
|
+
cursorX: cursorPos.x,
|
|
184
|
+
cursorY: cursorPos.y,
|
|
185
|
+
cursorZ: cursorPos.z
|
|
183
186
|
})
|
|
184
187
|
} else if (bot.supportFeature('blockPlaceHasInsideBlock')) {
|
|
185
188
|
bot._client.write('block_place', {
|
|
186
189
|
location: block.position,
|
|
187
|
-
direction:
|
|
190
|
+
direction: directionNum,
|
|
188
191
|
hand: 0,
|
|
189
|
-
cursorX:
|
|
190
|
-
cursorY:
|
|
191
|
-
cursorZ:
|
|
192
|
+
cursorX: cursorPos.x,
|
|
193
|
+
cursorY: cursorPos.y,
|
|
194
|
+
cursorZ: cursorPos.z,
|
|
192
195
|
insideBlock: false
|
|
193
196
|
})
|
|
194
197
|
}
|
|
@@ -325,7 +328,7 @@ function inject (bot, { hideErrors }) {
|
|
|
325
328
|
}
|
|
326
329
|
window.deposit = async (itemType, metadata, count, nbt) => {
|
|
327
330
|
const options = {
|
|
328
|
-
window
|
|
331
|
+
window,
|
|
329
332
|
itemType,
|
|
330
333
|
metadata,
|
|
331
334
|
count,
|
|
@@ -339,8 +342,8 @@ function inject (bot, { hideErrors }) {
|
|
|
339
342
|
}
|
|
340
343
|
}
|
|
341
344
|
|
|
342
|
-
async function openBlock (block) {
|
|
343
|
-
bot.activateBlock(block)
|
|
345
|
+
async function openBlock (block, direction, cursorPos) {
|
|
346
|
+
bot.activateBlock(block, direction, cursorPos)
|
|
344
347
|
const [window] = await once(bot, 'windowOpen')
|
|
345
348
|
extendWindow(window)
|
|
346
349
|
return window
|
|
@@ -433,7 +436,7 @@ function inject (bot, { hideErrors }) {
|
|
|
433
436
|
if (click === undefined || !windowClickQueue.some(clicks => clicks.id === actionId)) {
|
|
434
437
|
// mimic vanilla client and send a rejection for faulty transaction packets
|
|
435
438
|
bot._client.write('transaction', {
|
|
436
|
-
windowId
|
|
439
|
+
windowId,
|
|
437
440
|
action: actionId,
|
|
438
441
|
accepted: true
|
|
439
442
|
// bot.emit(`confirmTransaction${click.id}`, false)
|
|
@@ -513,7 +516,7 @@ function inject (bot, { hideErrors }) {
|
|
|
513
516
|
slot,
|
|
514
517
|
mouseButton,
|
|
515
518
|
mode,
|
|
516
|
-
changedSlots
|
|
519
|
+
changedSlots,
|
|
517
520
|
cursorItem: Item.toNotch(window.selectedItem)
|
|
518
521
|
})
|
|
519
522
|
} else if (bot.supportFeature('actionIdUsed')) { // <= 1.16.5
|
|
@@ -531,7 +534,7 @@ function inject (bot, { hideErrors }) {
|
|
|
531
534
|
slot,
|
|
532
535
|
mouseButton,
|
|
533
536
|
mode,
|
|
534
|
-
changedSlots
|
|
537
|
+
changedSlots,
|
|
535
538
|
cursorItem: Item.toNotch(window.selectedItem)
|
|
536
539
|
})
|
|
537
540
|
}
|
|
@@ -641,6 +644,28 @@ function inject (bot, { hideErrors }) {
|
|
|
641
644
|
bot.emit(`setWindowItems:${window.id}`)
|
|
642
645
|
})
|
|
643
646
|
|
|
647
|
+
/**
|
|
648
|
+
* Convert a vector direction to minecraft packet number direction
|
|
649
|
+
* @param {Vec3} v
|
|
650
|
+
* @returns {number}
|
|
651
|
+
*/
|
|
652
|
+
function vectorToDirection (v) {
|
|
653
|
+
if (v.y < 0) {
|
|
654
|
+
return 0
|
|
655
|
+
} else if (v.y > 0) {
|
|
656
|
+
return 1
|
|
657
|
+
} else if (v.z < 0) {
|
|
658
|
+
return 2
|
|
659
|
+
} else if (v.z > 0) {
|
|
660
|
+
return 3
|
|
661
|
+
} else if (v.x < 0) {
|
|
662
|
+
return 4
|
|
663
|
+
} else if (v.x > 0) {
|
|
664
|
+
return 5
|
|
665
|
+
}
|
|
666
|
+
assert.ok(false, `invalid direction vector ${v}`)
|
|
667
|
+
}
|
|
668
|
+
|
|
644
669
|
bot.activateBlock = activateBlock
|
|
645
670
|
bot.activateEntity = activateEntity
|
|
646
671
|
bot.activateEntityAt = activateEntityAt
|
package/lib/plugins/ray_trace.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { Vec3 } = require('vec3')
|
|
2
|
+
const { RaycastIterator } = require('prismarine-world').iterators
|
|
2
3
|
|
|
3
4
|
module.exports = (bot) => {
|
|
4
5
|
function getViewDirection (pitch, yaw) {
|
|
@@ -24,6 +25,41 @@ module.exports = (bot) => {
|
|
|
24
25
|
return bot.world.raycast(eyePosition, viewDirection, maxDistance, matcher)
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
bot.entityAtCursor = (maxDistance = 3.5) => {
|
|
29
|
+
const block = bot.blockAtCursor(maxDistance)
|
|
30
|
+
maxDistance = block?.intersect.distanceTo(bot.entity.position) ?? maxDistance
|
|
31
|
+
|
|
32
|
+
const entities = Object.values(bot.entities)
|
|
33
|
+
.filter(entity => entity.type !== 'object' && entity.username !== bot.username && entity.position.distanceTo(bot.entity.position) <= maxDistance)
|
|
34
|
+
|
|
35
|
+
const dir = new Vec3(-Math.sin(bot.entity.yaw) * Math.cos(bot.entity.pitch), Math.sin(bot.entity.pitch), -Math.cos(bot.entity.yaw) * Math.cos(bot.entity.pitch))
|
|
36
|
+
const iterator = new RaycastIterator(bot.entity.position.offset(0, bot.entity.height, 0), dir.normalize(), maxDistance)
|
|
37
|
+
|
|
38
|
+
let targetEntity = null
|
|
39
|
+
let targetDist = maxDistance
|
|
40
|
+
|
|
41
|
+
for (let i = 0; i < entities.length; i++) {
|
|
42
|
+
const entity = entities[i]
|
|
43
|
+
const w = entity.width / 2
|
|
44
|
+
|
|
45
|
+
const shapes = [[-w, 0, -w, w, entity.height + (entity.type === 'player' ? 0.18 : 0), w]]
|
|
46
|
+
const intersect = iterator.intersect(shapes, entity.position)
|
|
47
|
+
if (intersect) {
|
|
48
|
+
const entityDir = entity.position.minus(bot.entity.position) // Can be combined into 1 line
|
|
49
|
+
const sign = Math.sign(entityDir.dot(dir))
|
|
50
|
+
if (sign !== -1) {
|
|
51
|
+
const dist = bot.entity.position.distanceTo(intersect.pos)
|
|
52
|
+
if (dist < targetDist) {
|
|
53
|
+
targetEntity = entity
|
|
54
|
+
targetDist = dist
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return targetEntity
|
|
61
|
+
}
|
|
62
|
+
|
|
27
63
|
bot.blockAtEntityCursor = (entity = bot.entity, maxDistance = 256, matcher = null) => {
|
|
28
64
|
if (!entity.position || !entity.height || !entity.pitch || !entity.yaw) return null
|
|
29
65
|
const { position, height, pitch, yaw } = entity
|
package/lib/plugins/settings.js
CHANGED
|
@@ -58,7 +58,7 @@ function inject (bot, options) {
|
|
|
58
58
|
viewDistance: viewDistanceBits,
|
|
59
59
|
chatFlags: chatBits,
|
|
60
60
|
chatColors: bot.settings.colorsEnabled,
|
|
61
|
-
skinParts
|
|
61
|
+
skinParts,
|
|
62
62
|
mainHand: handBits,
|
|
63
63
|
enableTextFiltering: bot.settings.enableTextFiltering,
|
|
64
64
|
enableServerListing: bot.settings.enableServerListing
|
package/lib/plugins/tablist.js
CHANGED
|
@@ -5,7 +5,7 @@ const escapeValueNewlines = str => {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function inject (bot) {
|
|
8
|
-
const ChatMessage = require('prismarine-chat')(bot.
|
|
8
|
+
const ChatMessage = require('prismarine-chat')(bot.registry)
|
|
9
9
|
|
|
10
10
|
bot.tablist = {
|
|
11
11
|
header: new ChatMessage(''),
|
package/lib/plugins/team.js
CHANGED
package/lib/plugins/villager.js
CHANGED
|
@@ -5,7 +5,7 @@ module.exports = inject
|
|
|
5
5
|
|
|
6
6
|
function inject (bot, { version }) {
|
|
7
7
|
const { entitiesByName } = bot.registry
|
|
8
|
-
const Item = require('prismarine-item')(bot.
|
|
8
|
+
const Item = require('prismarine-item')(bot.registry)
|
|
9
9
|
|
|
10
10
|
let selectTrade
|
|
11
11
|
if (bot.supportFeature('useMCTrSel')) {
|
|
@@ -100,18 +100,20 @@ function inject (bot, { version }) {
|
|
|
100
100
|
if (packet.windowId !== villager.id) return
|
|
101
101
|
assert.ok(packet.trades)
|
|
102
102
|
villager.trades = packet.trades.map(trade => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
inputItem2
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
trade.inputs = [trade.inputItem1 = Item.fromNotch(trade.inputItem1 || { blockId: -1 })]
|
|
104
|
+
if (trade.inputItem2?.itemCount != null) {
|
|
105
|
+
trade.inputs.push(trade.inputItem2 = Item.fromNotch(trade.inputItem2 || { blockId: -1 }))
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
trade.hasItem2 = !!(trade.inputItem2 && trade.inputItem2.type && trade.inputItem2.count)
|
|
109
|
+
trade.outputs = [trade.outputItem = Item.fromNotch(trade.outputItem || { blockId: -1 })]
|
|
110
|
+
|
|
108
111
|
if (trade.demand !== undefined && trade.specialPrice !== undefined) { // the price is affected by demand and reputation
|
|
109
112
|
const demandDiff = Math.max(0, Math.floor(trade.inputItem1.count * trade.demand * trade.priceMultiplier))
|
|
110
113
|
trade.realPrice = Math.min(Math.max((trade.inputItem1.count + trade.specialPrice + demandDiff), 1), trade.inputItem1.stackSize)
|
|
111
114
|
} else {
|
|
112
115
|
trade.realPrice = trade.inputItem1.count
|
|
113
116
|
}
|
|
114
|
-
trade.hasItem2 = !!(trade.inputItem2 && trade.inputItem2.type && trade.inputItem2.count)
|
|
115
117
|
return trade
|
|
116
118
|
})
|
|
117
119
|
if (!ready) {
|
package/lib/scoreboard.js
CHANGED
|
@@ -5,7 +5,7 @@ const sortItems = (a, b) => {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
module.exports = (bot) => {
|
|
8
|
-
const ChatMessage = require('prismarine-chat')(bot.
|
|
8
|
+
const ChatMessage = require('prismarine-chat')(bot.registry)
|
|
9
9
|
|
|
10
10
|
class ScoreBoard {
|
|
11
11
|
constructor (packet) {
|
package/lib/team.js
CHANGED
|
@@ -3,8 +3,8 @@ let MessageBuilder
|
|
|
3
3
|
|
|
4
4
|
module.exports = loader
|
|
5
5
|
|
|
6
|
-
function loader (
|
|
7
|
-
ChatMessage = require('prismarine-chat')(
|
|
6
|
+
function loader (registry) {
|
|
7
|
+
ChatMessage = require('prismarine-chat')(registry)
|
|
8
8
|
MessageBuilder = ChatMessage.MessageBuilder
|
|
9
9
|
return Team
|
|
10
10
|
}
|
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', '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']
|
|
2
|
+
supportedVersions: ['1.8', '1.9', '1.10', '1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.19'],
|
|
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', '1.19']
|
|
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": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "create minecraft bots with a stable, high level API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"mocha_test": "mocha --reporter spec --exit",
|
|
9
9
|
"test": "npm run mocha_test",
|
|
10
10
|
"pretest": "npm run lint",
|
|
11
|
-
"lint": "standard &&
|
|
12
|
-
"fix": "standard --fix &&
|
|
11
|
+
"lint": "standard && standard-markdown",
|
|
12
|
+
"fix": "standard --fix && standard-markdown --fix",
|
|
13
13
|
"prepublishOnly": "cp docs/README.md README.md"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
@@ -21,33 +21,32 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"minecraft-data": "^3.
|
|
25
|
-
"minecraft-protocol": "^1.
|
|
24
|
+
"minecraft-data": "^3.15.2",
|
|
25
|
+
"minecraft-protocol": "^1.36.0",
|
|
26
26
|
"prismarine-biome": "^1.1.1",
|
|
27
27
|
"prismarine-block": "^1.13.1",
|
|
28
|
-
"prismarine-chat": "^1.
|
|
29
|
-
"prismarine-chunk": "^1.
|
|
30
|
-
"prismarine-entity": "^2.
|
|
31
|
-
"prismarine-item": "^1.
|
|
28
|
+
"prismarine-chat": "^1.7.1",
|
|
29
|
+
"prismarine-chunk": "^1.32.0",
|
|
30
|
+
"prismarine-entity": "^2.2.0",
|
|
31
|
+
"prismarine-item": "^1.12.1",
|
|
32
32
|
"prismarine-nbt": "^2.0.0",
|
|
33
33
|
"prismarine-physics": "^1.3.1",
|
|
34
|
-
"prismarine-recipe": "^1.
|
|
35
|
-
"prismarine-registry": "^1.
|
|
36
|
-
"prismarine-windows": "^2.
|
|
34
|
+
"prismarine-recipe": "^1.3.0",
|
|
35
|
+
"prismarine-registry": "^1.5.0",
|
|
36
|
+
"prismarine-windows": "^2.5.0",
|
|
37
37
|
"prismarine-world": "^3.6.0",
|
|
38
38
|
"protodef": "^1.14.0",
|
|
39
39
|
"typed-emitter": "^1.0.0",
|
|
40
40
|
"vec3": "^0.1.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^18.0.6",
|
|
44
44
|
"doctoc": "^2.0.1",
|
|
45
45
|
"minecraft-wrap": "^1.3.0",
|
|
46
46
|
"mineflayer": "file:.",
|
|
47
|
-
"mocha": "^
|
|
48
|
-
"standard": "^
|
|
47
|
+
"mocha": "^10.0.0",
|
|
48
|
+
"standard": "^17.0.0",
|
|
49
49
|
"standard-markdown": "^7.1.0",
|
|
50
|
-
"ts-standard": "^11.0.0",
|
|
51
50
|
"typescript": "^4.4.3"
|
|
52
51
|
}
|
|
53
52
|
}
|