From a93bb2c2dc48fcccd38b6cc9109fa2bd255a28ab Mon Sep 17 00:00:00 2001 From: extremeheat Date: Tue, 7 Jan 2025 12:01:18 +0000 Subject: [PATCH] disable logging and --bail --- lib/plugins/entities.js | 2 +- package.json | 2 +- test/externalTests/plugins/testCommon.js | 26 +++++++++++++----------- test/internalTest.js | 15 +++++++++----- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/lib/plugins/entities.js b/lib/plugins/entities.js index 0ec573f8b..740fcb742 100644 --- a/lib/plugins/entities.js +++ b/lib/plugins/entities.js @@ -601,7 +601,7 @@ function inject (bot) { console.log('Player Info', packet) // player list item(s) - if (bot.registry.version['>=']('1.21.3')) { + if (typeof packet.action === 'string') { // the features checks below this will be un-needed with https://github.com/PrismarineJS/minecraft-data/pull/948 for (const update of packet.data) { let player = bot.uuidToUsername[update.uuid] ? bot.players[bot.uuidToUsername[update.uuid]] : null diff --git a/package.json b/package.json index c2df60783..7b69e2f79 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "types": "index.d.ts", "scripts": { - "mocha_test": "mocha --reporter spec --exit --bail", + "mocha_test": "mocha --reporter spec --exit", "test": "npm run mocha_test", "pretest": "npm run lint", "lint": "standard && standard-markdown", diff --git a/test/externalTests/plugins/testCommon.js b/test/externalTests/plugins/testCommon.js index 2876cef0c..78506ee2c 100644 --- a/test/externalTests/plugins/testCommon.js +++ b/test/externalTests/plugins/testCommon.js @@ -143,18 +143,20 @@ function inject (bot) { } // DEBUG - bot._client.on('packet', function (data, meta) { - if (['chunk', 'time', 'light', 'alive'].some(e => meta.name.includes(e))) return - console.log('->', meta.name, JSON.stringify(data)?.slice(0, 250)) - }) - const oldWrite = bot._client.write - bot._client.write = function (name, data) { - if (['alive', 'pong', 'ping'].some(e => name.includes(e))) return - console.log('<-', name, JSON.stringify(data)?.slice(0, 250)) - oldWrite.apply(bot._client, arguments) - } - BigInt.prototype.toJSON ??= function () { - return this.toString() + if (process.env.DEBUG) { + bot._client.on('packet', function (data, meta) { + if (['chunk', 'time', 'light', 'alive'].some(e => meta.name.includes(e))) return + console.log('->', meta.name, JSON.stringify(data)?.slice(0, 250)) + }) + const oldWrite = bot._client.write + bot._client.write = function (name, data) { + if (['alive', 'pong', 'ping'].some(e => name.includes(e))) return + console.log('<-', name, JSON.stringify(data)?.slice(0, 250)) + oldWrite.apply(bot._client, arguments) + } + BigInt.prototype.toJSON ??= function () { // eslint-disable-line + return this.toString() + } } // you need to be in creative mode for this to work diff --git a/test/internalTest.js b/test/internalTest.js index ae28a1fda..69b0535a9 100644 --- a/test/internalTest.js +++ b/test/internalTest.js @@ -11,8 +11,13 @@ for (const supportedVersion of mineflayer.testedVersions) { const registry = require('prismarine-registry')(supportedVersion) const version = registry.version const Chunk = require('prismarine-chunk')(supportedVersion) - const hasSignedChat = registry.supportFeature('signedChat') + const isNewPlayerInfoFormat = registry.version['>=']('1.20.3') + function wrapPlayerInfo (n) { + if (isNewPlayerInfoFormat) return { _value: n } + return n + } + const hasSignedChat = registry.supportFeature('signedChat') function chatText (text) { // TODO: move this to prismarine-chat in a new ChatMessage(text).toNotch(asNbt) method return registry.supportFeature('chatPacketsUseNbtComponents') @@ -580,7 +585,7 @@ for (const supportedVersion of mineflayer.testedVersions) { assert.strictEqual(entity.username, player.displayName.toString()) if (registry.supportFeature('playerInfoActionIsBitfield')) { client.write('player_info', { - action: 53, + action: wrapPlayerInfo(53), data: [{ uuid: '1-2-3-4', player: { @@ -616,7 +621,7 @@ for (const supportedVersion of mineflayer.testedVersions) { assert.strictEqual('wvffle', player.displayName.toString()) if (registry.supportFeature('playerInfoActionIsBitfield')) { client.write('player_info', { - action: 53, + action: wrapPlayerInfo(53), data: [{ uuid: '1-2-3-4', player: { @@ -653,7 +658,7 @@ for (const supportedVersion of mineflayer.testedVersions) { if (registry.supportFeature('playerInfoActionIsBitfield')) { client.write('player_info', { - action: 53, + action: wrapPlayerInfo(53), data: [{ uuid: '1-2-3-4', player: { @@ -736,7 +741,7 @@ for (const supportedVersion of mineflayer.testedVersions) { if (registry.supportFeature('playerInfoActionIsBitfield')) { client.write('player_info', { - action: 53, + action: wrapPlayerInfo(53), data: [{ uuid: '1-2-3-4', player: {