Zero-downtime handoff and ordered replication
What happens when a player walks from one shard to another: swapping their backend mid-session, replaying their input, and keeping each shard's mirror of its neighbour in exactly the order things happened.
Part 1 · Handoff
Every player connects through Velocity, so the proxy is the one place that can move them without the client knowing. When a player crosses into another shard's chunks, the old shard keeps simulating them until the new one is ready. Then the proxy swaps the player's backend mid-session. The client keeps one connection the whole time.
The swap isn't instant, and the client keeps sending moves while it happens. Those moves are buffered and replayed on the new shard once it takes over, so nothing the player did is lost.
The first version replayed every buffered move as soon as the new shard took over, all in the same tick. On 26.3 that got the player kicked: the server accepts one move per tick from a client, and a burst of buffered moves looks exactly like a cheating client. The fix was to replay at the rate a real client sends, one move per tick, until the buffer is empty.
Part 2 · Mirror streams
Each shard keeps a read-only copy of a band of its neighbour's chunks. That copy is fed by a mirror stream: a snapshot to start from, then a numbered sequence of changes. The numbers matter. Applying change #46 before #45 isn't "slightly late"; it's a different world.
- Flush at tick end. Changes made during a tick are sent together once the tick finishes, so the mirror never sees half a tick.
- Catch up before taking over. Before a shard takes a player over, its mirror must have applied every change up to the moment the handoff was requested. Otherwise the player would step into a world a tick or two out of date.
- Neighbour updates ride inside the stream. Block updates that ripple across the border travel in the same numbered stream as the changes that caused them.
A redstone clock built right on a shard border stopped after a few pulses. The neighbour updates were going over a separate path from the block changes, so the other shard sometimes got told "your neighbour changed" before the change itself had arrived. It re-evaluated the wire against a stale clock, saw nothing new, and never updated again. Moving neighbour updates into the mirror stream fixed it, because they can no longer overtake the change they describe.