diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d328e20..8fc81edb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - name: Use Node.js 22.x uses: actions/setup-node@v1.4.4 with: - node-version: 22.x + node-version: 24 - run: npm i && npm run lint PrepareTestedVersions: @@ -28,7 +28,7 @@ jobs: - name: Use Node.js 22.x uses: actions/setup-node@v1.4.4 with: - node-version: 22.x + node-version: 24 - id: set-matrix run: | node -e " @@ -48,7 +48,7 @@ jobs: - name: Use Node.js 22.x uses: actions/setup-node@v1.4.4 with: - node-version: 22.x + node-version: 24 - name: Install Dependencies run: npm install - name: Start Tests diff --git a/package.json b/package.json index 7611dd66..a3147f37 100644 --- a/package.json +++ b/package.json @@ -35,15 +35,14 @@ "exit-hook": "^2.2.1", "flatmap": "^0.0.3", "long": "^5.1.0", - "minecraft-protocol": "^1.53.0", + "minecraft-protocol": "^1.66.0", "moment": "^2.10.6", "needle": "^2.5.0", - "node-gzip": "^1.1.2", "prismarine-chunk": "^1.34.0", "prismarine-entity": "^2.2.0", "prismarine-item": "^1.14.0", - "prismarine-nbt": "^2.2.1", - "prismarine-provider-anvil": "^2.7.0", + "prismarine-nbt": "^2.8.0", + "prismarine-provider-anvil": "^2.13.0", "prismarine-registry": "^1.7.0", "prismarine-windows": "^2.8.0", "prismarine-world": "^3.6.2", diff --git a/src/lib/playerDat.js b/src/lib/playerDat.js index ef87a01b..24054308 100644 --- a/src/lib/playerDat.js +++ b/src/lib/playerDat.js @@ -4,10 +4,14 @@ const fs = require('fs') const Vec3 = require('vec3').Vec3 const nbt = require('prismarine-nbt') const long = require('long') -const { gzip } = require('node-gzip') +const zlib = require('zlib') const { promisify } = require('util') const convertInventorySlotId = require('./convertInventorySlotId') +// Use sync gzip to avoid uncaught async zlib errors during teardown. +// See nodejs/node#62325, nodejs/node#61202 +const gzip = (data) => Promise.resolve(zlib.gzipSync(data)) + const nbtParse = promisify(nbt.parse) const playerDefaults = { diff --git a/src/lib/plugins/physics.js b/src/lib/plugins/physics.js index 9b9f6881..45a0fc26 100644 --- a/src/lib/plugins/physics.js +++ b/src/lib/plugins/physics.js @@ -47,6 +47,7 @@ module.exports.entity = function (entity, serv, { version }) { scaledVelocity = scaledVelocity.floored() entity._writeNearby('entity_velocity', { entityId: entity.id, + velocity: scaledVelocity, velocityX: scaledVelocity.x, velocityY: scaledVelocity.y, velocityZ: scaledVelocity.z diff --git a/src/lib/plugins/spawn.js b/src/lib/plugins/spawn.js index 5fa661e4..b1ebedbb 100644 --- a/src/lib/plugins/spawn.js +++ b/src/lib/plugins/spawn.js @@ -334,6 +334,7 @@ module.exports.entity = function (entity, serv) { headPitch: entity.headPitch, currentItem: 0, objectData: entity.data, + velocity: scaledVelocity, velocityX: scaledVelocity.x, velocityY: scaledVelocity.y, velocityZ: scaledVelocity.z, diff --git a/test/mineflayer.test.js b/test/mineflayer.test.js index 459fe032..23e441ad 100644 --- a/test/mineflayer.test.js +++ b/test/mineflayer.test.js @@ -159,6 +159,14 @@ squid.testedVersions.forEach((testedVersion, i) => { afterEach(async () => { console.log('Quitting server...') + // Disconnect bots before stopping the server so the compressed + // stream is drained cleanly. Without this, Node 24's stricter + // zlib can throw an uncaught "unexpected end of file" error when + // the server force-kicks clients and truncates the compressed data. + try { bot?.quit() } catch (e) { /* ignore */ } + try { bot2?.quit() } catch (e) { /* ignore */ } + // Give bots time to disconnect cleanly + await new Promise(resolve => setTimeout(resolve, 500)) await serv.quit() console.log('Quit server!') })