Skip to main content

Overview

The Minecraft integration is an intelligent bot built on a four-layered cognitive architecture inspired by cognitive science. AIRI can understand natural language commands, explore the world autonomously, gather resources, craft items, and interact with players.

Features

  • Cognitive Architecture: Perception → Reflex → Conscious → Action layers
  • Natural Language Understanding: Chat with the bot using plain English
  • Autonomous Gameplay: Gather resources, craft items, build structures
  • World Awareness: Navigate terrain, avoid obstacles, track entities
  • Combat System: Fight hostile mobs and defend itself
  • Inventory Management: Smart item collection and crafting
  • Debug Dashboard: Web-based real-time monitoring and MCP integration
  • Mineflayer Viewer: Watch the bot’s POV in your browser

Prerequisites

  • Node.js 18 or higher
  • Minecraft Java Edition server (1.20 recommended)
  • OpenAI API key (or compatible LLM provider)
  • AIRI server runtime (optional, for integration)

Setup

1. Prepare Minecraft Server

You need a Minecraft server where the bot can connect. Options:
  • Local server: Download from minecraft.net
  • Aternos: Free hosting at aternos.org
  • Existing server: Use any Java Edition server
The bot supports Minecraft Java Edition versions 1.12 - 1.20. Version 1.20 is recommended.

2. Configure Environment

Navigate to the Minecraft service:
Edit .env.local:

3. Install Dependencies

From project root:

4. Start the Bot

You should see:

Usage

In-Game Commands

Talk to the bot in Minecraft chat:

Web Viewer

Open http://localhost:3007 to see the bot’s first-person view in real-time.

Debug Dashboard

Open http://localhost:3008 for:
  • Real-time bot status
  • Cognitive layer monitoring
  • Tool execution interface
  • MCP server integration

Cognitive Architecture

The bot operates on four distinct layers:

Layer A: Perception

Location: src/cognitive/perception/ Collects and processes raw Mineflayer events into normalized signals:
  • Chat messages
  • Health/hunger changes
  • Entity spawns
  • Block interactions
  • Combat events

Layer B: Reflex

Location: src/cognitive/reflex/ Handles immediate, instinctive reactions:
  • Auto-eat when hungry
  • Dodge incoming attacks
  • React to sudden damage
  • Idle behaviors (looking around)

Layer C: Conscious

Location: src/cognitive/conscious/ LLM-powered reasoning and planning:
  • Interprets user commands
  • Plans multi-step tasks
  • Manages goal hierarchies
  • Handles conversation

Layer D: Action

Location: src/cognitive/action/ Executes concrete tasks in the world:
  • Movement and pathfinding
  • Block breaking/placing
  • Item crafting
  • Entity interaction
  • Inventory management

Code Examples

Bot Initialization

From services/minecraft/src/main.ts:22:

Configuration Loading

From services/minecraft/src/composables/config.ts:62:

Skills System

The bot has modular skills in src/skills/: Movement (src/skills/movement.ts):
Gathering (src/skills/blocks.ts):
Crafting (src/skills/crafting.ts):
Combat (src/skills/combat.ts):

Plugin System

Extend bot capabilities with plugins:

Advanced Features

Query DSL

Query the world from conscious layer:

MCP Integration

The debug server exposes Model Context Protocol tools:

Troubleshooting

Bot can’t connect to server

  1. Verify server is running and accessible
  2. Check BOT_HOSTNAME and BOT_PORT
  3. For online servers, use BOT_AUTH='microsoft'
  4. Ensure Minecraft version matches: BOT_VERSION='1.20'

Bot is stuck or unresponsive

  1. Check debug dashboard for task status
  2. Send stop command in chat
  3. Restart the bot service
  4. Check logs for errors

LLM errors

  1. Verify OPENAI_API_KEY is valid
  2. Check API rate limits
  3. Ensure OPENAI_MODEL is accessible
  4. Try a different model endpoint

Pathfinding fails

  1. Bot may be in difficult terrain
  2. Increase search radius
  3. Clear obstacles near bot
  4. Use /tp to relocate bot

Performance Tips

  • Use o1-mini for complex reasoning tasks
  • Set shorter tick intervals for faster reactions
  • Reduce perception event frequency for lower CPU usage
  • Enable viewer only when debugging

Next Steps

Factorio Integration

Automate Factorio gameplay

API Reference

Full Minecraft API documentation