Map item format

Minecraft Beta 1.6 added craftable map items. Their information is placed in the "data" directory within the world's save directory. Each map has its own file associated with its ID, and there is one file that keeps track of the highest (= most recently created) map ID. This is limited to the size of a short (65,536). When Notch was adding them the first time he did not use the NBT format.

The structure tells that there will probably be an additional feature of maps with different zoom and size. There is support for The Nether, but it is obscured by the top blocks of the Nether and therefore unreadable. The End is supported without problems.

Data folder structure
The file idcounts.dat contains the latest ID for current map. Each map's file name uses the format map<#>.dat, where <#> is the map's unique number.

map_<#>.dat Format
map_<#>.dat files are GZip'd NBT files.

NBT Structure

 * The root tag.
 * : The map data.
 * : How zoomed in the map is (it is in 2scale blocks square per pixel, even for 0, where the map will be 1:1). Default 3, minimum 0 and maximum 4.
 * : 0 = The Overworld, -1 = The Nether, 1 = The End
 * : Height of map. Default (and only possible value) 128
 * : Width of map. Default (and only possible value) 128
 * : Center of map according to real world by X
 * : Center of map according to real world by Z
 * : Width * Height array of color values (16384 entries for a default 128x128 map). Color can be accessed via the following method: colorID = Colors[widthOffset + heightOffset * width], where (widthOffset==0, heightOffset==0) is left upper point.

When this structure is loaded, Colors array is transformed to standard dimension (if it's necessary) and then structure is saved with standard height and width.

idcounts.dat Format
This file keeps track of the latest map added. It is stored as a raw (uncompressed) NBT file.

NBT Structure

 * The root tag.
 * : Latest map ID.

Color table
Maps use a Color Table to store the colors efficiently by ID.

Base Colors
Blocks are colored according to their Material. Each Material has a base color which is multiplied by 180, 220 or 255, and then divided by 255 to make the map color. Each Base Color below is associated with four Map Colors - to get the first Map Color ID for a Base Color, multiply the Base Color ID by 4.

Map Colors
Each Base Color above has 4 associated Map Colors below. The conversion works by multiplying each of the Red, Green, and Blue values by a value and then dividing by 255, finally rounding to the nearest whole. Here is a Map Color table provided as an example: