When you need biome data for a rectangular area — to render a map, scan a region for structures, or filter seeds —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Cubitect/cubiomes/llms.txt
Use this file to discover all available pages before exploring further.
genBiomes is far more efficient than calling getBiomeAt for each position individually. For the layered generators used in versions up to 1.17 the speedup can be dramatic, because the layer stack can propagate intermediate results across the whole area instead of recomputing them per point. Even for the 1.18+ noise-based generator, a single genBiomes call avoids repeated function-call overhead and lets the compiler optimise the inner loop.
The Range struct
Before calling genBiomes you must describe the volume you want to generate using a Range:
| Field | Description |
|---|---|
scale | Horizontal scale factor. One cell = scale blocks. Supported values: 1, 4, 16, 64, 256 (256 is Overworld only). |
x, z | Top-left corner of the area in scaled coordinates. |
sx, sz | Width and depth of the area in cells. |
y | Vertical origin in biome coordinates (always 1:4, regardless of scale), except when scale == 1 where vertical is also 1:1. |
sy | Number of vertical layers. Use 1 for a flat 2D map. |
The
y field is in biome coordinates (1:4 scale) for all scale values except scale=1, where it is in block coordinates. For a surface map near sea level, use r.y = 15 (biome coords ≈ y=60 blocks) when scale > 1, or r.y = 63 when scale = 1.Supported scale values
The scale you choose affects both resolution and, for versions ≤ 1.17, which biome layer is sampled:| Scale | Blocks per cell | Layer (≤ 1.17) | Notes |
|---|---|---|---|
1 | 1 × 1 | Voronoi (1:1) | Full resolution; slowest |
4 | 4 × 4 | River Mix (1:4) | Native biome resolution |
16 | 16 × 16 | Shore (1:16) | One sample per chunk |
64 | 64 × 64 | Rare Biome (1:64) | Coarse overview |
256 | 256 × 256 | Biome (1:256) | Overworld only |
Allocating the cache
UseallocCache to obtain a correctly-sized int buffer:
allocCache calls malloc internally; you must free the buffer when done. The buffer is indexed as:
(i_x, i_y, i_z) is a position relative to the range cuboid, i.e. i_x runs from 0 to r.sx - 1.
Generating biomes
genBiomes returns 0 and fills biomeIds according to the index formula above. You must have called applySeed before this call.
Complete example: rendering a world map
The following program is taken directly from the cubiomes README. It generates a 120×120 area at 1:16 scale, maps the biome IDs to colours, and saves the result as a PPM image.The LARGE_BIOMES flag
Passing LARGE_BIOMES as the flags argument to setupGenerator replicates the world-type of the same name: biomes are roughly 4× larger. The rest of the API is unchanged — you use the same Range, the same genBiomes call, and the same index formula.
0 (or combine flags with bitwise OR if needed).
Utility functions from util.h
The util.h header provides helpers for turning the raw biome ID buffer into a visual output:
initBiomeColors
initBiomeTypeColors fills the same table with colours based on biome category instead.
biomesToImage
biomeIds array into an RGB pixel buffer. pixscale sets the number of pixels per biome cell (4 in the example above). flip=2 flips the image vertically to match the typical map orientation where north (negative Z) is at the top.
savePPM
0 on success, -1 if the file could not be opened, or 1 if the write was incomplete.
Workflow overview
Set up and seed the generator
Call
setupGenerator once, then applySeed for each seed you want to render.Define the Range
Set
r.scale, r.x, r.z, r.sx, r.sz, r.y, and r.sy to describe the cuboid you want to generate.Generate biomes
Call
genBiomes(&g, biomeIds, r). On success the buffer is filled; access cells via biomeIds[i_y*r.sx*r.sz + i_z*r.sx + i_x].Performance notes
Performance notes
genBiomes uses all available optimisations for the chosen generator and scale. For the layered generators (≤ 1.17) it generates the entire area through each layer in a single pass, which is substantially faster than calling getBiomeAt per cell — especially at coarse scales where intermediate layers cover large areas cheaply.For the noise-based generator (1.18+) the benefit is smaller but still meaningful at large sx/sz values. If you are scanning millions of seeds, prefer a coarser scale for the initial filter and only refine with scale=1 on candidates.Query a single position
Use
getBiomeAt when you only need the biome at one coordinate.Filter seeds by biome requirements
Use
checkForBiomes to efficiently reject seeds that cannot contain the biomes you need.