Use this file to discover all available pages before exploring further.
This page walks you through three progressively complex programs that cover the most common cubiomes use cases. Each example is self-contained and can be compiled directly inside your cubiomes working directory after building the library.Every program follows the same basic pattern: create a Generator, call setupGenerator() with a Minecraft version and flags, then call applySeed() to bind a specific seed and dimension before querying biomes or structures.
This program iterates over seeds until it finds one that places a Mushroom Fields biome at block coordinates (0, 63, 0) in a Minecraft 1.18 Overworld.
1
Write the program
Save the following as find_biome_at.c in the cubiomes directory:
find_biome_at.c
// check the biome at a block position#include "generator.h"#include <stdio.h>int main(){ // Set up a biome generator that reflects the biome generation of // Minecraft 1.18. Generator g; setupGenerator(&g, MC_1_18, 0); // Seeds are internally represented as unsigned 64-bit integers. uint64_t seed; for (seed = 0; ; seed++) { // Apply the seed to the generator for the Overworld dimension. applySeed(&g, DIM_OVERWORLD, seed); // To get the biome at a single block position, we can use getBiomeAt(). int scale = 1; // scale=1: block coordinates, scale=4: biome coordinates int x = 0, y = 63, z = 0; int biomeID = getBiomeAt(&g, scale, x, y, z); if (biomeID == mushroom_fields) { printf("Seed %" PRId64 " has a Mushroom Fields biome at " "block position (%d, %d).\n", (int64_t) seed, x, z); break; } } return 0;}
2
Compile and run
gcc find_biome_at.c libcubiomes.a -fwrapv -lm
Expected output:
Seed 262 has a Mushroom Fields biome at block position (0, 0).
getBiomeAt() accepts scale=1 for block coordinates or scale=4 for biome coordinates. Use scale=4 when you don’t need sub-chunk precision — it is faster for noise-based generators.
For large areas, genBiomes() is much faster than calling getBiomeAt() for each cell individually. This is especially true for the layered generators used in versions up to 1.17, which can apply transformations in bulk across an entire range.This program generates a 120×120 region at 1:16 (chunk) scale centered on the origin, then saves it as a PPM image.
1
Write the program
Save the following as gen_biomes.c in the cubiomes directory:
gen_biomes.c
// generate an image of the world#include "generator.h"#include "util.h"int main(){ Generator g; setupGenerator(&g, MC_1_18, LARGE_BIOMES); uint64_t seed = 123LL; applySeed(&g, DIM_OVERWORLD, seed); Range r; // 1:16, a.k.a. horizontal chunk scaling r.scale = 16; // Define the position and size for a horizontal area: r.x = -60, r.z = -60; // position (x,z) r.sx = 120, r.sz = 120; // size (width,height) // Set the vertical range as a plane near sea level at scale 1:4. r.y = 15, r.sy = 1; // Allocate the necessary cache for this range. int *biomeIds = allocCache(&g, r); // Generate the area inside biomeIds, indexed as: // biomeIds[i_y*r.sx*r.sz + i_z*r.sx + i_x] // where (i_x, i_y, i_z) is a position relative to the range cuboid. genBiomes(&g, biomeIds, r); // Map the biomes to an image buffer, with 4 pixels per biome cell. int pix4cell = 4; int imgWidth = pix4cell*r.sx, imgHeight = pix4cell*r.sz; unsigned char biomeColors[256][3]; initBiomeColors(biomeColors); unsigned char *rgb = (unsigned char *) malloc(3*imgWidth*imgHeight); biomesToImage(rgb, biomeColors, biomeIds, r.sx, r.sz, pix4cell, 2); // Save the RGB buffer to a PPM image file. savePPM("map.ppm", rgb, imgWidth, imgHeight); // Clean up. free(biomeIds); free(rgb); return 0;}
2
Compile and run
gcc gen_biomes.c libcubiomes.a -fwrapv -lm
Running the program writes map.ppm to the current directory — a color-coded biome map of seed 123 around the origin.
The supported scale values for a Range are 1, 4, 16, 64, and (Overworld only) 256. For versions up to 1.17, the scale selects the matching biome layer and affects which biomes can appear in the output.
Structure generation is a two-stage process: first find where Minecraft attempts to place the structure (getStructurePos()), then verify the biomes are viable at that position (isViableStructurePos()). The position check depends only on the lower 48 bits of the seed, so you can filter out the vast majority of seeds before doing the more expensive biome check.This program finds the first seed that places a Pillager Outpost inside the origin chunk.
1
Write the program
Save the following as find_structure.c in the cubiomes directory:
find_structure.c
// find a seed with a certain structure at the origin chunk#include "finders.h"#include <stdio.h>int main(){ int structType = Outpost; int mc = MC_1_18; Generator g; setupGenerator(&g, mc, 0); uint64_t lower48; for (lower48 = 0; ; lower48++) { // The structure position depends only on the region coordinates and // the lower 48-bits of the world seed. Pos p; if (!getStructurePos(structType, mc, lower48, 0, 0, &p)) continue; // Look for a seed with the structure at the origin chunk. if (p.x >= 16 || p.z >= 16) continue; // Look for a full 64-bit seed with viable biomes. uint64_t upper16; for (upper16 = 0; upper16 < 0x10000; upper16++) { uint64_t seed = lower48 | (upper16 << 48); applySeed(&g, DIM_OVERWORLD, seed); if (isViableStructurePos(structType, &g, p.x, p.z, 0)) { printf("Seed %" PRId64 " has a Pillager Outpost at (%d, %d).\n", (int64_t) seed, p.x, p.z); return 0; } } }}
2
Compile and run
gcc find_structure.c libcubiomes.a -fwrapv -lm
Some structures — including desert pyramids, jungle temples, and woodland mansions — can also fail to generate based on terrain height near the attempt position. cubiomes does not model block-level terrain, so isViableStructurePos() may return false positives for these structure types.