Alpha Map Format: Difference between revisions

From wiki.vg
Jump to navigation Jump to search
imported>MAD
(→‎Players: I suck at tables.)
imported>MAD
(→‎Chunks: Explain base-36.)
Line 7: Line 7:
= Chunks =
= Chunks =


Chunks are stored in folders inside the world corresponding to their coordinates in base-36.
Chunks are stored in folders inside the world corresponding to their coordinates in base-36. The path is "<base-36-x-63>/<base-36-z-63>/c.<base-36-x>.<base-36-z>.dat", where <base-36-x-63> is the base-36 representation of the X coordinate of the chunk AND'd bitwise with 63.
 
== The Base-36 Algorithm ==
 
To retrieve the base-36 representation of a number, use the digits "0123456789abcdefghijklmnopqrstuvwxyz", and prefix the result with a hyphen ("-") if the number is negative.
 
Example code in Python, from [[Beta]]:
 
def base36(i):
    """
    Return the string representation of i in base 36, using lowercase letters.
    """
    letters = "0123456789abcdefghijklmnopqrstuvwxyz"
    if i < 0:
        i = -i
        signed = True
    elif i == 0:
        return "0"
    else:
        signed = False
    s = ""
    while i:
        i, digit = divmod(i, 36)
        s = letters[digit] + s
    if signed:
        s = "-" + s
    return s


= Players =
= Players =

Revision as of 21:06, 11 December 2010

Alpha worlds consist of several files, all held together in one folder under a very rigid directory structure.

Level

The level is a file called "level.dat" in the root of the world.

Chunks

Chunks are stored in folders inside the world corresponding to their coordinates in base-36. The path is "<base-36-x-63>/<base-36-z-63>/c.<base-36-x>.<base-36-z>.dat", where <base-36-x-63> is the base-36 representation of the X coordinate of the chunk AND'd bitwise with 63.

The Base-36 Algorithm

To retrieve the base-36 representation of a number, use the digits "0123456789abcdefghijklmnopqrstuvwxyz", and prefix the result with a hyphen ("-") if the number is negative.

Example code in Python, from Beta:

def base36(i):
    """
    Return the string representation of i in base 36, using lowercase letters.
    """
    letters = "0123456789abcdefghijklmnopqrstuvwxyz"
    if i < 0:
        i = -i
        signed = True
    elif i == 0:
        return "0"
    else:
        signed = False
    s = ""
    while i:
        i, digit = divmod(i, 36)
        s = letters[digit] + s
    if signed:
        s = "-" + s
    return s

Players

Persistent data for players is stored in a folder called "players". Each player has a file called "<username>.dat".

Name Type Description
Pos List of 3 doubles X, Y, and Z coordinates of the player position, in pixel coordinates
Rotation List of 2 doubles Yaw and pitch of the player, in degrees

Map Generation

There are several approaches to map generation.

Noise

Two-dimensional noise functions can be used to provide a terrain height at certain coordinates.