World System
The world system manages blocks, entities, and game logic through theSimpleWorld trait.
Core Features
pumpkin-world/src/world.rs:66-93
Block Flags
Block state changes are controlled with fine-grained flags:pumpkin-world/src/world.rs:21-49
These flags control:
- Observer Detection:
NOTIFY_NEIGHBORStriggers observers and redstone - Client Updates:
NOTIFY_LISTENERSsends packets to nearby players - Item Drops:
SKIP_DROPSprevents item drops when replacing blocks - Block Entities: Control callbacks for containers and tile entities
Level System
TheLevel manages chunks, world generation, and persistence.
Level Structure
pumpkin-world/src/level.rs:61-84
Chunk Loading
Pumpkin uses an efficient chunk system with:- Lazy Loading: Chunks load on-demand when needed
- Chunk Watchers: Reference counting for loaded chunks
- Generation Queue: Async chunk generation
- Priority System: Load order based on player proximity
pumpkin-world/src/level.rs:49-74
Chunk States
Chunks progress through states:World Generation
Pumpkin implements vanilla-compatible world generation.Generator Types
pumpkin-world/src/generation/mod.rs:32-35
Noise-Based Generation
World generation uses multi-layered noise:- Perlin Noise: Base terrain generation
- Density Functions: 3D terrain shaping
- Biome Sampling: Multi-noise biome placement
- Aquifer Sampling: Underground water systems
- Ore Veins: Ore distribution
pumpkin-world/src/generation/noise/
Generation Pipeline
- Proto Chunk Creation: Initial chunk structure
- Noise Sampling: Generate terrain heightmap
- Surface Rules: Apply biome-specific surface blocks
- Feature Placement: Trees, structures, decorations
- Lighting Calculation: Sky and block light
- Finalization: Convert to playable chunk
Structures
Pumpkin generates vanilla structures:- Strongholds: Portal rooms, libraries, corridors
- Nether Fortresses: Bridge networks
- Igloos: Surface and basement variants
- Swamp Huts: Witch huts
- Buried Treasure: Ocean treasure chests
pumpkin-world/src/generation/structure/structures/
Coordinate Systems
Pumpkin uses multiple coordinate systems:pumpkin-world/src/generation/mod.rs:71-114
Lighting Engine
Dynamic lighting with real-time updates.Light Types
- Sky Light: Sunlight propagation from sky to ground
- Block Light: Light from torches, lava, glowstone
Light Engine Features
pumpkin-world/src/lighting/mod.rs:4-7
The lighting engine:
- Updates light in real-time when blocks change
- Propagates light through transparent blocks
- Handles light occlusion correctly
- Sends only changed sections to clients
Block Access
Efficient block access through theBlockAccessor trait:
pumpkin-world/src/world.rs:167-182
World Saving
Pumpkin supports multiple save formats:Anvil Format
Standard Minecraft region file format:- Region files (32x32 chunks)
- NBT-compressed chunk data
- Compatible with vanilla Minecraft
pumpkin-world/src/chunk/format/anvil.rs
Linear Format
Optimized custom format:- Faster read/write performance
- Better compression
- Backwards compatible conversion
pumpkin-world/src/chunk/format/linear.rs
Autosave
pumpkin-world/src/level.rs:93-96
Autosave periodically saves modified chunks to disk.
Performance Features
- Async Chunk I/O: Non-blocking chunk loading/saving
- Chunk Caching: DashMap for concurrent access
- Task Tracking: Tokio TaskTracker for cleanup
- Cancellation Tokens: Graceful shutdown
- Generation Caching: Reuse generated chunk data
pumpkin-world/src/level.rs:87-103