Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS
GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/lib/plugins/rain.js
9427 views
1
module.exports = inject
2
const states = ['no_respawn_block_available', 'start_raining', 'stop_raining', 'change_game_mode', 'win_game', 'demo_event', 'play_arrow_hit_sound', 'rain_level_change', 'thunder_level_change', 'puffer_fish_sting', 'guardian_elder_effect', 'immediate_respawn', 'limited_crafting', 'level_chunks_load_start']
3
4
function inject (bot) {
5
bot.isRaining = false
6
bot.thunderState = 0
7
bot.rainState = 0
8
bot._client.on('game_state_change', (packet) => {
9
const reason = states[packet.reason] ?? packet.reason
10
if (reason === 'start_raining') {
11
bot.isRaining = true
12
bot.emit('rain')
13
} else if (reason === 'stop_raining') {
14
bot.isRaining = false
15
bot.emit('rain')
16
} else if (reason === 'rain_level_change') {
17
bot.rainState = packet.gameMode
18
bot.emit('weatherUpdate')
19
} else if (reason === 'thunder_level_change') {
20
bot.thunderState = packet.gameMode
21
bot.emit('weatherUpdate')
22
}
23
})
24
}
25
26