A utility package for Mineflayer bots, including automatic eating and totem handling.
npm install mineflayer-utility-botdeath.txt file
bash
npm install mineflayer-utility-bot
`
Usage
$3
`javascript
const mineflayer = require('mineflayer');
const { Food, AutoTotem, BotDeath } = require('mineflayer-utility-bot');
const bot = mineflayer.createBot({
host: 'localhost',
username: 'bot'
});
// Initialize all utilities
const food = new Food(bot);
const autoTotem = new AutoTotem(bot);
autoTotem.start();
const deathTracker = new BotDeath(bot);
`
$3
You can use only the modules you need:
`javascript
// Only auto-eating
const { Food } = require('mineflayer-utility-bot');
const food = new Food(bot);
// Only totem management
const { AutoTotem } = require('mineflayer-utility-bot');
const autoTotem = new AutoTotem(bot);
autoTotem.start();
// Only death tracking
const { BotDeath } = require('mineflayer-utility-bot');
const deathTracker = new BotDeath(bot);
`
API Reference
$3
Constructor: new Food(bot)
Properties:
- foodList - Array of food items the bot will eat
Default Food List:
- minecraft:cooked_beef
- minecraft:cooked_chicken
- minecraft:bread
Methods:
- normalizeFoodName(foodName) - Adds minecraft: prefix if missing
- startAutoEat() - Begins automatic eating loop
- tryToEat() - Attempts to eat food from inventory
- findFoodInInventory() - Searches for consumable food
$3
Constructor: new AutoTotem(bot)
Properties:
- lowHealthThreshold - Health level that triggers totem equipping (default: 10)
- offhandSlot - Off-hand inventory slot (default: 45)
Methods:
- start() - Begins health monitoring and auto-equipping
- handleAutoTotem() - Checks health and triggers totem equipping
- equipTotem() - Equips totem to off-hand
- findTotemInInventory() - Searches for totem in inventory
$3
Constructor: new BotDeath(bot)
Methods:
- getKillerWeapon(killer) - Gets the weapon used by a killer
- setupDeathHandler() - Sets up death event listener
Death Log Format:
`
[MM/DD/YYYY, HH:MM:SS AM/PM] The bot has died at [timestamp] at location: X: 100, Y: 64, Z: -200. Killed by player: Steve using diamond_sword.
`
Configuration Examples
$3
`javascript
const food = new Food(bot);
food.foodList = [
'minecraft:golden_apple',
'minecraft:cooked_porkchop',
'minecraft:steak'
];
`
$3
`javascript
const autoTotem = new AutoTotem(bot);
autoTotem.lowHealthThreshold = 14; // Equip at 7 hearts
autoTotem.start();
`
Output Files
- death.txt` - Contains timestamped death logs with location and killer information