What is a 'chunk'?

Ok, so I know roughly that a chunk is like a mass of generated terrain in minecraft.
I hear people say 'loading chunks' and I've seen questions about 'chunk errors' so I assume it is part of terrain generation.

My question is: What is the definition of 'chunk' and what is a chunk used for?


Solution 1:

A chunk is 16x16 column of blocks extending from the bottom to the top of the map.

The game generates new land when you explore and the terrain is generated in such chunks. The game also keeps loaded in memory only chunks that are near you. Technically, building the map from chunks is what made possible the "infinite" (for practical purposes) worlds in Minecraft.

There are several different phenomena called 'chunk error':

  • Client-only chunk error - if the client does not receive information for some chunks (because of network communication error) they appear as holes in the ground; usually can be fixed by re-joining on the server or forcing the client to reload the area around the player (F3 + A).
  • Server chunk error - usually if some world files are corrupted - acts like a real hole where you may fall in the void; can be fixed using external (3-rd party) tools.
  • Terrain generation boundary - sharp, straight edges in generated terrain or biomes. Although it is often referred to as 'chunk error', it is not really an error. Here is how it works:
    1. The terrain is generated randomly using a pseudo-random number generator.
    2. The generator is initialized with a number, called the world seed. This number is stored in the level file. Each world seed can be seen as 'key code' for completely different world from the universe of possible worlds.
    3. When the game needs a new chunk, it uses the seed (the 'key code') to create (to 'summon') the chunk. After the chunk is created, it is saved in the world files.
    4. If the 'key code', that is, the seed changes (intentional or not), newly generated chunks are from 'completely different world' (see 2. above).
    5. Whenever the terrain generator changes (like in the upcoming 1.7), this replaces the entire universe of possible worlds so the same 'key code' now refers to completely different world from the new universe.
    6. Either way the terrain and biome of the newly generated chunks does not match with the terrain/biome of the old saved chunks. See this example from the wiki.

For even more information, see the Minkecraft Wiki page on Chunks

Solution 2:

The other answers have very accurately described what a chunk is; a 16x16 column that represents a unit of terrain. Terrain is seeded, loaded and unloaded in these units. I will attempt to answer why they exist at all; as opposed to an amorphous continuum of blocks; loaded and unloaded as necessary.

Why not every block as its own object?

Each independent object that is passed to the graphics card has considerable overhead, its own connection to textures, a decision to render it or not has to be made etc etc. As such its implausible to have each block as its own independent object (I briefly programmed something like this; it was bad). This discounts the everything separate part of the spectrum.

Why not all the blocks together?

The other end of the spectrum is to have all the blocks grouped together as a single object (this would actually feel very similar to every block being separate). This would give the lowest overhead, but has several fatal drawbacks;

  • When you're not looking at something the graphics card can cull it saving resources, if its all one big object then this isn't possible; its all rendered or none of it is
  • Whenever you wanted to change a block (which happens a lot in minecraft) the whole thing would have to be rebuilt in less than one 60th of a second to look convincing and this just isn't possible.

Summary

Chunks are the intermediate position between these two extremes, you cut your number of independent objects down from hundreds of thousands of blocks down to a few hundred chunks but you can still cull parts of the scene you aren't looking at and if a block is added/removed you only need to rebuilt 1% of the scene instead of 100%

Solution 3:

its a 16x16 blocks of land going from bedrock to sky. Minecraft Wiki Chunks