Pumpkin is built using a modular architecture with multiple crates that work together to provide a complete Minecraft server implementation. This document outlines the system architecture and how the different modules interact.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Pumpkin-MC/Pumpkin/llms.txt
Use this file to discover all available pages before exploring further.
Workspace Structure
Pumpkin uses a Cargo workspace to organize code into focused, reusable modules:Core Modules
pumpkin (Main Server)
The main server crate that orchestrates all other modules. It contains:- Server Management: Core server initialization and lifecycle management
- Network Handling: Player connection and protocol handling
- Game Logic: Block interactions, entity management, commands
- Plugin System: Dynamic plugin loading via
libloading
block/- Block behavior implementationsentity/- Entity logic and AIcommand/- Command implementationsnet/- Network layerworld/- World management layerserver/- Server core
pumpkin-protocol
Handles all Minecraft protocol operations:- Packet Serialization/Deserialization: Reading and writing Minecraft packets
- Encryption: AES/CFB8 encryption for secure connections
- Compression: Zlib compression for packet optimization
- Multi-version Support: Both Java and Bedrock editions
pumpkin-world
World and chunk management system:- Chunk Loading: Asynchronous chunk loading from disk
- Chunk Generation: Vanilla-compatible world generation
- Chunk Caching: In-memory chunk storage with
DashMap - Lighting Engine: Dynamic lighting calculations
- Multi-format Support: Anvil and Linear chunk formats
- Efficient chunk I/O with file caching
- Parallel chunk generation
- Chunk saving and autosave functionality
- Entity chunk data management
pumpkin-data
Generated data and registries:- Block States: All block state definitions
- Item Registry: Item IDs and properties
- Biome Data: Biome definitions and properties
- Entity Types: Entity type registry
- Dimension Data: Dimension configurations
- Game Rules: Minecraft game rule definitions
pumpkin-config
Configuration management:- TOML Parsing: Server configuration in TOML format
- Validation: Configuration validation on load
- Runtime Helpers: Optional test helpers for config manipulation
pumpkin-inventory
Inventory and container management:- Player Inventories: Player inventory handling
- Container GUIs: Chest, furnace, and other container interfaces
- Item Stack Operations: Item manipulation and validation
pumpkin-util
Shared utilities:- Math Types: Vector2, Vector3, BlockPos, etc.
- Text Components: Rich text formatting
- Crypto Utilities: Encryption and hashing helpers
- NBT Helpers: Named Binary Tag utilities
pumpkin-macros
Procedural macros for code generation:- Derive Macros: Custom derives for common patterns
- Block/Tag Helpers: Compile-time block and tag validation
pumpkin-api-macros
Macros for the plugin API system (excluded from main workspace for independent versioning).Concurrency Architecture
Tokio + Rayon Pattern
Pumpkin uses a hybrid concurrency model:Tokio Runtime (Async I/O)
Used for:- Network I/O (player connections)
- File I/O (chunk loading/saving)
- Timers and scheduled tasks
- Async coordination
Rayon (CPU-Intensive Tasks)
Used for:- Parallel chunk generation
- World generation computations
- Data processing
Communication Between Runtimes
Usetokio::sync::mpsc channels to transfer data between Tokio and Rayon:
Synchronization Primitives
- DashMap: Concurrent hashmap for chunk storage
- Arc: Shared ownership for immutable data
- AtomicBool/AtomicU64: Lock-free atomic operations
- Mutex: For mutable state that needs exclusive access
- TaskTracker: Track and manage async tasks
- CancellationToken: Graceful shutdown coordination
Data Flow
Player Connection Flow
- Connection →
pumpkin/netreceives TCP connection - Handshake →
pumpkin-protocolhandles protocol negotiation - Authentication → Validates player with Mojang API
- Join Game →
pumpkin/serverinitializes player state - Chunk Loading →
pumpkin-worldloads/generates chunks - Game Loop →
pumpkinprocesses player actions
Chunk Loading Flow
- Request → Player movement triggers chunk load
- Cache Check → Check
loaded_chunksDashMap - Disk Load →
pumpkin-worldasync loads from disk - Generation → If not exists, generate with world generator
- Lighting → Calculate lighting for chunk
- Send →
pumpkin-protocolserializes and sends to client
Packet Processing Flow
- Receive → TCP stream receives encrypted/compressed data
- Decrypt →
pumpkin-protocoldecrypts if encryption enabled - Decompress → Decompress if compression enabled
- Deserialize → Parse into packet struct
- Handle →
pumpkinprocesses packet logic - Response → Send response packets back to client
Performance Considerations
Compilation Profiles
Clippy Configuration
Pumpkin enforces strict linting:Module Dependencies
Next Steps
- Building from Source - Set up your development environment
- Contributing Guidelines - Learn how to contribute to Pumpkin
