Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS
GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/lib/plugins/rain.js
1467 views
1
module.exports = inject
2
3
function inject (bot) {
4
bot.isRaining = false
5
bot.thunderState = 0
6
bot.rainState = 0
7
bot._client.on('game_state_change', (packet) => {
8
if (packet.reason === 1) {
9
bot.isRaining = true
10
bot.emit('rain')
11
} else if (packet.reason === 2) {
12
bot.isRaining = false
13
bot.emit('rain')
14
} else if (packet.reason === 7) {
15
bot.rainState = packet.gameMode
16
bot.emit('weatherUpdate')
17
} else if (packet.reason === 8) {
18
bot.thunderState = packet.gameMode
19
bot.emit('weatherUpdate')
20
}
21
})
22
}
23
24