Skip to main content

Overview

Minecraft Community Edition supports both split-screen local multiplayer and network multiplayer. The game uses a client-server architecture where one instance acts as the authoritative server and others connect as clients.

Multiplayer Architecture

Client-Server Model

Location: MinecraftServer.cpp:69 and MultiPlayerLevel.cpp:26

Network Flow

Split-Screen Local Multiplayer

Local Player Management

Up to 4 players can play on the same console:
Location: Minecraft.h (referenced in Minecraft.cpp:861)

Adding Local Players

Location: Minecraft.cpp:989

Viewport Assignment

Players are assigned screen regions based on count: 1 Player: Full screen
2 Players: Split horizontally or vertically
3-4 Players: Quadrants
Location: Minecraft.cpp:883-986

Network Multiplayer

Connection Establishment

Default Port: 25565 (Minecraft standard) Location: Referenced in MinecraftServer.cpp:168

Player Connection Lifecycle

1. Connection Request
2. Login Handshake
3. World Sync
4. Player Spawn
5. Disconnect

Player Synchronization

Server Player

The authoritative representation:
Updates Sent:
  • Position and rotation
  • Health and hunger
  • Inventory changes
  • Experience
  • Effects (potion, fire, drowning)

Client Player

Client-side prediction and rendering:
Updates Sent:
  • Input (movement, jumping, crouching)
  • Block breaking/placing
  • Item usage
  • Inventory actions

World Synchronization

Chunk Packets

Chunks are sent as the player moves:
Compression:
  • Chunks are zlib compressed
  • Reduces network bandwidth by ~80%
  • Client decompresses on receive
Location: Referenced in MultiPlayerLevel.cpp:876

Chunk Unloading

Location: MultiPlayerLevel.cpp:389

Block Updates

Single Block:
Multiple Blocks:

Block Change Tracking

Client changes are reverted pending server confirmation:
Location: MultiPlayerLevel.cpp:16-24 and MultiPlayerLevel.cpp:127-150

Entity Synchronization

Entity Spawning

Location: Referenced in tracking system

Movement Packets

Small Movement (relative):
Large Movement (absolute):

Entity Data Updates

Sent when:
  • Entity on fire state changes
  • Crouching/sprinting changes
  • Drowning bubbles change
  • Name tag changes (if supported)

Entity Removal

Connection Management

Client Connection

Timeout Detection:
Location: Referenced in MultiPlayerLevel.cpp:44

Server Connection

Location: MinecraftServer.cpp:168

Pending Connections

Local players connecting to local server:
Location: Minecraft.cpp:1049

Packet Processing

Server-Side Handling

Client-Side Handling

Location: Connection tick methods in MultiPlayerLevel.cpp:118

Disconnect Handling

Disconnect Reasons

Graceful Disconnect

Location: MultiPlayerLevel.cpp:606

Removing Players

Location: Minecraft.cpp:1163

Network Optimization

Slow Queue System

Reduces packet spam for less critical updates:
Used For:
  • Entity metadata updates
  • Non-critical inventory syncs
  • Effect particles
Location: MinecraftServer.cpp:63-65

Packet Batching

Multiple small packets combined:

Update Frequency

Different update rates for different data:
  • Position: Every tick (20 TPS)
  • Health: On change only
  • Inventory: On change only
  • Time: Every 20 ticks (1 second)
  • Chunk visibility: On enter/exit range
Location: MinecraftServer.cpp:1477

Key Takeaways

  1. Client-Server Model: One authoritative server, multiple clients
  2. Split-Screen Support: Up to 4 local players with separate viewports
  3. Chunk Streaming: Dynamic loading as players explore
  4. Entity Tracking: Only entities in range are synchronized
  5. Prediction: Client predicts movement, server corrects
  6. Compression: Chunk data compressed for bandwidth efficiency