Take the 2-minute tour ×
Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

Minecraft worlds are huge; supposedly, nearly 130 quadrillion blocks. (Zoom out a little on that site and you'll see it.) Anyways, I looked in the Save folder (C:\Users\username\AppData\Roaming.minecraft\saves), and the world I'm currently playing in has a folder of the same name as my world. This folder is only 12 Mb. Does Minecraft really store 130 quadrillion blocks in 12 Mb, or is there some kind of insane level encoding going on? Even if there is crazy encoding ("Saving chunks", whatever that means) in the game itself, one does not simply fit 130 quadrillion blocks into well under one gigabyte of physical memory.

How does Minecraft store world data? As a programmer, I understand tilemaps that represent 1 or more blocks (in a 2D sense) per byte, and world data of that sort, but I can simply not wrap my mind around how 130 quadrillion blocks take up so little memory.

share|improve this question
4  
check out the wiki on it minecraftwiki.net/wiki/Anvil_file_format chunks are explained here –  ratchet freak Jun 15 '12 at 1:18

4 Answers 4

There is not 130 quadrillion blocks in a typical world save. The world is generated as needed and only the areas that are generated are saved. This means you are only saving a handful of chunks. A chunk in Minecraft is an area 16 x 16 x world height blocks in size (currently 65536 blocks, previously 32768).

share|improve this answer
    
But theoretically, you will eventually explore all 130 quadrillion blocks, right? Obviously that would take hundreds of hours, but never mind that. Would the level data in that case just be massive? –  Lincoln Bergeson Jun 14 '12 at 23:01
    
@LincolnBergeson: Yep. But exploring the entire minecraft world isn't physically possible without some mod to speed you up or something in that vein. –  Matthew Scharley Jun 14 '12 at 23:03
1  
@LincolnBergeson: Now you're getting into the realm of gamedev.SE. I'm not 100% on the internals, but I do know that Minecraft loads and unloads a certain number of chunks around you (10[?]), which is slightly further than you can see. That would take care of the lighting issues, etc. –  Matthew Scharley Jun 14 '12 at 23:06
1  
@LincolnBergeson: A region is just another delineation of an area. You can think of it as a group of chunks, where a chunk is a group of blocks. Specifically, a region is a group of 16x16 chunks. –  Matthew Scharley Jun 15 '12 at 1:55
1  
@LincolnBergeson - Just because nobody else addressed this quite this explicitly, YES the world file would be massive (measured in gigabytes if not terabytes) if you generated every possible chunk. However, there's no feasible way to do that in the game in a human lifetime. –  Shinrai Jun 15 '12 at 14:26

Bear in mind that Minecraft almost certainly stores its world data using some form of compression, such as RLE (Run Length Encoding), which represents a string of identical blocks as (R16,A65,R1,W15), which basically says:

The next 16 blocks of the array are rock, followed by 65 blocks of air, followed by one block of rock, followed by 15 blocks of water... and so on.

Given the huge swaths of homogeneous material typically generated in a Minecraft chunk (especially up in the air), this sort of format can vastly reduce the amount of space needed to store it. Player construction will tend to chop up this space and make it less efficient by creating complex arrays of blocks and spaces - but even so in most places it would require vastly less storage space to represent the average chunk this way.

There are additional optimizations you could employ, but this is probably the simplest and most straightforward for a world like Minecraft.

share|improve this answer
1  
The save file format is well documented. It uses Zlib to compress block data within chunks, which uses the same compression algorithm as Zip archives and PNG images. –  SevenSidedDie Oct 25 '13 at 17:46

The entire world is generated using seed values. Only user modified block data is stored as well as the seed. In my engine, I have what's called a region. It is composed of 16x16x16 chunks which are 16x16x16 cubes. 4096 cubes per chunk, 4096 chunks per region. An algorithm determines which faces of the cubes are visible and adds them to a vertex buffer. Only chunks within view are built. To generate an endless world chunks are recycled and built as you move. The number of chunks never changes. Cubes are stored as a byte array allowing you to have 255 block types. No other data is stored since face normals and other things are done programatically. A perlin noise and perlin worm algorithm are used to generate new world data as you move using the seed values. Hope this helps someone.

share|improve this answer
1  
This isn't entirely correct. Chunks are saved as soon as they're generated. Otherwise, updating your world to a version that changed land generation would change your entire world. –  MBraedley Jun 27 at 19:26

It is not 130 quadrillion because the sky limit is 42 blocks and the ground limit is 50 and the land limit is 136x2(both sides)do the math not 130 quadrillion (38841600 blocks)

share|improve this answer
1  
World size has changed several times over Minecrafts life, and 'limits' are only enforced by certain world generators. The numbers are large and irrelevant to the question, given the observed filesize. Also, 'air' is still a block: specifically, it's a lack of a block. That emptiness still needs to be stored in some format, and Minecraft does (air is block id 0). –  Matthew Scharley Jun 15 '12 at 0:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.