Module overview
The World module is organized into several major systems:Entity system
All living entities, mobs, players, and items
World simulation
Chunks, blocks, lighting, and physics
Game mechanics
Crafting, combat, enchanting, brewing
Networking
Packet system for multiplayer
Core classes
Level class
TheLevel class (Level.h:source/Minecraft.World/Level.h) is the central world manager:
- Entity lifecycle management
- Chunk loading and unloading
- Block updates and lighting
- Collision detection
- Weather simulation
- Scheduled tick processing
The Level class uses critical sections (
CRITICAL_SECTION m_entitiesCS) to protect entity lists from race conditions during multi-threaded chunk generation and rendering.World dimensions
Minecraft has three dimensions, each with a separate Level instance:- Overworld (dimension 0): Normal world with full height
- Nether (dimension -1): Hell dimension with different generation
- The End (dimension 1): End dimension with void and end stone
Entity system
The entity system uses inheritance-based polymorphism.Entity hierarchy
Entity class
TheEntity base class (Entity.h:source/Minecraft.World/Entity.h) provides:
Core properties:
tick(): Update entity state each game tickmove(): Physics and collisionhurt(): Take damageinteract(): Player interactionsave()/load(): NBT serialization
Entity synchronization
Entity synchronization
Entities use The
SynchedEntityData to synchronize properties between client and server:SetEntityDataPacket synchronizes these values to clients.AI system
Mobs use a goal-based AI system: GoalSelector manages AI goals:MeleeAttackGoal: Close-range combatRangedAttackGoal: Bow/projectile attacksFollowOwnerGoal: Tamed animal followingPanicGoal: Flee when damagedBreedGoal: Animal breedingLookAtPlayerGoal: Look at nearby playersRandomStrollGoal: Random wandering
PathNavigation: High-level navigationPathFinder: A* pathfinding algorithmPath: Sequence of nodes to destination
Entity limits
The Level class enforces entity limits:Chunk system
Chunk structure
LevelChunk represents a 16×256×16 section of the world:
- World position (x, z) maps to chunk (x >> 4, z >> 4)
- Each chunk contains 65,536 blocks (16×256×16)
Chunk generation
ChunkSource generates chunks:
Generator types:
RandomLevelSource: Overworld terrain generationHellRandomLevelSource: Nether generationTheEndLevelRandomLevelSource: End generationFlatLevelSource: Superflat worlds
- Base terrain: Perlin noise for height and biomes
- Biome layers: Temperature, rainfall, biome selection
- Features: Trees, ores, lakes, caves, dungeons
- Structures: Villages, temples, mineshafts, strongholds
- Population: Grass, flowers, mushrooms
Chunk generation uses
BiomeSource with layer-based biome generation, similar to Java Edition’s climate system.Block system
Tile is the base class for all blocks:LiquidTile: Water and lava flowRedStoneDustTile: Redstone wirePistonBaseTile: Piston mechanicsDoorTile,FenceTile,StairTile: Complex shapesCropTile: Farmland crops with growth
TileEntity system
Complex blocks useTileEntity for extra data:
ChestTileEntity: Inventory storageFurnaceTileEntity: Smelting with fuel and progressBrewingStandTileEntity: Potion brewingEnchantmentTableEntity: Enchantment randomizationBeaconTileEntity: Beacon effectsCommandBlockEntity: Command executionSignTileEntity: Sign text
World simulation
Lighting system
The lighting engine calculates two types of light: Sky light:- Sunlight/moonlight from above
- Propagates downward until blocked
- Changes with time of day
- Light from torches, lava, glowstone
- Propagates in all directions
- Constant brightness
Lighting optimization
Lighting optimization
The lighting system uses several optimizations:
- Light cache: Thread-local cache for chunk rebuilding
- Sparse storage: Only store non-zero light values
- Batch updates: Group multiple light changes
- Scheduled updates: Defer lighting until chunk generation complete
Scheduled ticks
Blocks can schedule future updates:- Redstone repeater delays
- Water and lava flow
- Crop growth
- Fire spread
- Grass propagation
Physics and collision
AABB (Axis-Aligned Bounding Box) for collision:- Get potential collision boxes from blocks and entities
- Sweep AABB through space
- Resolve collisions iteratively (X, Y, Z order)
- Set
onGround,horizontalCollisionflags
Game mechanics
Item system
Item base class for all items:DiggerItem: Tools (pickaxe, axe, shovel)BowItem,FishingRodItem: Projectile weaponsArmorItem: Helmets, chestplates, leggings, bootsFoodItem: ConsumablesComplexItem: Items with NBT data
Container system
AbstractContainerMenu manages inventory screens:InventoryMenu: Player inventory (2×2 crafting)CraftingMenu: Crafting table (3×3 crafting)FurnaceMenu: Furnace (input, fuel, output)BrewingStandMenu: Brewing stand (3 potions, ingredient)EnchantmentMenu: Enchanting tableBeaconMenu: Beacon power selection
Crafting system
Recipes class stores all crafting recipes:ShapedRecipe: Position-specific patternsShapelessRecipe: Order-independent ingredientsArmorDyeRecipe: Leather armor dyeingFireworksRecipe: Firework crafting
Enchanting system
Enchantments use a complex randomization system:- Protection: Fire, blast, projectile, fall protection
- Damage: Sharpness, smite, bane of arthropods
- Bow: Power, punch, flame, infinity
- Tool: Efficiency, fortune, silk touch
- Armor: Thorns, respiration, aqua affinity
Enchanting uses the player’s XP level and randomness based on surrounding bookshelves (max 15) to determine available enchantments.
Achievement system
TheAchievement class (Achievement.h:source/Minecraft.World/Achievement.h) extends Stat to track player progress:
Built-in achievements
The game includes a comprehensive achievement tree defined inAchievements.h:source/Minecraft.World/Achievements.h:
Core progression:
openInventory- Open your inventory (starting achievement)mineWood- Mine wood blocksbuildWorkbench- Craft a crafting tablebuildPickaxe- Craft a pickaxebuildFurnace- Build a furnaceacquireIron- Smelt iron orebuildSword- Craft a sworddiamonds- Mine diamond oreenchantments- Use an enchantment table
InToTheNether- Enter the Netherghast- Kill a ghastblazeRod- Obtain a blaze rodpotion- Brew a potion
theEnd- Enter the EndwinGame- Defeat the Ender Dragon
flyPig- Ride a pig off a cliffsnipeSkeleton- Kill a skeleton with an arrow from 50+ metersonARail- Travel by minecart at least 1km from startleaderOfThePack- Befriend five wolves
Achievements are tracked per-player and organized in a tree structure where many achievements require completing prerequisite achievements first.
Networking system
Packet architecture
ThePacket class (Packet.h:source/Minecraft.World/Packet.h) defines the network protocol:
Packet types
The game defines 100+ packet types for synchronization: Connection packets:LoginPacket: Initial connection handshakeDisconnectPacket: Graceful disconnectionKeepAlivePacket: Connection health check
AddPlayerPacket,AddMobPacket: Spawn entitiesMoveEntityPacket: Entity movementRotateHeadPacket: Head rotationSetEntityDataPacket: Synced data updatesRemoveEntitiesPacket: Despawn entities
LevelChunkPacket: Chunk data transferTileUpdatePacket: Single block updateBlockRegionUpdatePacket: Multi-block updateExplodePacket: Explosion effectsLevelEventPacket: World events (sound, particle)
MovePlayerPacket: Player positionPlayerActionPacket: Breaking blocks, actionsUseItemPacket: Right-click actionsInteractPacket: Entity interactionsPlayerAbilitiesPacket: Flying, invulnerability
ContainerClickPacket: Inventory slot clicksContainerSetSlotPacket: Single slot updateContainerSetContentPacket: Full inventoryCraftItemPacket: Crafting result
Packet optimization
Packet optimization
Packets include optimization features:Packet batching:
- Multiple small packets combined into one
- Reduces network overhead
MoveEntityPacketSmall: Sends only position delta- Saves bandwidth for small movements
- Later packets can invalidate earlier ones
- Prevents redundant updates
Multiplayer synchronization
Server authoritative model:- Client sends input packets (movement, actions)
- Server validates and processes
- Server broadcasts state changes to all clients
- Clients render received state
- Client immediately applies own actions
- Server corrections override if desynced
- Reduces perceived latency
Persistence
Save file format
World saves use NBT (Named Binary Tag) format:Level data
LevelData stores world settings:
Region files
Chunks are stored in region files (32×32 chunks per file):McRegionChunkStorage: Chunk read/writeRegionFile: Compressed chunk storageAnvilChunkStorage: Anvil format (256 height)
Next steps
Client architecture
Learn how the Client module renders the world and handles user interaction