Networking
The client and the server talk over ENet, a thin reliability layer on top of UDP. Each side reads and writes buffers. Every packet starts with a 16-bit unsigned integer that names its ID.
Every packet goes out reliably. ENet sequences each channel on its own, so the world stream has a channel of its own. A burst of chunk packets does not hold back login, entity or timing packets, and the other way around. Blocks, biomes and light share that channel, because a light packet is only meaningful after the chunk that it belongs to. A single sequence is what guarantees that order.
A client goes through one of two exchanges after it connects: a status ping, or a full login. Both exchanges start the same way. Both end with the server closing the connection or keeping it open.
Status pings
A client can connect just to ask a server about itself: protocol version, MOTD, player count, and slot limit. The server does not keep this connection open.
Flow
The figure shows the exchange. The table lists the same steps.
| Step | Sender | Receiver | Description |
|---|---|---|---|
| 1 | Client | Server | The client connects |
| 2 | Client | Server | The client sends a status request packet |
| 3 | Server | Client | The server responds with a status response packet |
| 4 | Client | Server | The client closes the connection |
Authentication
If the client sends a login request instead of a status request, the server starts an authentication exchange.
Flow
The figure shows the exchange. The table lists the same steps.
| Step | Sender | Receiver | Description |
|---|---|---|---|
| 1 | Client | Server | The client connects |
| 2 | Client | Server | The client sends a login request packet: username, public Ed25519 key, invite code, protocol version, and registry hashes |
| 3 | Server | Client | If the server accepts the request, it responds with a challenge packet holding a random nonce |
| 4 | Client | Server | The client signs the nonce plus the current UTC time (minute resolution), and sends the signature back in a challenge response packet |
| 5 | Server | Client | If the signature matches, the server admits the client with a packet holding its assigned username |
| 6 | N/A | N/A | Entity exchange and game packets start here |
Spawn world
The server admits the client into the world that worlds.yml marks with default: true, or the first world when none is marked. The server sends the world shape, the weather seed and the clocks in the admission packets. The client therefore needs no world name of its own. The world seed never leaves the server.
Identity
The client proves its identity with an Ed25519 keypair. The server challenges the client with a random nonce, and the client signs it.
Invite codes
The invite code is a one-time code. On a successful login, the server consumes the invite code. The server then adds the client’s public key to its whitelist. The same client can then reconnect later without a new invite. An operator issues codes with invite.
Registry hashes
The client sends its block, biome, fluid, tint, entity class, weather and precipitation registry hashes. The server checks each hash against its own. A mismatch means the two sides disagree on what a given ID means. When that happens, the server disconnects the client with a checksum mismatch reason. Neither side acts on the disagreement.
This check protects both sides:
- It stops a mismatched client from receiving chunk data it would render as corrupted or nonsensical.
- It stops that same client from placing a block ID the server does not recognize.
Operator access
A server can mark an Ed25519 public key as an operator. The server keeps these keys in operators.txt next to whitelist.txt in the user directory. The file holds one exported public key per line, the same format as whitelist.txt.
The server tracks the status per session. An operator bypasses the whitelist, so the same key does not have to appear in both files.
Enrolling an operator
The player runs the whoami command in the console. The client prints its public key and its identity. The identity is the crc64 of the key, and server logs show the identity. The public key is the value that the files expect.
The first operator enrolls by hand:
| Step | Who | Action |
|---|---|---|
| 1 | Player | Connect and run whoami |
| 2 | Server host | Copy the public key: line into operators.txt |
| 3 | Server host | Restart the server |
After that, an operator runs op <public key> or deop <public key>. These update operators.txt right away and promote or demote a matching live session without a reconnect. A hand edit still needs a restart, because the server loads the file during startup and writes it back on shutdown.
Operator commands
An operator connects like everyone else. The server sends the command list of an operator with the operator-only commands included, and every other client gets a list without them. A client that does not know a command reports it as unknown.
| Command | Description |
|---|---|
who | List connected sessions with their client IDs, identities, public keys, and access levels |
op | Add a public key to the operator list and promote that player |
deop | Remove a public key from the operator list and demote that player |
kick | Disconnect a player by client ID or username |
invite | Issue a one-time invite code |
The commands carry the admin and recall flags. recall lets the client forward the command to the server. admin makes cvar::exec refuse it unless the context holds a client that is an operator. The engine trusts a context without a client, such as server.conf or the client’s own console.
A demoted operator keeps the commands it already learned, but the server rejects them.
Kicking
kick sends a disconnect packet with the kicked reason and then closes the connection. The key is not banned. A kicked client can reconnect unless something else stops it, such as the whitelist or a full server.
Cvar replication
The server owns every variable flagged with FCVAR_REPLICATED. After admission it sends a full snapshot of them. On every fixed tick it sends the variables that changed since the previous tick.
The client keeps the server value in a shadow. A local variable with the same name must also carry the FCVAR_REPLICATED flag. Otherwise the client ignores the server value and logs a warning. A full snapshot drops stale remote variables and clears the old shadows.
The server accepts a cvar value from a client only when the variable carries the FCVAR_ADMIN flag and the caller is an operator. The client console forwards a write to a shadowed variable through the same Cvar_Command path as a command. The server applies the operator check and ignores every other remote value. Gamerules use the gr_ prefix. Match rules will use mp_. The console list_vars and list_cmds commands list every variable and command.
The command snapshot follows the same exchange. The server sends one full list to each admitted client. The list leaves out the commands that carry the FCVAR_ADMIN flag unless that client is an operator. When a live session gains or loses the operator status, the server sends the list again. A dirty variable update carries only the replicated variables that changed in that tick.
The snapshot packet carries a uint8 full flag and a uint32 count, then for each variable a string name and a string value. A full snapshot adds a uint16 flags and a string help for each entry.
World
Once the server admits a client, the client asks for chunks and reports block and entity actions. Only the server can make a world change final.
Chunk transfer
The client sends RequestChunk every fixed tick with two boxes: the chunk-aligned view it needs, and the XZ interest box for column data. The server intersects each box with its own view limit and sends only what the peer does not hold yet. The server answers with ChunkBlocks, holding that chunk’s full block data. It also sends ChunkBlocks on its own initiative, as a full resync.
Biomes and column heights belong to an XZ column, not to one chunk. The server sends ChunkBiomes and ChunkColumns once per column. ChunkColumns carries the surface and liquid heights that precipitation and the shelter checks use. When a column changes, the server sends Column to the sessions whose interest box holds that column. A client drops a column that leaves its interest box, and the server sends it again when the client comes back.
World info
The server sends World_Info at admission and again when a session moves to another world. It carries the world’s name, its vertical bounds and spawn point, its optional visual groups, the weather types it allows and the world’s weather seed. The client builds its one world from this packet instead of a local world definition. These values never change for a world, so the periodic packets do not repeat them. The world seed is not in the packet: the client streams terrain without being able to predict it. The client derives its star field seed from the weather seed, which both sides compute the same way. The length of a day is not here either: it is the replicated server variable sv_day_length, so a change reaches every connected client without another packet.
World switch
A session moves to another world only through tpe, which runs on the server. The server moves the player entity into the target registry, then repeats the admission state: World_Info, World_Timings and Entity_Client for the new entity. The client purges its world on World_Info, drops the player and resets its weather state, then streams the new world from its next World_Request. The server scopes entity, light and block packets to the session’s own world, so they never reach a session in another world.
Time
The server owns a world clock per world. World_Timings carries the universe-wide current_tick, the world’s daylight_tick, the whole day count (daylight_tick / sv_day_length), the world’s weather_tick and a reserved season_tick. The season_tick stays zero until the season cycle lands. Every world shares current_tick, so block ticks and chunk saves stay comparable across the server. daylight_tick advances per world at the same fixed rate, and that is what lets two worlds run different days. The gr_daylight_cycle gamerule stops only the daylight clock. The client runs its own smooth phase between packets and aligns it with the server. When a packet moves the clock by a second or more, which is what time_set does, the client snaps instead of easing. The packet carries no flag for this: the client sees the jump in the tick values that it already keeps. The server writes each world’s daylight tick into that world’s world.conf on shutdown, so a restart continues the day where it was. Operators set the clock with time_set <daylight tick>, which targets the caller’s world. Clients read what they see with time_query.
Weather
The engine derives the weather, and it does not stream it. The server rolls one weather seed per world and keeps it in that world’s world.conf, independent of the world seed. It sends the seed once in World_Info. Every tick the server advances a per-world weather_tick and sends it in World_Timings. That is the only weather value on the wire after admission. Both sides turn the pair (weather_seed, weather_tick) and a world position into the same field. Two drifting noise grids form the two axes of a climate square, and every weather type owns a target point in that square. The nearest target and its soft share decide the type and the local strength. There is no drift or baseline packet any more, and no accumulated drift to diverge. The same seed and the same tick always give the same field. A client advances its copy of the tick between packets, and it snaps when a packet jumps the clock by more than a second. That jump is what weather_force and a world switch look like. The replicated gr_weather_cycle gamerule stops the weather clock on the server and the client’s local advance together. The login checksums cover the weather and precipitation definitions, which travel as part of the mod content. The precipitation type is local: both sides derive it from the same weather field and the block climate, so no precipitation state travels.
Block and entity actions
The client sends one of four packets depending on what it targets and what it does: PlayerAttackE/PlayerInteractE for an entity target, PlayerAttackB/PlayerInteractB for a block target. There is no single unified packet with a nullable target field.
The entity variants carry only the targeted entity. Both block variants carry the block’s position and the ID the client expects to find there. PlayerInteractB also carries the hit face, normal and point, which match the physics::BlockHit fields the block callbacks expect.
Packet reference
Each packet starts with a 16-bit unsigned integer that names its ID. The packets use these names and structures:
0x0000 StatusRequestPacket
Request a status from server
| Type | Name | Description |
|---|---|---|
uint32 | major | Major game version |
uint32 | minor | Minor game version |
uint32 | patch | Patch game version |
0x0001 StatusResponsePacket
Server’s response to a StatusRequestPacket
| Type | Name | Description |
|---|---|---|
uint32 | major | Major game version |
uint16 | slots | Maximum player slots |
uint16 | players | Current player count |
string | motd | One-line MOTD no longer than 32 characters |
uint32 | minor | Minor game version |
uint32 | patch | Patch game version |
uint32 | tags | Server tags |
Server flags
| Value | Description |
|---|---|
0x00000001 | Server has whitelist enabled |
0x00000002 | Server enforces strict version matching |
0x0002 AuthRequestPacket
Request an authentication on a server
| Type | Name | Description |
|---|---|---|
uint32 | major | Major game version |
uint32 | minor | Minor game version |
uint32 | patch | Patch game version |
uint8[32] | pkey | Public Ed25519 key |
uint64 | invite | Invite-code |
uint64 | biomes_hash | Biome registry hash |
uint64 | blocks_hash | Block registry hash |
uint64 | fluids_hash | Fluid registry hash |
uint64 | tints_hash | Tint registry hash |
uint64 | ents_hash | Entity registry hash |
uint64 | weather_hash | Weather registry hash |
uint64 | precip_hash | Precipitation registry hash |
string | username | Desired username |
0x0003 AuthChallengePacket
Server’s response to AuthRequestPacket
| Type | Name | Description |
|---|---|---|
uint8[64] | nonce | Nonce for the client to sign |
0x0004 AuthResponsePacket
Client’s repsonse to AuthChallengePacket
| Type | Name | Description |
|---|---|---|
uint8[64] | signature | Signed nonce + UNIX minutes |
0x0005 AuthAdmissionPacket
On successful auth, server’s response to AuthResponsePacket
| Type | Name | Description |
|---|---|---|
uint16 | client_id | Client ID |
uint64 | identity | Client identity |
string | username | Assigned username |
0x0006 Disconnect
Disconnection notification. Each side should close the connection right after this packet, although it may keep the connection open
| Type | Name | Description |
|---|---|---|
uint32 | reason | Disconnect reason |
Reason values
| Value | Description | When |
|---|---|---|
0x00000000 | Unspecified reason | Anything not specified below |
0x00000001 | Client disconnect | Client manually disconnects |
0x00000002 | Client shutdown | Client closes the game |
0x00000003 | Entity ID desync | EnTT registry goes nuts |
0x00000004 | Checksum mismatch | Client isn’t synced up with server mods |
0x00000005 | Not whitelisted | Client’s public key is not in the whitelist |
0x00000006 | Invalid signature | Client messed up nonce signing |
0x00000007 | Outdated client | Client is too old for the server |
0x00000008 | Outdated server | Client is too new for the server |
0x00000009 | Server is full | No more free slots available |
0x0000000A | Server shutdown | Server is terminating |
0x0000000B | Cvar rejected | A remote write to an admin variable was refused |
0x0000000C | Kicked | An operator removed the client |
0x0000000D | World unknown | The client asked for a world the server does not have |
0x0007 RequestChunk
The client sends this packet every fixed tick to describe what world data it wants. The packet carries a chunk-aligned view box, an XZ interest box for column data and a budget. The server intersects each box with its view limit, stores what the peer already has, and sends only the difference. A box with min > max is empty.
| Type | Name | Description |
|---|---|---|
vector3<int32> | view_min | Minimum chunk of the view |
vector3<int32> | view_max | Maximum chunk of the view |
vector2<int32> | interest_min | Minimum XZ chunk of the column interest |
vector2<int32> | interest_max | Maximum XZ chunk of the column interest |
uint16 | chunk_budget | How many chunks the server may queue now |
The budget carries the client’s backpressure. The client lowers the budget while its mesher queues more work than it can take. The sent sets live on the server, and the server fills them only when it hands a packet to ENet. The server therefore retries a request that produces no data instead of counting it as delivered.
0x0008 ChunkBlocks
The server sends this packet as a response to RequestChunk, or at arbitrary moments to synchronize chunk contents with clients
| Type | Name | Description |
|---|---|---|
vector3<int32> | cpos | Chunk position |
data | blocks | Serialized and compressed block storage contents |
data | light | Compressed packed light, one byte per block: skylight in the high nibble, block light in the low nibble |
uint8 | light_valid | 1 when light holds computed light. 0 makes the client fall back to its own estimate until a ChunkLight arrives |
0x0009 ChunkBiomes
The server sends this packet as a response to RequestChunk to synchronize the biome caches that client rendering uses
| Type | Name | Description |
|---|---|---|
vector2<int32> | cpos | XZ-position |
data | biomes | Compressed list of 256 biome IDs |
WriteBuffer::write_compressed writes every compressed field, and ReadBuffer::read_compressed reads it back. Such a field holds four parts. The parts are a mode byte, the size that the data had before compression, the size that it takes in the buffer, and the bytes. The bytes are either raw or a zlib stream. The engine compresses the whole array at once, so the ratio is the one that the codec gets over a chunk. A transport would get a different ratio out of a single datagram.
0x000A ChunkColumns
The server sends this packet once per XZ column to synchronize the surface and liquid heights that precipitation and the shelter checks use.
| Type | Name | Description |
|---|---|---|
vector2<int32> | cpos | XZ chunk position |
data | columns | Compressed list of 256 columns. Each column holds two int32 values: surface_y and liquid_y |
A stored height of INT32_MIN means that the column has no such block.
0x000B ChunkLight
The server sends this packet when the light of chunks that it has already synchronized changes. One packet carries every chunk whose light changed in a tick. Each entry is either a delta over the cells that changed or, when most of the chunk changed, the whole array.
| Type | Name | Description |
|---|---|---|
uint16 | count | Number of entries |
entry[count] | entries | One per changed chunk |
Each entry:
| Type | Name | Description |
|---|---|---|
vector3<int32> | cpos | Chunk position |
uint8 | full | 1 when the entry carries the whole array, 0 for a delta |
data | light | Only with full = 1. Packed light, same layout as the light field of ChunkBlocks |
uint16 | cells | Only with full = 0. Number of changed cells |
uint16, uint8 | index, value | Only with full = 0. One pair per changed cell, repeated cells times: the cell index, the same order as the light array, then the new packed light |
The server applies a delta only to a chunk that the client already holds light for. When the server replaces a whole array, it always sends it whole. It does the same when the changed cells outnumber a quarter of the chunk, instead of sending a delta that would be larger.
The server splits a batch when it would exceed 32 KiB. A tick that relights a large part of the view distance therefore turns into several packets instead of one huge one.
0x000C SetBlock
The server sends this packet as a sub-chunk block update
| Type | Name | Description |
|---|---|---|
vector3<int64> | bpos | World-scale block position |
uint32 | block | Resulting numeric block ID |
0x000D Column
The server sends this packet when the surface or liquid height of a column changes.
| Type | Name | Description |
|---|---|---|
vector2<int64> | bpos | World-scale XZ block position |
int32 | surface_y | Top surface block, or INT32_MIN |
int32 | liquid_y | Top liquid block, or INT32_MIN |
0x000E WorldTimings
The server sends this packet every tick for the world a client is in
| Type | Name | Description |
|---|---|---|
uint64 | current_tick | Current world tick |
uint64 | daylight_tick | Tick the daylight cycle follows |
uint64 | day | Day number |
uint64 | weather_tick | Tick the weather clock stands at |
uint64 | season_tick | Reserved for the season cycle, zero for now |
0x000F WorldInfo
The server sends this packet when it admits a client, and again when the client moves to another world
| Type | Name | Description |
|---|---|---|
string | name | World name |
uint64 | weather_seed | Seed of the weather field of this world |
int64 | min_y | Lowest buildable block Y |
int64 | max_y | Highest buildable block Y |
vector3<int64> | spawn | Spawn position |
uint16 | nweather | Number of allowed weather types. Zero allows every type |
uint32[nweather] | weather | Allowed weather type IDs |
0x0010 CvarServerVars
The server sends this packet with the variables a client may read
| Type | Name | Description |
|---|---|---|
uint8 | full | 1 for a full list, 0 for an update |
uint32 | count | Number of variables |
string | name | Variable name, per variable |
string | value | Variable value, per variable |
uint16 | flags | Variable flags, per variable. Only with full = 1 |
string | help | Variable help, per variable. Only with full = 1 |
0x0011 CvarServerCmds
The server sends this packet with the commands a client may run
| Type | Name | Description |
|---|---|---|
uint32 | count | Number of commands |
string | name | Command name, per command |
uint16 | flags | Command flags, per command |
string | help | Command help, per command |
0x0012 CvarCommand
The client sends this packet to run a console line on the server
| Type | Name | Description |
|---|---|---|
uint32 | request_id | ID the server echoes in its reply |
string | line | Console line, no longer than the protocol limit |
0x0013 PlayerAttackE
Sent by client to specify an attack action against an entity
| Type | Name | Description |
|---|---|---|
uint64 | target | Targeted entity |
0x0014 PlayerAttackB
Sent by client to specify an attach action against a block
| Type | Name | Description |
|---|---|---|
vector3<int64> | bpos | Targeted block position |
uint32 | expected | Numeric block ID the client expects at bpos |
0x0015 PlayerInteractE
Sent by client to specify an interact action against an entity
TODO: send over specific part of an entity’s hitbox as well
| Type | Name | Description |
|---|---|---|
uint64 | target | Targeted entity |
0x0016 PlayerInteractB
Sent by client to specify an interact action against a block
| Type | Name | Description |
|---|---|---|
vector3<int64> | bpos | Targeted block position |
uint32 | expected | Numeric block ID the client expects at bpos |
uint8 | face | Hit face used for interactions |
vector3<float> | normal | Hit normal |
vector3<float> | point | Hit point local to the block |
0x0017 PlayerMoveData
The client sends this packet with its own movement state
| Type | Name | Description |
|---|---|---|
vector3<int32> | cpos | Chunk position the client simulated in |
vector3<float> | angles | Camera angles |
vector3<float> | lpos | Local position inside the chunk |
vector3<float> | velocity | Velocity |
vector3<float> | wishdir | Direction the player asks to move in |
0x0018 EntitySpawn
The server sends this packet when it spawns an entity
| Type | Name | Description |
|---|---|---|
uint64 | id | Entity ID |
uint16 | class_id | Numeric class ID |
0x0019 EntityPatch
The server sends this packet when it updates a component of an entity
| Type | Name | Description |
|---|---|---|
uint64 | id | Entity ID |
uint32 | ncomp | Component count |
uint16 | id | Component ID, per component |
uint32 | size | Byte length of the component, per component |
data | bytes | Component bytes, per component |
0x001A EntityRemove
The server sends this packet when it removes an entity
| Type | Name | Description |
|---|---|---|
uint64 | id | Entity ID |
0x001B EntityClient
The server sends this packet to tell a client which entity it controls
| Type | Name | Description |
|---|---|---|
uint64 | id | Entity ID |
0x001C MsgLog
The server sends this packet as the reply to a console line
| Type | Name | Description |
|---|---|---|
uint32 | request_id | ID of the request it answers |
uint8 | level | Log level of the message |
string | message | Message text |