Skip to main content
The full sources are in shard-example/. Each of these exists because the obvious single-server version is wrong here in a specific way.

Homes

Homes live in the player record through an adapter, so they follow the player. Going home uses transfer, because the home may be in a region this server does not own.
transfer handles all three cases: the same region, another shard in this geo, and a shard on another continent. Never Player#teleport.

Random teleport

This is the one that proves askAt and safeLanding earn their place. A random point is almost always on somebody else’s shard, and this server cannot look at the ground there.
The recursion is the feature. Most random points in a real world are inside a mountain, under an ocean or in a cave, so a single throw is not a random teleport — it is a coin flip about whether the player suffocates. safeLanding answers honestly, which means it can say no, which means the caller has to be willing to throw again.

Teleport requests

/tpa needs locate, because the stored record says where somebody was when they were last saved, which for anybody walking is the wrong answer.
The request travels with the message, because /tpaccept is typed by the target on whatever server is holding them, and a map on the asker’s shard is not visible from there. Anything two players share has to live where the second one will look for it. Accepting uses summon, because the asker is somewhere else entirely and there is no player object for them here.

The arrival action

All three use the same named action, registered on every shard at enable, because it runs on whichever server the player landed on.
The obvious version — teleport, then tell them what happened — sends the message to the server they are leaving.