npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mineflayer-auto-eat

v5.0.3

Published

An auto eat plugin for mineflayer

Readme

A customizable and flexible auto-eat utility plugin for Mineflayer bots

Table of Contents

Install

npm install mineflayer-auto-eat

Warning: This package is ESM only and does not support CommonJS.

Example

import { createBot } from 'mineflayer'
import { loader as autoEat } from 'mineflayer-auto-eat'

const bot = createBot({
    host: process.argv[2] || 'localhost',
    port: process.argv[3] || 25565,
    username: process.argv[4] || 'bot',
    auth: process.argv[5] || 'microsoft'
})

bot.once('spawn', async () => {
    bot.loadPlugin(autoEat)
    bot.autoEat.enableAuto()

    bot.autoEat.on('eatStart', (opts) => {
        console.log(`Started eating ${opts.food.name} in ${opts.offhand ? 'offhand' : 'hand'}`)
    })

    bot.autoEat.on('eatFinish', (opts) => {
        console.log(`Finished eating ${opts.food.name}`)
    })

    bot.autoEat.on('eatFail', (error) => {
        console.error('Eating failed:', error)
    })
})

Run this with node <file>.js [host] [port] [username] [auth].

API

Properties

bot.autoEat.enabled

Boolean value indicating whether the auto-eat utility is enabled or disabled.

bot.autoEat.isEating

Boolean value indicating whether the bot is currently eating or not. This value should not be manually set.

bot.autoEat.opts

This object holds the configurable options for the auto-eat utility.

{
  priority: "foodPoints",
  minHunger: 15,
  minHealth: 14,
  returnToLastItem: true,
  offhand: false,
  eatingTimeout: 3000,
  bannedFood: ["rotten_flesh", "pufferfish", "chorus_fruit", "poisonous_potato", "spider_eye"],
  strictErrors: true
}

bot.autoEat.foods

Returns the foods registry from the bot, which contains all food-related information from the Minecraft data.

bot.autoEat.foodsArray

Returns an array of all available foods in Minecraft from the bot's registry.

bot.autoEat.foodsByName

Returns an object mapping food item names to their properties (e.g., saturation, foodPoints).

Methods

bot.autoEat.setOpts(opts: Partial<IEatUtilOpts>)

Allows you to modify the configuration options for the auto-eat utility dynamically.

bot.autoEat.setOpts({
    minHunger: 10,
    priority: 'saturation'
})

bot.autoEat.eat(opts: EatOptions)

Manually triggers the eating function. If options are not provided, it will automatically pick the best food based on the current options.

bot.autoEat
    .eat({
        food: 'apple', // optional
        offhand: true, // optional
        equipOldItem: false, // optional
        priority: 'saturation' // optional
    })
    .then(() => {
        console.log('Successfully ate the food!')
    })
    .catch((err) => {
        console.error('Failed to eat:', err)
    })

bot.autoEat.enableAuto()

Enables automatic eating based on the bot's hunger and health levels. The bot will automatically check if it needs to eat during each physicsTick.

bot.autoEat.enableAuto()

bot.autoEat.disableAuto()

Disables the automatic eating functionality.

bot.autoEat.disableAuto()

bot.autoEat.cancelEat()

Cancels the current eating action if the bot is in the process of eating.

bot.autoEat.cancelEat()

Settings

IEatUtilOpts

These options define how the EatUtil behaves:

  • priority (FoodPriority): Defines the priority for choosing food. Acceptable values are "foodPoints", "saturation", "effectiveQuality", and "saturationRatio". Default is "foodPoints".
  • minHunger (number): If the bot's hunger is less than or equal to this value, the bot will attempt to eat. Default is 15.
  • minHealth (number): If the bot's health is less than or equal to this value, the bot will prioritize eating food with higher saturation. Default is 14.
  • bannedFood (string[]): An array of food names that the bot is not allowed to eat. Default includes "rotten_flesh", "pufferfish", "chorus_fruit", "poisonous_potato", "spider_eye".
  • returnToLastItem (boolean): If true, the bot will re-equip the previous item after eating. Default is true.
  • offhand (boolean): If true, the bot will use the offhand to eat. Default is false.
  • eatingTimeout (number): The timeout (in milliseconds) for completing the eating action. Default is 3000.
  • strictErrors (boolean): If true, errors during the eating process will be thrown. Otherwise, they will be logged to the console. Default is true.

EatOpts

These options are provided to the eat method to override default behavior.:

  • food (FoodSelection): The food item to eat. If not provided, the bot will automatically choose the best food based on the current options.
  • offhand (boolean): If true, the bot will use the offhand to eat. Default is false.
  • equipOldItem (boolean): If true, the bot will re-equip the previous item after eating. Default is true.
  • priority (FoodPriority): Defines the priority for choosing food. Acceptable values are "foodPoints", "saturation", "effectiveQuality", and "saturationRatio". Default is "foodPoints".

Events

  • eatStart: Emitted when the bot starts eating an item.
bot.autoEat.on('eatStart', (opts) => {
    console.log(`Started eating ${opts.food.name}`)
})
  • eatFinish: Emitted when the bot finishes eating.
bot.autoEat.on('eatFinish', (opts) => {
    console.log(`Finished eating ${opts.food.name}`)
})
  • eatFail: Emitted when the bot fails to eat due to an error.
bot.autoEat.on('eatFail', (error) => {
    console.error('Eating failed:', error)
})

Authors

👤 Rocco A

https://github.com/GenerelSchwerz

👤 Linkle

https://github.com/linkle69

Show your support

Give a ⭐️ if this plugin helped you!