link-discord / mineflayer-auto-eat

Auto eat plugin for mineflayer
https://www.npmjs.com/package/mineflayer-auto-eat
MIT License
33 stars 4 forks source link

How to enable autoeat when the health is low, rather than when the foodPoints are low? #67

Closed ArtificialT800 closed 4 months ago

ArtificialT800 commented 4 months ago

So I've been trying to create a bot that will eat when its low on health but it doesnt seem to work.

Here's what my code so far:

bot.once('spawn', () => {
  bot.autoEat.options = {
    priority: 'auto',
    startAt: 14,
    bannedFood: [],
    healthThreshold: 16,
    checkOnItemPickup: true,
    equipOldItem: true 
  }
})

bot.on('autoeat_started', () => {
  console.log('Auto Eat started!')
})

bot.on('autoeat_stopped', () => {
  console.log('Auto Eat stopped!')
})

bot.on('health', () => {
  console.log("Health: ", bot.health)
  console.log("FoodPoints: ", bot.food)
  if (bot.health !== 20) bot.autoEat.eat() //for some reason .enable() doesn't work AT ALL?

  else bot.autoEat.disable()

})