Skip to content

omarzanji/citizens-aware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Citizens-Aware

Intelligent Agentic NPCs for Minecraft with LLM Integration

Architecture License: MIT

🌟 Overview

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!


πŸ—οΈ Architecture

Component Architecture

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 β†’


✨ Features

πŸ€– Personal NPC System

Personal NPC System

  • 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

🚢 Advanced Movement System

Movement System

Three distinct movement types for different use cases:

  • go_to_user: "Come here" - One-time movement to player location
  • move_to_entity: Move to specific targets, trees, or coordinates
  • npc follow: Continuous following via Citizens commands

🌳 Intelligent Tree Management

Tree Cutting System

  • 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

πŸ› οΈ Comprehensive Tool System

Tool System

NPCs can perform various actions through LLM-driven tools:

  • give_item / remove_item: Inventory management
  • run_command: Execute server commands as console
  • move_to_entity / go_to_user: Advanced movement
  • cut_tree: Realistic tree cutting with effects

πŸ“‘ Real-time Communication

Communication Flow

  • 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

πŸ“Š Intelligent Data Flow

Data Flow

  • 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

πŸš€ Quick Start

Prerequisites

  • Minecraft Spigot/Paper server (1.19.4+)
  • Java 8+ (JDK 17 recommended)
  • Maven
  • Python 3.8+
  • Citizens plugin
  • OpenRouter API key

Installation

1. Citizens Plugin

# Download Citizens plugin and place in plugins directory
# Restart your server

2. Build AgenticNPCPlugin

cd AgenticNPCPlugin
mvn clean package
cp target/agenticnpc-1.0-SNAPSHOT.jar /path/to/your/server/plugins/
# Restart server

3. FastAPI 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

Usage

# In Minecraft
/agenticnpc create Helper

# In chat
"Helper, can you cut down that tree?"
"Helper, come here please"
"Helper, give me some diamonds"

πŸ“š Documentation

πŸ“– Core Documentation

πŸ”¬ Technical Documentation

πŸ“Š Visual Architecture

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

πŸ› οΈ Project Structure

β”œβ”€β”€ 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

πŸ”§ Configuration

Plugin Configuration

  • 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

FastAPI Configuration

# .env file
OPENROUTER_API_KEY=your_api_key_here

Server Configuration

  • Host: 0.0.0.0 (configurable)
  • Port: 8000 (configurable)
  • WebSocket Endpoint: /ws/minecraft

🎯 Commands

Administrative Commands

/agenticnpc create <name>    # Create personal NPC
/agenticnpc status           # Show system status
/agenticnpc cleartrees       # Reset cut trees registry

Citizens Integration

/npc select <name>           # Select NPC for editing
/npc follow <player>         # Make NPC follow player
/npc moveto <x> <y> <z>      # Teleport NPC

πŸ” Troubleshooting

Common Issues

  • 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 β†’


🀝 Contributing

We welcome contributions! Please see our documentation for:

  • Code architecture and patterns
  • Testing procedures
  • Development setup

πŸ“„ License

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

🌟 Acknowledgments

Built with:


Ready to bring intelligent NPCs to your Minecraft world? Get started with our setup guide!

About

Intelligent Agentic NPCs for Minecraft with LLM Integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published