mineflayer 4.24.0 → 4.26.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 +6 -6
- package/.github/workflows/npm-publish.yml +1 -1
- package/docs/history.md +9 -0
- package/index.js +1 -1
- package/lib/plugins/blocks.js +1 -1
- package/lib/plugins/digging.js +5 -1
- package/lib/plugins/entities.js +62 -15
- package/lib/version.js +1 -1
- package/package.json +3 -3
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 22.x
|
|
16
16
|
uses: actions/setup-node@v1.4.4
|
|
17
17
|
with:
|
|
18
|
-
node-version:
|
|
18
|
+
node-version: 22.x
|
|
19
19
|
- run: npm i && npm run lint
|
|
20
20
|
|
|
21
21
|
PrepareSupportedVersions:
|
|
@@ -25,10 +25,10 @@ jobs:
|
|
|
25
25
|
|
|
26
26
|
steps:
|
|
27
27
|
- uses: actions/checkout@v2
|
|
28
|
-
- name: Use Node.js
|
|
28
|
+
- name: Use Node.js 22.x
|
|
29
29
|
uses: actions/setup-node@v1.4.4
|
|
30
30
|
with:
|
|
31
|
-
node-version:
|
|
31
|
+
node-version: 22.x
|
|
32
32
|
- id: set-matrix
|
|
33
33
|
run: |
|
|
34
34
|
node -e "
|
|
@@ -45,10 +45,10 @@ jobs:
|
|
|
45
45
|
|
|
46
46
|
steps:
|
|
47
47
|
- uses: actions/checkout@v2
|
|
48
|
-
- name: Use Node.js
|
|
48
|
+
- name: Use Node.js 22.x
|
|
49
49
|
uses: actions/setup-node@v1.4.4
|
|
50
50
|
with:
|
|
51
|
-
node-version:
|
|
51
|
+
node-version: 22.x
|
|
52
52
|
- name: Setup Java JDK
|
|
53
53
|
uses: actions/setup-java@v1.4.3
|
|
54
54
|
with:
|
package/docs/history.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 4.26.0
|
|
2
|
+
* [Use node 22 (#3570)](https://github.com/PrismarineJS/mineflayer/commit/dbff9314418d30df203c32fe83f2a1b56653d0a6) (thanks @rom1504)
|
|
3
|
+
* [Fix infinity setTimeout by throwing error (#3561)](https://github.com/PrismarineJS/mineflayer/commit/69539494c88c2ca718330142839a35414ecd3bda) (thanks @BBpezsgo)
|
|
4
|
+
* [Prevent TypeError when removing event lPrevent TypeError when removing event listeners in switchWorld (BunJS issue maybe)isteners in switchWorld (#3544)](https://github.com/PrismarineJS/mineflayer/commit/e974e703a875d16f5e36d35574bf334a20c76b1b) (thanks @0x15d3v2)
|
|
5
|
+
* [Mounting for other entities and fix bot not dismounting when the vehicle is gone (#3384)](https://github.com/PrismarineJS/mineflayer/commit/08b7317b57ca5c2f1a6ddd116bd0c74c2e10c20c) (thanks @qwqtoday)
|
|
6
|
+
|
|
7
|
+
## 4.25.0
|
|
8
|
+
* [1.21.4 (#3546)](https://github.com/PrismarineJS/mineflayer/commit/8bbf5669f5ff3ea8a708633e51b47c312dc7a26b) (thanks @extremeheat)
|
|
9
|
+
|
|
1
10
|
## 4.24.0
|
|
2
11
|
* [Support 1.21.3. (#3489)](https://github.com/PrismarineJS/mineflayer/commit/58ae9e5b5abf75139f4ba93fe4f34ef7ed3936e8) (thanks @rom1504)
|
|
3
12
|
* [Fix out of bounds access leading to crash at spawn (#3535)](https://github.com/PrismarineJS/mineflayer/commit/3187368397e880ba8b32bb03affa18203cbcbb42) (thanks @wAIfu-DEV)
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
if (typeof process !== 'undefined' && !process.browser && process.platform !== 'browser' && 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 >= 22.x.x from https://nodejs.org/')
|
|
4
4
|
process.exit(1)
|
|
5
5
|
}
|
|
6
6
|
|
package/lib/plugins/blocks.js
CHANGED
|
@@ -511,7 +511,7 @@ function inject (bot, { version, storageBuilder, hideErrors }) {
|
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
for (const [name, listener] of Object.entries(bot._events)) {
|
|
514
|
-
if (name.startsWith('blockUpdate:')) {
|
|
514
|
+
if (name.startsWith('blockUpdate:') && typeof listener === 'function') {
|
|
515
515
|
bot.emit(name, null, null)
|
|
516
516
|
bot.off(name, listener)
|
|
517
517
|
}
|
package/lib/plugins/digging.js
CHANGED
|
@@ -24,6 +24,11 @@ function inject (bot) {
|
|
|
24
24
|
digFace = 'auto'
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const waitTime = bot.digTime(block)
|
|
28
|
+
if (waitTime === Infinity) {
|
|
29
|
+
throw new Error(`dig time for ${block?.name ?? block} is Infinity`)
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
bot.targetDigFace = 1 // Default (top)
|
|
28
33
|
|
|
29
34
|
if (forceLook !== 'ignore') {
|
|
@@ -127,7 +132,6 @@ function inject (bot) {
|
|
|
127
132
|
location: block.position,
|
|
128
133
|
face: bot.targetDigFace // default face is 1 (top)
|
|
129
134
|
})
|
|
130
|
-
const waitTime = bot.digTime(block)
|
|
131
135
|
waitTimeout = setTimeout(finishDigging, waitTime)
|
|
132
136
|
bot.targetDigBlock = block
|
|
133
137
|
bot.swingArm()
|
package/lib/plugins/entities.js
CHANGED
|
@@ -803,26 +803,73 @@ function inject (bot) {
|
|
|
803
803
|
|
|
804
804
|
// attaching to a vehicle
|
|
805
805
|
bot._client.on('attach_entity', (packet) => {
|
|
806
|
-
|
|
807
|
-
const vehicle =
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
806
|
+
const passenger = fetchEntity(packet.entityId)
|
|
807
|
+
const vehicle = packet.vehicleId === -1 ? null : fetchEntity(packet.vehicleId)
|
|
808
|
+
|
|
809
|
+
const originalVehicle = passenger.vehicle
|
|
810
|
+
if (originalVehicle !== null) {
|
|
811
|
+
const index = originalVehicle.passengers.indexOf(passenger)
|
|
812
|
+
originalVehicle.passengers = originalVehicle.passengers.splice(index, 1)
|
|
813
|
+
}
|
|
814
|
+
passenger.vehicle = vehicle
|
|
815
|
+
vehicle.passengers.push(passenger)
|
|
816
|
+
|
|
817
|
+
if (packet.entityId === bot.entity.id) {
|
|
818
|
+
const vehicle = bot.vehicle
|
|
819
|
+
if (packet.vehicleId === -1) {
|
|
820
|
+
bot.vehicle = null
|
|
821
|
+
bot.emit('dismount', vehicle)
|
|
822
|
+
} else {
|
|
823
|
+
bot.vehicle = bot.entities[packet.vehicleId]
|
|
824
|
+
bot.emit('mount')
|
|
825
|
+
}
|
|
814
826
|
}
|
|
815
827
|
})
|
|
816
828
|
|
|
817
829
|
bot._client.on('set_passengers', ({ entityId, passengers }) => {
|
|
818
|
-
|
|
819
|
-
const vehicle = bot.
|
|
820
|
-
|
|
830
|
+
const passengerEntities = passengers.map((passengerId) => fetchEntity(passengerId))
|
|
831
|
+
const vehicle = entityId === -1 ? null : bot.entities[entityId]
|
|
832
|
+
|
|
833
|
+
for (const passengerEntity of passengerEntities) {
|
|
834
|
+
const originalVehicle = passengerEntity.vehicle
|
|
835
|
+
if (originalVehicle !== null) {
|
|
836
|
+
const index = originalVehicle.passengers.indexOf(passengerEntity)
|
|
837
|
+
originalVehicle.passengers = originalVehicle.passengers.splice(index, 1)
|
|
838
|
+
}
|
|
839
|
+
passengerEntity.vehicle = vehicle
|
|
840
|
+
if (vehicle !== null) {
|
|
841
|
+
vehicle.passengers.push(passengerEntity)
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
if (passengers.includes(bot.entity.id)) {
|
|
846
|
+
const originalVehicle = bot.vehicle
|
|
847
|
+
if (entityId === -1) {
|
|
848
|
+
bot.vehicle = null
|
|
849
|
+
bot.emit('dismount', originalVehicle)
|
|
850
|
+
} else {
|
|
851
|
+
bot.vehicle = bot.entities[entityId]
|
|
852
|
+
bot.emit('mount')
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
})
|
|
856
|
+
|
|
857
|
+
// dismounting when the vehicle is gone
|
|
858
|
+
bot._client.on('entityGone', (entity) => {
|
|
859
|
+
if (bot.vehicle === entity) {
|
|
821
860
|
bot.vehicle = null
|
|
822
|
-
bot.emit('dismount',
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
|
|
861
|
+
bot.emit('dismount', (entity))
|
|
862
|
+
}
|
|
863
|
+
if (entity.passengers) {
|
|
864
|
+
for (const passenger of entity.passengers) {
|
|
865
|
+
passenger.vehicle = null
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
if (entity.vehicle) {
|
|
869
|
+
const index = entity.vehicle.passengers.indexOf(entity)
|
|
870
|
+
if (index !== -1) {
|
|
871
|
+
entity.vehicle.passengers = entity.vehicle.passengers.splice(index, 1)
|
|
872
|
+
}
|
|
826
873
|
}
|
|
827
874
|
})
|
|
828
875
|
|
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
|
+
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']
|
|
2
2
|
module.exports = {
|
|
3
3
|
|
|
4
4
|
testedVersions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mineflayer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.26.0",
|
|
4
4
|
"description": "create minecraft bots with a stable, high level API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"url": "git://github.com/PrismarineJS/mineflayer.git"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=22"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prismarine-block": "^1.17.0",
|
|
28
28
|
"prismarine-chat": "^1.7.1",
|
|
29
29
|
"prismarine-chunk": "^1.36.0",
|
|
30
|
-
"prismarine-entity": "^2.
|
|
30
|
+
"prismarine-entity": "^2.5.0",
|
|
31
31
|
"prismarine-item": "^1.15.0",
|
|
32
32
|
"prismarine-nbt": "^2.0.0",
|
|
33
33
|
"prismarine-physics": "^1.9.0",
|