Alpha Map Format
Alpha worlds consist of several files, all held together in one folder under a very rigid directory structure.
Contents
Level
The level is a file called "level.dat" in the root of the world.
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Data | Compound | General level data
|
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.
For example, if we have the chunk coordinate (39, -13), we end up with the path 13/1f/c.13.-d.dat
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
Example code in C#:
public static string Base36Encode(long input)
{
if (input == 0){ return "0"; }
string chars = "0123456789abcdefghijklmnopqrstuvwxyz";
bool negative = (input < 0);
StringBuilder sb = new StringBuilder();
if (negative) {
input = -input;
sb.Append("-");
}
while (input > 0) {
sb.Insert((negative ? 1 : 0), chars[(int)(input % 36)]);
input /= 36;
}
return sb.ToString();
}
Players
Persistent data for players is stored in a folder called "players". Each player has a file called "<username>.dat".
Beta player files
Player files are NBT encoded.
The file starts with a nameless TAG_Compound which contains all other data.
| Tag Name | Type | Description |
|---|---|---|
| SleepTimer | TAG_Short | |
| Motion | TAG_List(3 TAG_Double) | |
| OnGround | TAG_Byte | |
| HurtTime | TAG_Short | |
| Health | TAG_Short | |
| Dimension | TAG_Int | |
| Air | TAG_Short | |
| Inventory | TAG_List or TAG_Byte(when empty) | See Inventory table below |
| Pos | TAG_List(3 TAG_Double) | |
| AttackTime | TAG_Short | |
| Sleeping | TAG_Byte | |
| Fire | TAG_Short | |
| FallDistance | TAG_Float | |
| Rotation | TAG_List(2 TAG_Float) | |
| DeathTime | TAG_Short | |
| SpawnX | TAG_Int | Only present when spawn is set elsewhere |
| SpawnY | TAG_Int | Only present when spawn is set elsewhere |
| SpawnZ | TAG_Int | Only present when spawn is set elsewhere |
Inventory items are in the TAG_Compound format with the following tags:
| Tag Name | Type | Description |
|---|---|---|
| Slot | TAG_byte | |
| id | TAG_Short | |
| Damage | TAG_Short | |
| Count | TAG_Byte |
Other formats
The following format is not used in Beta. May be the Alpha format.
| 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.