From cd6698652faaf293b21edbd9926087c57c4bc254 Mon Sep 17 00:00:00 2001 From: Ic3Tank <61137113+IceTank@users.noreply.github.com> Date: Thu, 21 Nov 2024 19:47:22 +0100 Subject: [PATCH] Add gamemode test related comments --- lib/plugins/game.js | 2 +- test/externalTests/gamemode.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/plugins/game.js b/lib/plugins/game.js index 0fbe62f07..1a6522907 100644 --- a/lib/plugins/game.js +++ b/lib/plugins/game.js @@ -25,7 +25,7 @@ function inject (bot, options) { function handleRespawnPacketData (packet) { bot.game.levelType = packet.levelType ?? (packet.isFlat ? 'flat' : 'default') bot.game.hardcore = packet.isHardcore ?? Boolean(packet.gameMode & 0b100) - if (bot.registry.isOlderThan('1.10')) { + if (bot.registry.isOlderThan('1.10')) { // gamemode is used pre 1.10 and post 1.20 but in between it's gameMode bot.game.gameMode = parseGameMode(packet.gamemode) } else { bot.game.gameMode = packet.gamemode || parseGameMode(packet.gameMode & 0b1111) // lower four bits diff --git a/test/externalTests/gamemode.js b/test/externalTests/gamemode.js index f6a240028..e708a3daf 100644 --- a/test/externalTests/gamemode.js +++ b/test/externalTests/gamemode.js @@ -23,6 +23,7 @@ module.exports = () => { bot.chat('/kill') await onceWithCleanup(bot, 'respawn', { timeout: 2000 }) + // Respawn packets send the gamemode. If the bot is in creative mode, it should respawn in creative mode. Tested <1.20 assert.strictEqual(bot.game.gameMode, 'creative', 'Wrong gamemode after respawn') })