-
-
Notifications
You must be signed in to change notification settings - Fork 4
Principles
For this explanation, we will use a world with limits (-4, 4) on the X and Z axis.
Each Level/Dimension can be configured with individual limits.
- The Nether can use different limits than The Overworld so nether portals line up.
- The End can loop or go on forever.
- This also allows custom limits for custom dimensions.
World limits are defined in terms of chunks. This allows the server to simply swap out chunks for other chunks rather than generate new chunks composed of two separate chunks.
When you enter in an axis' limit from -4
to 4
for example, the limit goes from the start of the minimum chunk (-4
) to the start of the maximum chunk (4
) (or [-4,4)
as an algebraic interval). This means chunk 4
isn't actually included. This is required because world coordinates start at chunk (0,0)
on the north-west side of that chunk.
Below you can see chunk coordinates in red and the (0,0)
world coordinate in blue.
When the client requires a chunk, the server interprets that chunk relative to its limits.
If the client requires chunk (-5,0)
the server gives the client (3,0)
. The chunk (-5,0)
is really just (3-8,0)
.
If the client requires chunk (-13,0)
the server also gives the client (3,0)
. The chunk (-13,0)
is really just (3-16,0)
.
Therefore, the actual chunk can be found by taking the remainder after dividing by the diameter of the X axis.
When the client crosses over the limit, the server teleports the player to the other side. This allows collision systems and interaction distances to work properly. However, this teleportation does not take place on the client. Instead of teleporting, the client continues on, and the server compensates for this coordinate discrepancy by modifying the packets it sends the client.