GitHub avatar

Fox's Blog

← Back to projects

ANNA — Minecraft Bot

ANNA is an autonomous Minecraft bot built with Node.js and Mineflayer. She connects to a Minecraft server, understands natural language commands (in French), and performs tasks like mining, crafting, cooking, killing, and following players — all while being a friendly companion with a voice.

How It Works

1. Connection & Chat Listener

bot.js creates a Mineflayer bot that connects to a local Minecraft server. It listens to in-game chat messages and processes each one through a command pipeline.

2. Natural Language Parsing

When a player sends a chat message, utils/id_parser.js parses it:

  • Splits the message on " et " (French for "and") to handle multiple orders.
  • Recognizes action verbs: mine, craft, obtien (obtain), farm, tue (kill), donne (give), suis moi (follow me).
  • Translates French item names to Minecraft item IDs using a French→English dictionary (utils/fr_fr.json / fr_fr.json).

alt text

3. Task Tree Calculation

For crafting/mining/farming tasks, the mc-tasks-tree module recursively breaks down a requested item into all necessary sub-steps. Here is an example for a flint and steel (briquet):

Voici ce que tu dois farmer avant d'obtenir Briquet:
- Tout d'abord, mines 3 Bûche de chêne.
- Ensuite, craftes 12 Planches de chêne.
- Ensuite, craftes 8 Bâton.
- Puis craftes 1 Établi.
- Ensuite, craftes 1 Pioche en bois dans l'établi.
- Après ca, mines 4 Roche pour obtenir Pierres.
- Ensuite, craftes 1 Pelle en pierre dans l'établi.
- Une fois cela fait, mines 1 Gravier jusqu'à trouver Silex.
- Ensuite, craftes 1 Pioche en pierre dans l'établi.
- Puis mines 1 Minerai de fer.
- Ensuite, mines 1 Minerai de charbon pour obtenir Charbon.
- Maintenant, cuis 1 Minerai de fer afin d'obtenir Lingot de fer.
- Enfin, craftes 1 Briquet.

This uses recipe data from Minecraft 1.16.1 loot tables and recipes:

Individual task type examples:

alt text alt text

4. Action Executors

Each task type maps to an action module in actions/:

  • mining — Navigate to and mine blocks using pathfinder + collectblock.
  • crafting — Craft items (with or without a crafting table).
  • cooking — Smelt items in a furnace.
  • killing / killingByName — Attack mobs or named entities.
  • drop — Drop items from inventory.
  • follow — Follow a player.
  • clutch / clutchSave — Emergency actions.
  • count — Count items in inventory.
  • sayIfIHave — Respond whether the bot has an item.

alt text alt text alt text alt text alt text

5. AI Conversation

If a message isn't a command, it's sent to AI/index.js, which uses the Hercai API (with an AIML base: faq-fr.basic.json). ANNA is prompted to act as a "Minecraft girlfriend" — sentient, emotional, and playful.

Example interaction: alt text alt text

6. Survival Automation

The bot manages its own survival needs:

  • Auto-eats when hungry (food items defined in constants.js).
  • Equips armor via mineflayer-armor-manager.
  • Fights back or hunts for food using mineflayer-pvp.
  • Claims blocks to avoid re-mining the same spot.

7. Task Prioritization & Deduction

ANNA can deduce everything needed to accomplish a task. Here is the diamond helmet breakdown: alt text alt text alt text alt text

Plus inventory awareness: alt text

8. Text-to-Speech

speak.js provides TTS via msedge-tts (French voice) so the bot can "speak" aloud.

Tech Stack

Getting Started

npm install
node bot.js

The bot connects to localhost:50567 by default. Edit the connection options in bot.js to change the server.

Project Structure

actions/          - Task executors (mining, crafting, killing, etc.)
AI/               - Hercai-powered conversational AI
mc-tasks-tree/    - Task dependency tree calculator
utils/            - French-to-English ID parser, data files
constants.js      - Food items, tool/material priorities
alternativeCraft.js - Fallback crafting system using /give commands
bot.js            - Main bot entry point
index.js          - Offline simulation/testing script
speak.js          - Text-to-speech module
README_DATA/      - Images, loot tables, recipes, AIML data