Intelligent Agentic NPCs for Minecraft with LLM Integration
Citizens-Aware is a Minecraft plugin that brings intelligent, LLM-powered NPCs to your server. Each player can create their own personal AI companion that understands natural language, performs complex actions, and interacts with the Minecraft world autonomously.
π― Key Highlights:
- Personal AI NPCs: Each player gets their own intelligent companion
- Complete Environmental Awareness: NPCs can see and interact with ALL nearby entities, structures, blocks, and players
- Full Command Access: NPCs inherit your permissions and can execute ANY command you have access to
- Natural Language Processing: Chat naturally with NPCs using their names - no complex syntax required
- Autonomous Intelligence: NPCs make decisions, plan actions, and execute complex multi-step tasks independently
- Real-time World Understanding: Powered by state-of-the-art LLMs via OpenRouter with live world context
- Like Playing with a Friend: Your NPC companion can do everything you can do - build, explore, fight, trade, and more!
- Seamless Integration: Built on Citizens plugin with WebSocket communication for instant responsiveness
π§ What Makes This Special: Your AI NPC isn't just a chatbot - it's a fully aware digital companion that can:
- See every entity around you (players, mobs, animals, items)
- Access your complete command arsenal (build, teleport, give items, change weather, etc.)
- Understand spatial relationships and navigate intelligently
- Remember context and maintain coherent conversations
- Execute complex plans like "build me a house" or "collect resources while I'm away"
- Inherit your exact player permissions and capabilities
It's like having an intelligent friend who never gets tired, never gets bored, and can help with anything you need in Minecraft!
Our system consists of three main components:
- π§ AgenticNPCPlugin (Java/Spigot): Handles NPC management and world interaction
- π§ FastAPI Server (Python): Processes natural language via LLM integration
- π WebSocket Communication: Real-time bidirectional messaging
π View Complete Architecture Documentation β
- One NPC per Player: Create your personal AI companion with
/agenticnpc create <name>
- Name-based Interaction: Simply mention your NPC's name in chat to interact
- Privacy-focused: Only you receive responses from your NPC
- Ownership Tracking: Thread-safe player-NPC relationships
Three distinct movement types for different use cases:
go_to_user
: "Come here" - One-time movement to player locationmove_to_entity
: Move to specific targets, trees, or coordinatesnpc follow
: Continuous following via Citizens commands
- Smart Tree Detection: Scans 15-block radius for tree clusters
- Realistic Cutting: Progressive block-by-block tree removal
- Visual Effects: Sound effects, particles, and proper NPC facing
- Inventory Management: Wood goes directly to player inventory
- Cut Tree Tracking: Prevents re-scanning of already cut trees
NPCs can perform various actions through LLM-driven tools:
give_item
/remove_item
: Inventory managementrun_command
: Execute server commands as consolemove_to_entity
/go_to_user
: Advanced movementcut_tree
: Realistic tree cutting with effects
- WebSocket Protocol: Low-latency bidirectional communication
- Rich Context: NPCs receive inventory, location, nearby structures, and trees
- Agentic Loops: LLMs can make multiple tool calls in sequence
- JSON Message Format: Structured data exchange
- Context-aware: Real-time inventory, location, and world state
- Performance Optimized: Structure caching and efficient scanning
- Thread-safe: Concurrent data structures for multiplayer environments
- Smart Tracking: Prevents redundant operations
- Minecraft Spigot/Paper server (1.19.4+)
- Java 8+ (JDK 17 recommended)
- Maven
- Python 3.8+
- Citizens plugin
- OpenRouter API key
# Download Citizens plugin and place in plugins directory
# Restart your server
cd AgenticNPCPlugin
mvn clean package
cp target/agenticnpc-1.0-SNAPSHOT.jar /path/to/your/server/plugins/
# Restart server
cd citizens-aware-fastapi
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp env.example.txt .env
# Edit .env and add your OpenRouter API key
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# In Minecraft
/agenticnpc create Helper
# In chat
"Helper, can you cut down that tree?"
"Helper, come here please"
"Helper, give me some diamonds"
- ποΈ Architecture Guide - Complete system architecture with visual diagrams
- π§ API Reference - Comprehensive API documentation with examples
- βοΈ Setup Guide - Detailed installation and configuration
- β¨ Features Guide - Feature overview and usage examples
- π§ͺ Spigot Testing - Communication testing guide
- β‘ Forge Testing - Alternative platform testing
All documentation includes professional mermaid diagrams rendered as high-quality images:
- System Architecture Overview
- Component Relationships
- Personal NPC Workflow
- Movement System Logic
- Tree Cutting Process
- Communication Flow
- Tool System Integration
- Data Flow Optimization
βββ AgenticNPCPlugin/ # Java plugin (Maven)
β βββ src/main/java/ # Plugin source code
β βββ pom.xml # Maven dependencies
β βββ target/ # Compiled JAR
βββ citizens-aware-fastapi/ # Python FastAPI server
β βββ main.py # WebSocket endpoints
β βββ modules/ # LLM integration modules
β βββ requirements.txt # Python dependencies
βββ docs/ # Comprehensive documentation
β βββ ARCHITECTURE.md # System architecture
β βββ API_REFERENCE.md # Complete API docs
β βββ *.md # Additional guides
βββ assets/ # Visual diagrams
β βββ *.png # Rendered mermaid diagrams
β βββ *.mmd # Source mermaid files
βββ README.md # This file
- WebSocket URI:
ws://localhost:8000/ws/minecraft
- Scan Radii: Trees (15 blocks), Blocks (8 blocks), Structures (100 blocks)
- Tree Cutting: 3x3 area, up to 15 blocks high
# .env file
OPENROUTER_API_KEY=your_api_key_here
- Host:
0.0.0.0
(configurable) - Port:
8000
(configurable) - WebSocket Endpoint:
/ws/minecraft
/agenticnpc create <name> # Create personal NPC
/agenticnpc status # Show system status
/agenticnpc cleartrees # Reset cut trees registry
/npc select <name> # Select NPC for editing
/npc follow <player> # Make NPC follow player
/npc moveto <x> <y> <z> # Teleport NPC
- NPCs not responding: Check WebSocket connection and NPC ownership
- Tree cutting failures: Use
/agenticnpc cleartrees
to reset registry - Connection issues: Ensure FastAPI server is running on correct port
π Complete Troubleshooting Guide β
We welcome contributions! Please see our documentation for:
- Code architecture and patterns
- Testing procedures
- Development setup
This project is licensed under the MIT License - see the LICENSE file for details.
Key permissions:
- β Commercial use
- β Modification
- β Distribution
- β Private use
Requirements:
- π Include copyright notice
- π Include license text
Built with:
- Citizens - NPC framework
- Spigot - Minecraft server platform
- FastAPI - Modern Python web framework
- OpenRouter - LLM API gateway
Ready to bring intelligent NPCs to your Minecraft world? Get started with our setup guide!