Skip to content

Commit

Permalink
Add gamemode test related comments
Browse files Browse the repository at this point in the history
  • Loading branch information
IceTank committed Nov 21, 2024
1 parent e346813 commit cd66986
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/plugins/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/externalTests/gamemode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})

Expand Down

0 comments on commit cd66986

Please sign in to comment.