Chunk

A chunk is a 256 block tall 16×16 segment of a Minecraft world. Chunks are the method used by the world generator to divide maps into manageable pieces.

Generation
Chunks are 16 blocks wide, 16 blocks long, and 256 blocks high, which is 65,536 blocks total. Chunks are generated around players when they first enter the world. As they wander around the world, new chunks are generated as needed.

Chunks are generated with the help of the map seed, which means that the chunks are always the same if you would use the same seed again, as long as the map generator and version number remain the same.

Chunk loading
Since minecraft worlds are "infinite" and contain extreme amount of chunks, the game only loads certain chunks in order to make the game playable.

Unloaded chunks are unprocessed by the game and do not process any of the game aspects.

Tickets
Loading starts when chunk recieves ticket. All loaded chunks originate from ticket.

Each load ticket have 3 properties: Level, Ticket type and (optionally) Time to Live.

Level and load type
Levels are numbers that determine what load type the chunk is.

Load levels range from 22 to 44 in regular gameplay while only 22 to 33 are relevant. Technically, lower load levels than 22 are possible (but not without a modded game). Load levels above 44 are not possible.

For a given chunk, only its lowest-level ticket matters. (Lower levels = higher load type.)

Not all loaded chunks have same properties and are divided into 4 load types. This excludes unloaded chunks.

Level propagation
Load levels "propagate" or flow from scource chunk with ticket to neighbouring chunks, but each time it increases its level by 1 until the maximum of 44 is reached.

The chunks that get load level from level expansion activate assigned load type.

Idle timeout
Each dimension has its own idle timeout. If there are players or forceloaded chunks in the dimension, the timeout is disabled. When player leaves or enters dimension, the timeout is reset.

If the timeout reaches 300 ticks, the dimension will stop processing certain actions. These include entity processing, ender dragon fight will stop and global entities (lightning and weather).

Ticket types
Different ticket types from different scources to activate chunks with different load levels.

Player ticket
Ticket created by player. It has level of 31 so its propagation can be seen in the table above.

This ticket is given to each chunk that is in the server/player´s render distance.

In multiplayer each player load its own set of chunks which can result in lag.

Forced ticket
Ticket created by using the forceload command. It has level of 31 so its propagation can be seen in the table above.

Chunks remain forceloaded even after closing and opening the game.

Start ticket
Ticket created by the world spawn chunk (so called "spawn chunks"). It has level of 22, the lowest in the game. They are active whenever player is in the overworld and are otherwise permanently active.

Portal ticket
Ticket created when entity is teleported trought nether portal, given to chunk at the other side of the portal. It has level of 30, so it is stronger that player/forceloaded ticket.

It expire after 300 ticks (without lag equivalent to 15 seconds). Because they are created each time entity passes trought the portal, it is possible to create "chunk loader" but it can create lag.

Dragon ticket
Ticket created at the start of the battle with ender dragon and is given to the 0,0 chunk (the one with exit portal). It has level of 24.

It expires after no more players participate in the battle or the dragon dies.

Post-teleport ticket
Ticket created when entity is teleported either by going trought the end portal and using teleport or spreadplayers commands. For the teleport command, it has level of 32 whereas for the spreadplayers and end portal it has level of 33.

It expires after 5 ticks.

Unknown ticket
Ticket created when arbitrary piece of game code calls "getChunk". If the game code says the chunk should be loaded, it places this ticket on that chunk (after possibly creating it).

The load level depends on what kind of chunk the game attempts to load (a fully world-generated chunk or not). It will be at least 33 (border), but in many cases it could beyond 33, which will involve world-generation in some way.

As an example, when generic mob wandering AI is executing, it asks if a certain block has a solid top surface. As part of that check, that chunk will have an "unknown" ticket with level 33 placed on it.

It expires after 1 tick.

Light ticket
Unknown, possibly world-generation releated.

Ticking area
Ticking area are chunks that are kept loaded using Commands/tickingarea.

Slime chunks
Slime chunks are specific chunks capable of spawning Slimes bellow Y=40 regardless of Light. These chunks are otherwise same as all other chunks.

Slime chunks generate throughout the world (except in mushroom islands). 1 in 10 of all chunks is slime chunk. These slime chunks are determined pseudo-randomly by combining their chunk coordinates with the seed of the world: Random rnd = new Random(   seed +    (int) (xPosition * xPosition * 0x4c1906) +    (int) (xPosition * 0x5ac0db) +     (int) (zPosition * zPosition) * 0x4307a7L +    (int) (zPosition * 0x5f24f) ^ 0x3ad8025f ); return rnd.nextInt(10) == 0; That is, using the chunk coordinates to help generate a seed, a random number between 0 and 9 inclusive is generated, and if that number is 0, the chunk can spawn slimes. To convert world coordinates to chunk coordinates, divide by 16 and round down. Note that are 32-bit integers ( int s).

Bedrock Edition
The slime chunk algorithm $$ is different from $$. The algorithm doesn't depend on the world seed, thus the chunks that slimes can naturally spawn in are the same for every world.

Finding chunk edges


The key can be used to display chunk boundaries.

Alternately, pressing the "F3" button opens the Debug screen that shows the player's X, Y, and Z coordinates, in addition to the "c" variable. These coordinates change as the player moves around. The player can know the chunk they are in by the variable "c" that is next to both "x" and "z" variables. The number in the brackets specifies how far the player is from the north-western corner of the chunk, so if the "c" beside X was 3(5), and the "c" beside Z was 2(4), then the player is on chunk (3, 2), and is on block (5, 4) from the north-western corner.

X and Z coordinates that are divisible by 16 represent the boundaries between chunks. EG: (96, -32) is a corner where four chunks meet. One of those chunks is between X coordinates 80 to 96 and Z coordinates -48 to -32. Another one is between X coordinates 96 to 112 and Z coordinates -32 to -16, and so on. When either X or Z crosses a multiple of 16, the player is moving across chunks.

Essentially, the player is in the top-left corner (north-western) of a chunk when both x and z coordinates are divisible by 16.

Additionally, the player can know the chunk they are on by this formula: The X of chunk is Floor( X coordinate / 16 ) The Z of chunk is Floor( Z coordinate / 16 ) Where Floor is the largest previous integer. E.g. Floor( 27.9561 ) is 27 In other words if X was 27, Z was -15 the chunk is chunk ( Floor( 27 / 16 ), Floor( -15 / 16 ) ), meaning that the player is on chunk (1, -1) Also, The player can know how far he is from the north-western corner by this formula: (X or Z coordinate) AND 15

In Bedrock Edition, when toggling fancy graphics, the world renders again, loading only the chunk the player is in for a split second, briefly showing the chunk boundaries. When the player changes the render distance rapidly, chunk barriers appear as a blue line.

Trivia

 * There are a possible fourteen trillion (14,062,500,000,000) real chunks that can be generated. There are 7.46&times;10244,700 possible chunks, excluding entities.
 * If a player stands in a chunk that has not generated yet, the world immediately becomes invisible until they are in a valid chunk. This does not happen if the Y coordinates are beyond the chunk boundaries.
 * $$, if one of the sixteen 16×16×16 sections of a chunk doesn't have any blocks in it, placing a block there shows the same animation as a chunk loading. This bug makes the block that the player placed turn to the same color of the sky in the direction the player is facing for about 1 second and starts fading away into the normal block texture. If the time is sunrise or sunset and the player places a block there, it actually changes colors constantly for 1 second if the player keeps bobbing their head up and down. The block also makes blocks behind it appear invisible.
 * Placing or destroying a block in an unloaded chunk usually reloads it.