Replies: 1 comment 1 reply
-
If you are trying to get the bot's current health (bot.health) and it's undefined, it's likely because you're not waiting for the correct event, as most properties are not available immediately after calling createBot, rather they are set after an appropriate event. For example the If you mean you want the health of another entity, then that may not be possible. If the server is sending that information, it probably will be through attributes and so the correct event to listen for would be bot.on('entityAttributes', function (entity) {
if (entity.username) // ensure entity is player
console.log('Entity attributes', entity.username, entity.attributes)
}) As mineflayer works over network packets, you can see all the client <=> server communications encoded in JSON by adding the following debug line to the top of your code: process.env.DEBUG = 'minecraft-protocol' That will show you all the information is and isn't sent by the server if you need to know it |
Beta Was this translation helpful? Give feedback.
-
Hello,
I would like to be able to see the hunger of a player and have events for when players place blocks (a lot of the things we can already do for the bots). I'm not sure if I missed something in the API for these things, or if there's a way I can create a bot that exists as a player in the game so I can get this kind of information.
Prismarine entity looks like you can get entity.hunger but I get an empty object. I can get player health through metadata, but I'd like to be able to get more info on the player.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions