PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.89k stars 897 forks source link

In Spigot server isRaining & thunderstorm no works fine #2713

Open sefirosweb opened 2 years ago

sefirosweb commented 2 years ago

Versions

Detailed description of a problem

I detected the bot cant sleep well when thunderstorm is active and is spigot server

I saw the variables used in bed, in the funderstorm & isRaining never return true https://github.com/PrismarineJS/mineflayer/blob/9dfa882df4e2e7151c5a7e9c48ba6ec10a4b31f3/lib/plugins/bed.js#L80

This issue only occurs in spigot server as far I know From vanilla servers works perfect,

What did you try yet?

Debug the variables of raining and thunder storm on differents version of server:

bot.on('time', () => {
  console.log(bot.isRaining)
  console.log(bot.thunderState)
})

Replace code

I saw in bot servers the variable bot.thunderState is positive, maybe can replace to remove "bot.isRaining"

const thunderstorm = bot.thunderState > 0

https://github.com/PrismarineJS/mineflayer/blob/9dfa882df4e2e7151c5a7e9c48ba6ec10a4b31f3/lib/plugins/bed.js#L80

Additional context

I think the problems come from packets sent by server and this library is getting, but im not sure how the mineflayer manage the difference packets between different version of server

https://github.com/PrismarineJS/mineflayer/blob/a0befeb042fe3851ac35887da116c2910f505791/lib/plugins/rain.js#L3-L22

Jovan-04 commented 1 year ago

I'm having the same problem, but on Paper. bot.rainState appears to work as intended, so you can replace bot.isRaining on line 80 with bot.rainState > 0 https://github.com/PrismarineJS/mineflayer/blob/9dfa882df4e2e7151c5a7e9c48ba6ec10a4b31f3/lib/plugins/bed.js#L80

the issue is with bot.isRaining, not with the thunderstorm