Alpha Map Format: Difference between revisions
imported>Agenthh (→Chunks) |
imported>Agenthh (→Chunks) |
(No difference)
| |
Revision as of 21:12, 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 main world is stored in the root directory of the world. The Nether is stored in the "DIM-1" folder in the root and uses the same chunk folder system.
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.