LookAtMySuitBot/js/node_modules/mineflayer/lib/plugins/breath.js

18 lines
547 B
JavaScript
Raw Normal View History

2023-12-24 20:08:39 -05:00
module.exports = inject
function inject (bot) {
bot._client.on('entity_metadata', (packet) => {
if (!bot?.entity?.id === packet?.entityId) return
if (packet?.metadata[1]?.key === 1) {
if (!packet?.metadata[1]?.value) return
bot.oxygenLevel = Math.round(packet.metadata[1].value / 15)
bot.emit('breath')
}
if (packet?.metadata[0]?.key === 1) {
if (!packet?.metadata[0]?.value) return
bot.oxygenLevel = Math.round(packet.metadata[0].value / 15)
bot.emit('breath')
}
})
}