Map item format

From Minecraft Wiki
Jump to: navigation, search

Minecraft Beta 1.6 added craftable map items. Unlike books, maps do not store their information in the item - instead, their data value corresponds to the map number (ID) of a saved file. 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).[1] When Notch was adding them the first time he did not use the NBT format.[2]

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.

Contents

[edit] 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.

[edit] map_<#>.dat format

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

[edit] NBT structure

  • Nbtsheet.png The root tag.
    • Nbtsheet.png data: The map data.
      • Nbtsheet.png scale: 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.
      • Nbtsheet.png dimension: 0 = The Overworld, -1 = The Nether, 1 = The End
      • Nbtsheet.png height: Height of map. Default (and only possible value) 128
      • Nbtsheet.png width: Width of map. Default (and only possible value) 128
      • Nbtsheet.png xCenter: Center of map according to real world by X
      • Nbtsheet.png zCenter: Center of map according to real world by Z
      • Nbtsheet.png colors: 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.

[edit] idcounts.dat format

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

[edit] NBT structure

  • Nbtsheet.png The root tag.
    • Nbtsheet.png map: Latest map ID.

[edit] Color table

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

[edit] 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.

Color Table
ID Color RGB Description
0 Transparent Glass, Powered Rail, Detector Rail, Torch, Fire, Redstone Wire, Ladders, Rails, Lever, Redstone Torch, Stone Button, Glowstone, Portal, Cake Block, Redstone Repeater, Glass Pane, End Portal, End Portal Frame
1 127,178,56 Grass Block, Mycelium
2 247,233,163 Sand, Gravel, Soul Sand
3 167,167,167 Sponge, Bed, Cobweb, Wool
4 255,0,0 Lava, TNT
5 160,160,255 Ice
6 167,167,167 Block of Gold, Block of Iron, Block of Diamond, Redstone Block, Iron Door, Iron Bars, Brewing Stand, Cauldron
7 0,124,0 Saplings, Leaves, Tall Grass, Dead Bush, Dandelion, Rose, Brown Mushroom, Red Mushroom, Seeds, Cactus, Sugar Cane, Pumpkin, Jack-O-Lantern, Melon, Pumpkin Stem, Melon Stem, Vines, Lily Pad, Nether Wart, Dragon Egg
8 255,255,255 snow, Snow Block
9 164,168,184 Clay Block, Monster Egg
10 183,106,47 Dirt, Farmland
11 112,112,112 Stone, Cobblestone, Bedrock, Gold Ore, Iron Ore, Coal Ore, Lapis Lazuli Ore, Lapis Lazuli Block, Dispenser, Sandstone, Sticky Piston, Piston, Piston Extension, Block moved by Piston, Double Slabs, Slabs, Bricks, Moss Stone, Obsidian, Monster Spawner, Diamond Ore, Furnace, Cobblestone Stairs, Stone Pressure Plate, Redstone Ore, Netherrack, Stone Bricks, Brick Stairs, Stone Brick Stairs, Nether Brick, Nether Brick Fence, Nether Brick Stairs, Enchantment Table, End Stone
12 64,64,255 Water
13 104,83,50 Wood Planks, Wood, Note Block, Bookshelf, Wooden Stairs, Chest, Crafting Table, Sign Post, Wooden Door, Wall Sign, Wooden Pressure Plate, Jukebox, Fence, Locked Chest, Trapdoor, Huge Brown Mushroom, Huge Red Mushroom, Fence Gate

[edit] 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.

Map Color ID Multiply R,G,B By
Base Color ID*4 + 0 180
Base Color ID*4 + 1 220
Base Color ID*4 + 2 255 (same color)
Base Color ID*4 + 3 220

Here is a map color table provided as an example:

Color Table
ID Color RGB Description
0 Transparent Not explored
1 Transparent Not explored
2 Transparent Not explored
3 Transparent Not explored
4 89,125,39 Grass
5 109,153,48 Grass
6 127,178,56 Grass
7 109,153,48 Grass
8 174,164,115 Sand/Gravel
9 213,201,140 Sand/Gravel
10 247,233,163 Sand/Gravel
11 213,201,140 Sand/Gravel
12 117,117,117 Other
13 144,144,144 Other
14 167,167,167 Other
15 144,144,144 Other
16 180,0,0 Lava/TNT
17 220,0,0 Lava/TNT
18 255,0,0 Lava/TNT
19 220,0,0 Lava/TNT
20 112,112,180 Ice
21 138,138,220 Ice
22 160,160,255 Ice
23 138,138,220 Ice
24 117,117,117 Metal
25 144,144,144 Metal
26 167,167,167 Metal
27 144,144,144 Metal
28 0,87,0 Plants
29 0,106,0 Plants
30 0,124,0 Plants
31 0,106,0 Plants
32 180,180,180 Snow
33 220,220,220 Snow
34 255,255,255 Snow
35 220,220,220 Snow
36 115,118,129 Clay
37 141,144,158 Clay
38 164,168,184 Clay
39 141,144,158 Clay
40 129,74,33 Dirt
41 157,91,40 Dirt
42 183,106,47 Dirt
43 157,91,40 Dirt
44 79,79,79 Stone/Cobblestone/Ore
45 96,96,96 Stone/Cobblestone/Ore
46 112,112,112 Stone/Cobblestone/Ore
47 96,96,96 Stone/Cobblestone/Ore
48 45,45,180 Water
49 55,55,220 Water
50 64,64,255 Water
51 55,55,220 Water
52 73,58,35 Log/Tree/Wood
53 89,71,43 Log/Tree/Wood
54 104,83,50 Log/Tree/Wood
55 89,71,43 Log/Tree/Wood

[edit] Code examples

Library name Language Link to Map-related code
MCModify Java Map.java

[edit] References

Personal tools
Namespaces
Variants
Actions
Minecraft Wiki
Minecraft
Useful pages
Toolbox
In other languages

Recent Community Articles

Mojang Tweets

    Getting your tweets...
Become a Premium Member!