Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions test/internalTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,20 +683,25 @@ for (const supportedVersion of mineflayer.testedVersions) {
const mapped = JSON.stringify(registry.protocol.play.toClient.types.packet_game_state_change).includes('rain_level_change')
const reason = mapped ? 'rain_level_change' : 7
server.on('playerJoin', (client) => {
assert.strictEqual(bot.isRaining, false)
bot.once('rain', () => {
assert.strictEqual(bot.isRaining, true)
client.write('login', bot.test.generateLoginPacket())
// Plugins inject after a deferred inject_allowed, so bot state is
// only readable once the bot has seen login.
bot.once('login', () => {
assert.strictEqual(bot.isRaining, false)
bot.once('rain', () => {
assert.strictEqual(bot.isRaining, false)
assert.strictEqual(bot.rainState, 0)
done()
assert.strictEqual(bot.isRaining, true)
bot.once('rain', () => {
assert.strictEqual(bot.isRaining, false)
assert.strictEqual(bot.rainState, 0)
done()
})
client.write('game_state_change', { reason, gameMode: 0 })
})
client.write('game_state_change', { reason, gameMode: 0 })
client.write('game_state_change', { reason, gameMode: 0.01 })
// A second wet level must not emit again: if it did, the inner
// once would run with isRaining still true and fail the assert.
client.write('game_state_change', { reason, gameMode: 0.5 })
})
client.write('game_state_change', { reason, gameMode: 0.01 })
// A second wet level must not emit again: if it did, the inner
// once would run with isRaining still true and fail the assert.
client.write('game_state_change', { reason, gameMode: 0.5 })
})
})
})
Expand Down
Loading