Skip to main content
Minecraft Community Edition uses a client-server architecture even for single-player games. This design enables seamless transitions between local and multiplayer gameplay.

Architecture Diagram

Client Architecture

Minecraft Class

The main client class manages the game state and rendering (Minecraft.h:47):
Even in single-player mode, the client maintains a ClientConnection to a local MinecraftServer instance running in the same process.

MultiplayerLocalPlayer

Represents a local player on the client:

Server Architecture

MinecraftServer Class

The server manages world simulation and player connections (MinecraftServer.h:60):

Server Tick System

The server runs at a fixed 20 ticks per second:
The server must maintain 20 TPS (ticks per second) for proper gameplay. Performance issues causing tick lag affect all connected players.

Connection Management

ClientConnection

Manages the client-side network connection (ClientConnection.h:9):

Connection Handshake

The connection process follows this sequence:

ServerConnection

Manages all incoming connections on the server (ServerConnection.h:10):

PlayerConnection

Manages a single player’s connection on the server (PlayerConnection.h:12):

Player Management

PlayerList

The server maintains a centralized player list:

Player Lifecycle

  1. Connection: PlayerConnection created when socket connects
  2. Login: Player entity created after successful authentication
  3. Spawn: Player spawned in world, visible to other players
  4. Gameplay: Continuous packet exchange (movement, actions, chat)
  5. Disconnect: Player removed, resources cleaned up

Split-Screen Local Play

Minecraft CE supports up to 4 local players simultaneously, each with their own connection to the local server.

Adding Local Players

Each local player:
  • Has their own ClientConnection to the server
  • Maintains separate inventory and game state
  • Renders to their own viewport
  • Can have different privileges and permissions

Server Lifecycle

Server Initialization

Server Main Loop

Server Shutdown

Best Practices

Always use critical sections when accessing shared state:
Check connection state before sending packets:
Avoid expensive operations in the main tick loop. Use background threads for:
  • Chunk generation
  • Chunk compression
  • File I/O operations

Networking

Deep dive into the network protocol and packet system

Overview

High-level architecture and component overview