From be14be2c45d5f67828bb5fe71630c1f08b9e56a6 Mon Sep 17 00:00:00 2001 From: extremeheat Date: Tue, 7 Jan 2025 22:11:47 +0000 Subject: [PATCH] fix internalTest and check --- lib/plugins/creative.js | 6 +++++- lib/plugins/entities.js | 4 ++-- test/internalTest.js | 13 ++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/plugins/creative.js b/lib/plugins/creative.js index 8140c9e34..40ddc768c 100644 --- a/lib/plugins/creative.js +++ b/lib/plugins/creative.js @@ -42,12 +42,16 @@ function inject (bot) { return new Promise((resolve, reject) => { function updateSlot (oldItem, newItem) { console.log('[creative] Slot update', arguments) - if (newItem.itemId !== item.itemId) reject(Error('Server rejected')) + if (newItem.itemId !== item.itemId) { + creativeSlotsUpdates[slot] = false + reject(Error('Server rejected')) + } } bot.inventory.once(`updateSlot:${slot}`, updateSlot) setTimeout(() => { bot.inventory.off(`updateSlot:${slot}`, updateSlot) console.log('[creative] setSlot OK') + creativeSlotsUpdates[slot] = false resolve() }, waitTimeout) }) diff --git a/lib/plugins/entities.js b/lib/plugins/entities.js index 740fcb742..b371ff73f 100644 --- a/lib/plugins/entities.js +++ b/lib/plugins/entities.js @@ -598,10 +598,10 @@ function inject (bot) { }) bot._client.on('player_info', (packet) => { - console.log('Player Info', packet) + console.dir(packet, { depth: null }) // player list item(s) - if (typeof packet.action === 'string') { + if (typeof packet.action !== 'number') { // 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/test/internalTest.js b/test/internalTest.js index 6e5f278cd..fc5519942 100644 --- a/test/internalTest.js +++ b/test/internalTest.js @@ -13,7 +13,18 @@ for (const supportedVersion of mineflayer.testedVersions) { const Chunk = require('prismarine-chunk')(supportedVersion) const isNewPlayerInfoFormat = registry.version['>=']('1.21.3') function wrapPlayerInfo (n) { - if (isNewPlayerInfoFormat) return { _value: n } + if (isNewPlayerInfoFormat) { + return { + _value: n, + add_player: (n & 1) !== 0, + initialize_chat: (n & 2) !== 0, + update_game_mode: (n & 4) !== 0, + update_listed: (n & 8) !== 0, + update_latency: (n & 16) !== 0, + update_display_name: (n & 32) !== 0, + update_priority: (n & 64) !== 0 + } + } return n }