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

Library wasn't working for me so I fixed some things #11

Closed hatkidchan closed 3 years ago

hatkidchan commented 3 years ago

Also that may be not your fault and problem lies in https://github.com/PrismarineJS/mineflayer/issues/2030, but still there are some changes that you may find helpful

link-discord commented 3 years ago

Did you test this

hatkidchan commented 3 years ago

Did you test this

Yep, seems to work. Used that code for testing:

const mineflayer = require("mineflayer")
const autoeat = require("./index")
const bot = mineflayer.createBot({
    host: process.argv[2],
    port: process.argv[3],
    username: process.argv[4]
})
bot.loadPlugin(autoeat)
bot.once("spawn", () => {
    bot.autoEat.options.startAt = 20
    bot.autoEat.options.checkOnItemPickup = true
    bot.autoEat.options.ignoreInventoryCheck = true
})
bot.on("autoeat_started", (item) => {
    console.log(`Started eating ${item.displayName}`)
})
bot.on("autoeat_stopped", (err) => {
    console.log(`Stopped eating with error ${err}`)
})
bot.on("health", () => {
    console.log(`HP: ${bot.health} ST: ${bot.food}`);
    if (bot.food === 20) bot.autoEat.disable()
    else bot.autoEat.enable()
})
link-discord commented 3 years ago

LGTM!