Skip to main content

Chunks

In Cubivox, a world is subdivided into 16x16x16 cube chunks, for a total of 4,096 individual voxels. These chunks serve multiple purposes, but mainly exist for performance reasons (especially with rendering).

Chunks store the actual data for all voxels within them, so setting a voxel through the World class will result in a modification to the chunk that voxel belongs in.

Using Chunks

Chunks can be obtained directly from a World using the World.GetChunk(Location) or World.GetChunk(x, y, z) methods. It is important to note that chunks use a different coordinate system than voxels. For example, a chunk at (1, 0, 1) would actual be at position (16, 0, 16).

Once obtained, the voxels in that chunk can be modified. The chunk can also be completely regenerated by using the WorldGenerator for the world that the chunk is in.

World currentWorld = Cubivox.GetWorlds()[0];
Chunk mainChunk = currentWorld.GetChunk(0, 2, 0);