Skip to content

World Map

Coordinate Calculator

Coming soon!

Coordinate System

Tile

The smallest unit of space in the world.

Chunk

An 8x8 area of tiles.

Region

An area of 8x8 chunks which makes an area of 64x64 tiles.

Area

It is often useful to be able to define an arbitrary area of contiguous or non-contiguous tiles, so an Area concept is required.

Coordinate Calculation

Because tiles are the smallest units in the map, we should start with a tile position, also known as an "absolute."

In this example, we will use (3200, 3200) for simplicity because it's a multiple of 8 with no remainder. All math is done using integers, so even if you were to use (3201, 3201) you would get effectively the same answers as would follow.

Simply divide the absolute coordinates by 8 and you get the chunk coordinates. Divide the chunk coordinates by 8 and you get the region coordinates. When observing this in the client, you will often see something like: chunkX = absX >> 3 and regionX = chunkX >> 3 or regionX = absX >> 6.

Absolute Chunk Region
3200, 3200 400, 400 50, 50

Encoding

Often, you will need to reference a tile, chunk, or region by a single value instead of a tuple. Depending on the situation, and the needs of the data, you may find several variations of this identifier.

Tile Hash Code

While not often used in the client, preferring to encode coordinate values distinctly, you can pack 3 values (x, y, z) into a single 32 bit integer with some tweaking to ensure that the values will always fit within the boundaries. Technically, adding (+) or using OR on all the values will achieve the same integer value, and the speed difference between the two will vary between CISC (x86, x86_64) processor implementations between vendors (AMD, Intel) and product lines.

You can calculate it using the formula: tileID = plane << 30 | (y & 0x7FFF) << 15 | x & 0x7FFF

The plane takes up 2 bits and is shifted to the end, y cleared & shifted 15 bits, and leaves x cleared with 15 bits at the beginning.

Region ID

The region ID is an integer packed with two values. Since the individual values do not exceed 16 bit max value, this works out fine and we don't need to AND the bits of either value to clear it.

You can calculate it using the formula: regionID = (regionX << 8) + regionY

Chunk ID

The chunk ID is an integer packed with two values. Since the individual values do not exceed 16 bit max value, this works out fine and we don't need to AND the bits of either value to clear it.

You can calculate it using the formula: chunkID = (chunkX << 8) + chunkY