Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.worldgen

Generated

This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.

TypeKindDescription
BiomeDefinitionrecordA biome defined in code.
BiomeDefinition.BuilderclassBuilds a BiomeDefinition.
BiomeSelectorinterfaceChooses biomes: by ID, or by biome tag such as minecraft:is_overworld.
BiomeSelector.ByIdrecord—
BiomeSelector.ByTagrecord—
BiomeSpawnrecordA mob that spawns in a code-defined biome.
CodeFeaturefunctional interfaceA placed feature written in code: a boulder, a plant patch, an ore cluster with a custom shape.
ColumnBuilderinterfaceOne block column being generated; valid only during TerrainGenerator.fillColumn.
FeatureContextinterfaceWhere and with what a CodeFeature places blocks, valid only during CodeFeature.place.
FeaturePlacementrecordWhere a CodeFeature is tried in each chunk: how often, and at which height.
GenerationStepNameenumThe feature placement steps of world generation, in the order the game runs them.
NoiseFunctionfunctional interfaceA density value per block position, used inside the game's noise terrain as a density function (WorldgenRegistrar.densityFunction).
StructureBuilderfunctional interfaceBuilds a code structure's blocks into its box.
StructureDefinitionrecordA structure built in code: a box placed on the terrain surface at the centre of chosen chunks, filled by a StructureBuilder.
StructureDefinition.BuilderclassBuilds a StructureDefinition.
StructurePieceContextinterfaceThe box a StructureBuilder builds in, valid only during StructureBuilder.build.
TerrainGeneratorfunctional interfaceTerrain written in code: fills each block column of new chunks.
WorldgenRegistrarinterfaceChanges world generation.

BiomeDefinition​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record BiomeDefinition(float temperature, float downfall, boolean precipitation, int skyColor, Optional<Integer> fogColor, int waterColor, Optional<Integer> grassColor, Optional<Integer> foliageColor, Map<GenerationStepName,List<ResourceId>> features, List<BiomeSpawn> spawns)

A biome defined in code. Poly Mod Loader writes it as biome data into its generated data pack, so it behaves exactly like a biome from a data pack: dimensions, biome tags, and /locate biome see it. Colours are 0xRRGGBB.

ComponentTypeDescription
temperaturefloataffects snow and grass colour (plains 0.8, snowy plains 0.0)
downfallfloataffects grass and foliage colour (plains 0.4)
precipitationbooleanwhether it rains (or snows when cold)
skyColorintsky colour
fogColorOptional<Integer>fog colour, or the game's default
waterColorintwater colour (plains 0x3f76e4)
grassColorOptional<Integer>grass colour, or computed from temperature and downfall
foliageColorOptional<Integer>leaf colour, or computed
featuresMap<GenerationStepName,List<ResourceId>>placed features per generation step
spawnsList<BiomeSpawn>mobs that spawn naturally

builder()​

public static BiomeDefinition.Builder builder()

Since 0.1.0-alpha.4 or earlier

A builder with plains-like values and no features or spawns.

Returns BiomeDefinition.Builder

BiomeDefinition.Builder​

class · Since 0.1.0-alpha.4 or earlier

public static final class Builder

Builds a BiomeDefinition.

climate(float, float, boolean)​

public BiomeDefinition.Builder climate(float temperature, float downfall, boolean precipitation)

Since 0.1.0-alpha.4 or earlier

Temperature (plains 0.8), downfall (plains 0.4) and whether it rains or snows.

ParameterTypeDescription
temperaturefloat—
downfallfloat—
precipitationboolean—

Returns BiomeDefinition.Builder

skyColor(int)​

public BiomeDefinition.Builder skyColor(int color)

Since 0.1.0-alpha.4 or earlier

Sky colour, 0xRRGGBB.

ParameterTypeDescription
colorint—

Returns BiomeDefinition.Builder

fogColor(int)​

public BiomeDefinition.Builder fogColor(int color)

Since 0.1.0-alpha.4 or earlier

Fog colour, 0xRRGGBB.

ParameterTypeDescription
colorint—

Returns BiomeDefinition.Builder

waterColor(int)​

public BiomeDefinition.Builder waterColor(int color)

Since 0.1.0-alpha.4 or earlier

Water colour, 0xRRGGBB.

ParameterTypeDescription
colorint—

Returns BiomeDefinition.Builder

grassColor(int)​

public BiomeDefinition.Builder grassColor(int color)

Since 0.1.0-alpha.4 or earlier

Grass colour, 0xRRGGBB, instead of one computed from the climate.

ParameterTypeDescription
colorint—

Returns BiomeDefinition.Builder

foliageColor(int)​

public BiomeDefinition.Builder foliageColor(int color)

Since 0.1.0-alpha.4 or earlier

Leaf colour, 0xRRGGBB, instead of one computed from the climate.

ParameterTypeDescription
colorint—

Returns BiomeDefinition.Builder

feature(GenerationStepName, ResourceId)​

public BiomeDefinition.Builder feature(GenerationStepName step, ResourceId placedFeature)

Since 0.1.0-alpha.4 or earlier

Adds a placed feature, such as minecraft:trees_plains, in step.

ParameterTypeDescription
stepGenerationStepName—
placedFeatureResourceId—

Returns BiomeDefinition.Builder

spawn(MobCategory, ResourceId, int, int, int)​

public BiomeDefinition.Builder spawn(MobCategory category, ResourceId type, int weight, int minGroup, int maxGroup)

Since 0.1.0-alpha.4 or earlier

Adds a naturally spawning mob.

ParameterTypeDescription
categoryMobCategory—
typeResourceId—
weightint—
minGroupint—
maxGroupint—

Returns BiomeDefinition.Builder

build()​

public BiomeDefinition build()

Since 0.1.0-alpha.4 or earlier

Creates the definition.

Returns BiomeDefinition

BiomeSelector​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public sealed interface BiomeSelector

Chooses biomes: by ID, or by biome tag such as minecraft:is_overworld.

ids(ResourceId[])​

static BiomeSelector ids(ResourceId... ids)

Since 0.1.0-alpha.4 or earlier

Biomes with one of these IDs.

ParameterTypeDescription
idsResourceId[]—

Returns BiomeSelector

tag(ResourceId)​

static BiomeSelector tag(ResourceId tag)

Since 0.1.0-alpha.4 or earlier

Biomes in this tag.

ParameterTypeDescription
tagResourceId—

Returns BiomeSelector

BiomeSelector.ById​

record · Since 0.1.0-alpha.4 or earlier

public static record ById(Set<ResourceId> ids) implements BiomeSelector
ComponentTypeDescription
idsSet<ResourceId>biome IDs

Supertypes: BiomeSelector

BiomeSelector.ByTag​

record · Since 0.1.0-alpha.4 or earlier

public static record ByTag(ResourceId tag) implements BiomeSelector
ComponentTypeDescription
tagResourceIdbiome tag ID, without #

Supertypes: BiomeSelector

BiomeSpawn​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record BiomeSpawn(MobCategory category, ResourceId type, int weight, int minGroup, int maxGroup)

A mob that spawns in a code-defined biome.

ComponentTypeDescription
categoryMobCategoryspawn group
typeResourceIdentity type, for example minecraft:sheep
weightintchance relative to other mobs of the category
minGroupintsmallest group
maxGroupintlargest group

CodeFeature​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface CodeFeature

A placed feature written in code: a boulder, a plant patch, an ore cluster with a custom shape. Called on world generation threads while chunks generate, possibly for several chunks at once; keep all state in local variables and take randomness only from FeatureContext.random().

place(FeatureContext)​

boolean place(FeatureContext context)

Since 0.1.0-alpha.4 or earlier

Places the feature around FeatureContext.origin().

ParameterTypeDescription
contextFeatureContext—

Returns boolean — whether anything was placed

ColumnBuilder​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ColumnBuilder

One block column being generated; valid only during TerrainGenerator.fillColumn.

minY()​

int minY()

Since 0.1.0-alpha.4 or earlier

Lowest Y of the dimension.

Returns int

maxY()​

int maxY()

Since 0.1.0-alpha.4 or earlier

Highest Y of the dimension (inclusive).

Returns int

seed()​

long seed()

Since 0.1.0-alpha.4 or earlier

A number derived from the world seed and the generator ID, the same for every column.

Returns long

set(int, ResourceId)​

void set(int y, ResourceId block)

Since 0.1.0-alpha.4 or earlier

Sets the default state of block at y; positions outside the dimension are ignored.

ParameterTypeDescription
yint—
blockResourceId—

Throws IllegalArgumentException — for an unknown block

fill(int, int, ResourceId)​

default void fill(int fromY, int toY, ResourceId block)

Since 0.1.0-alpha.4 or earlier

Sets block from fromY to toY, both inclusive.

ParameterTypeDescription
fromYint—
toYint—
blockResourceId—

FeatureContext​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface FeatureContext

Where and with what a CodeFeature places blocks, valid only during CodeFeature.place. The world being generated is the chunk of the origin and its neighbours; keep blocks within 16 blocks of the origin horizontally. Positions are world coordinates.

origin()​

BlockPos origin()

Since 0.1.0-alpha.4 or earlier

The position the placement chose, for example on the surface or at a random height.

Returns BlockPos

random()​

RandomGenerator random()

Since 0.1.0-alpha.4 or earlier

Randomness for this placement; the same world seed and position give the same values.

Returns RandomGenerator

blockAt(BlockPos)​

ResourceId blockAt(BlockPos pos)

Since 0.1.0-alpha.4 or earlier

The block at pos, without properties.

ParameterTypeDescription
posBlockPos—

Returns ResourceId

isAir(BlockPos)​

boolean isAir(BlockPos pos)

Since 0.1.0-alpha.4 or earlier

Whether pos is air.

ParameterTypeDescription
posBlockPos—

Returns boolean

setBlock(BlockPos, ResourceId)​

void setBlock(BlockPos pos, ResourceId block)

Since 0.1.0-alpha.4 or earlier

Sets the default state of block at pos.

ParameterTypeDescription
posBlockPos—
blockResourceId—

Throws IllegalArgumentException — if block is not a block

surfaceY(int, int)​

int surfaceY(int x, int z)

Since 0.1.0-alpha.4 or earlier

The y of the first air block above the terrain at x, z, as generation sees it so far.

ParameterTypeDescription
xint—
zint—

Returns int

minY()​

int minY()

Since 0.1.0-alpha.4 or earlier

The lowest block y of the world.

Returns int

maxY()​

int maxY()

Since 0.1.0-alpha.4 or earlier

The highest block y of the world.

Returns int

FeaturePlacement​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record FeaturePlacement(int countPerChunk, int rarity, boolean onSurface, int minY, int maxY)

Where a CodeFeature is tried in each chunk: how often, and at which height. Poly Mod Loader writes it as the placed feature with the feature's ID, the same as one from a data pack.

ComponentTypeDescription
countPerChunkinttries per chunk, each at a random x and z in the chunk
rarityinteach try happens in 1 of rarity chunks; 1 for every chunk
onSurfacebooleanwhether tries start on the terrain surface; otherwise at a random y in minY..maxY
minYintlowest y for tries below the surface
maxYinthighest y for tries below the surface

onSurface(int)​

public static FeaturePlacement onSurface(int countPerChunk)

Since 0.1.0-alpha.4 or earlier

countPerChunk tries on the surface of each chunk.

ParameterTypeDescription
countPerChunkint—

Returns FeaturePlacement

atHeight(int, int, int)​

public static FeaturePlacement atHeight(int countPerChunk, int minY, int maxY)

Since 0.1.0-alpha.4 or earlier

countPerChunk tries at random heights from minY to maxY in each chunk.

ParameterTypeDescription
countPerChunkint—
minYint—
maxYint—

Returns FeaturePlacement

rarity(int)​

public FeaturePlacement rarity(int rarity)

Since 0.1.0-alpha.4 or earlier

This placement in only 1 of rarity chunks.

ParameterTypeDescription
rarityint—

Returns FeaturePlacement

GenerationStepName​

enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public enum GenerationStepName

The feature placement steps of world generation, in the order the game runs them.

ConstantDescription
RAW_GENERATION—
LAKES—
LOCAL_MODIFICATIONS—
UNDERGROUND_STRUCTURES—
SURFACE_STRUCTURES—
STRONGHOLDS—
UNDERGROUND_ORES—
UNDERGROUND_DECORATION—
FLUID_SPRINGS—
VEGETAL_DECORATION—
TOP_LAYER_MODIFICATION—

NoiseFunction​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface NoiseFunction

A density value per block position, used inside the game's noise terrain as a density function (WorldgenRegistrar.densityFunction). In the game's terrain, positive final density is solid and negative is air or water, so a function can raise, carve or reshape terrain while the game keeps its caves, aquifers, ores, surface rules and biomes.

The game computes noise terrain in cells (noise.size_horizontal × 4 by noise.size_vertical × 4 blocks) and blends the final density inside a cell, so shapes smaller than a cell come out smoothed and a surface may be a block off the exact value.

Called extremely often from several world generation threads at once: it must be fast, keep no state, and give the same value for the same position every time.

compute(int, int, int)​

double compute(int x, int y, int z)

Since 0.1.0-alpha.4 or earlier

The density at block x, y, z.

ParameterTypeDescription
xint—
yint—
zint—

Returns double

StructureBuilder​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface StructureBuilder

Builds a code structure's blocks into its box. Called on world generation threads, once per chunk the box touches (see StructurePieceContext); keep all state in local variables.

build(StructurePieceContext)​

void build(StructurePieceContext context)

Since 0.1.0-alpha.4 or earlier

Writes the structure's blocks through context.

ParameterTypeDescription
contextStructurePieceContext—

StructureDefinition​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record StructureDefinition(int sizeX, int sizeY, int sizeZ, int yOffset, BiomeSelector biomes, int spacing, int separation, GenerationStepName step, boolean adaptTerrain, StructureBuilder builder)

A structure built in code: a box placed on the terrain surface at the centre of chosen chunks, filled by a StructureBuilder. Poly Mod Loader writes the structure and its structure set into the generated data pack, so /locate structure and /place structure work with its ID.

ComponentTypeDescription
sizeXintbox size along x, 1–128
sizeYintbox size along y, 1–256
sizeZintbox size along z, 1–128
yOffsetintwhere the box's bottom is relative to the surface; negative sinks it into the ground
biomesBiomeSelectorwhere it may generate
spacingintaverage distance between structures, in chunks (village 34)
separationintminimum distance between structures, in chunks; less than spacing
stepGenerationStepNamethe generation step it is built in
adaptTerrainbooleanwhether the terrain is smoothed around it, like around a village
builderStructureBuilderbuilds its blocks

builder(int, int, int, StructureBuilder)​

public static StructureDefinition.Builder builder(int sizeX, int sizeY, int sizeZ, StructureBuilder builder)

Since 0.1.0-alpha.4 or earlier

A builder for a sizeX × sizeY × sizeZ structure built by builder.

ParameterTypeDescription
sizeXint—
sizeYint—
sizeZint—
builderStructureBuilder—

Returns StructureDefinition.Builder

StructureDefinition.Builder​

class · Since 0.1.0-alpha.4 or earlier

public static final class Builder

Builds a StructureDefinition.

yOffset(int)​

public StructureDefinition.Builder yOffset(int yOffset)

Since 0.1.0-alpha.4 or earlier

Raises (or with a negative value sinks) the box relative to the surface; 0 by default.

ParameterTypeDescription
yOffsetint—

Returns StructureDefinition.Builder

biomes(BiomeSelector)​

public StructureDefinition.Builder biomes(BiomeSelector biomes)

Since 0.1.0-alpha.4 or earlier

Where it may generate; every overworld biome (#minecraft:is_overworld) by default.

ParameterTypeDescription
biomesBiomeSelector—

Returns StructureDefinition.Builder

spacing(int, int)​

public StructureDefinition.Builder spacing(int spacing, int separation)

Since 0.1.0-alpha.4 or earlier

Average and minimum distance between structures in chunks; 32 and 8 by default.

ParameterTypeDescription
spacingint—
separationint—

Returns StructureDefinition.Builder

step(GenerationStepName)​

public StructureDefinition.Builder step(GenerationStepName step)

Since 0.1.0-alpha.4 or earlier

The generation step; GenerationStepName.SURFACE_STRUCTURES by default.

ParameterTypeDescription
stepGenerationStepName—

Returns StructureDefinition.Builder

adaptTerrain()​

public StructureDefinition.Builder adaptTerrain()

Since 0.1.0-alpha.4 or earlier

Smooths the terrain around the box, like around a village.

Returns StructureDefinition.Builder

build()​

public StructureDefinition build()

Since 0.1.0-alpha.4 or earlier

Creates the definition; invalid values throw IllegalArgumentException.

Returns StructureDefinition

StructurePieceContext​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface StructurePieceContext

The box a StructureBuilder builds in, valid only during StructureBuilder.build. Coordinates are relative to the box's lowest corner, from 0 to size - 1 on each axis; blocks outside the box are ignored.

A structure larger than one chunk is built chunk by chunk: the builder is called once for each chunk the box touches, with the same random() sequence each time, and only the blocks in that chunk are written. Build the same structure on every call.

origin()​

BlockPos origin()

Since 0.1.0-alpha.4 or earlier

World position of the box's lowest corner.

Returns BlockPos

sizeX()​

int sizeX()

Since 0.1.0-alpha.4 or earlier

Box size along x.

Returns int

sizeY()​

int sizeY()

Since 0.1.0-alpha.4 or earlier

Box size along y.

Returns int

sizeZ()​

int sizeZ()

Since 0.1.0-alpha.4 or earlier

Box size along z.

Returns int

random()​

RandomGenerator random()

Since 0.1.0-alpha.4 or earlier

Randomness for this structure; the same on every call for the same structure.

Returns RandomGenerator

blockAt(int, int, int)​

ResourceId blockAt(int x, int y, int z)

Since 0.1.0-alpha.4 or earlier

The block at a box position, without properties.

ParameterTypeDescription
xint—
yint—
zint—

Returns ResourceId

setBlock(int, int, int, ResourceId)​

void setBlock(int x, int y, int z, ResourceId block)

Since 0.1.0-alpha.4 or earlier

Sets the default state of block at a box position.

ParameterTypeDescription
xint—
yint—
zint—
blockResourceId—

Throws IllegalArgumentException — if block is not a block

fill(int, int, int, int, int, int, ResourceId)​

default void fill(int x1, int y1, int z1, int x2, int y2, int z2, ResourceId block)

Since 0.1.0-alpha.4 or earlier

Fills the box positions from (x1, y1, z1) to (x2, y2, z2), both included.

ParameterTypeDescription
x1int—
y1int—
z1int—
x2int—
y2int—
z2int—
blockResourceId—

TerrainGenerator​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface TerrainGenerator

Terrain written in code: fills each block column of new chunks. Registered with WorldgenRegistrar.chunkGenerator, it is used by dimensions in data packs with "generator": {"type": "<mod id>:<path>", "biome_source": {...}}. Biome features (ores, trees) and structures are added afterwards by the game as for any generator.

Threads: called on the game's world generation threads, several columns at once; the code must be thread-safe and give the same column for the same position and seed.

fillColumn(int, int, ColumnBuilder)​

void fillColumn(int x, int z, ColumnBuilder column)

Since 0.1.0-alpha.4 or earlier

Fills the column at world position x, z; unset blocks stay air.

ParameterTypeDescription
xint—
zint—
columnColumnBuilder—

seaLevel()​

default int seaLevel()

Since 0.1.0-alpha.4 or earlier

Sea level of dimensions using this generator; the game spawns water mobs and fish below it.

Returns int

WorldgenRegistrar​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface WorldgenRegistrar

Changes world generation. The features themselves are data: put data/<mod id>/worldgen/configured_feature/*.json and placed_feature/*.json in the mod jar, in the game's format. Custom dimensions are data too (dimension/, dimension_type/). This registrar attaches placed features to existing biomes, which data alone cannot do without replacing the biome files.

When: common entrypoints. Applied every time a server loads its worlds; affects chunks generated afterwards.

addFeature(BiomeSelector, GenerationStepName, ResourceId)​

void addFeature(BiomeSelector biomes, GenerationStepName step, ResourceId placedFeature)

Since 0.1.0-alpha.4 or earlier

Adds a placed feature at the end of step in every selected biome.

ParameterTypeDescription
biomesBiomeSelector—
stepGenerationStepName—
placedFeatureResourceIdID of a placed feature from any data pack, for example the mod's own

chunkGenerator(String, TerrainGenerator)​

ResourceId chunkGenerator(String path, TerrainGenerator generator)

Since 0.1.0-alpha.4 or earlier

Registers terrain written in code as generator type <mod id>:<path>, for dimensions in data packs.

ParameterTypeDescription
pathString—
generatorTerrainGenerator—

Returns ResourceId — the generator type ID

Throws IllegalArgumentException — for an invalid or used path (POLY-WORLDGEN-001)

biome(String, BiomeDefinition)​

ResourceId biome(String path, BiomeDefinition definition)

Since 0.1.0-alpha.4 or earlier

Defines biome <mod id>:<path> in code. Use it in dimensions and biome tags like a biome from a data pack.

ParameterTypeDescription
pathString—
definitionBiomeDefinition—

Returns ResourceId — the biome ID

feature(String, FeaturePlacement, CodeFeature)​

ResourceId feature(String path, FeaturePlacement placement, CodeFeature feature)

Since 0.1.0-alpha.4 or earlier

Registers a feature written in code as feature type <mod id>:<path>, and writes a configured and a placed feature with the same ID into Poly Mod Loader's generated data pack. Add it to biomes with addFeature, place it with /place feature <id>, or use the type in the mod's own data pack.

ParameterTypeDescription
pathString—
placementFeaturePlacement—
featureCodeFeature—

Returns ResourceId — the feature ID

Throws IllegalArgumentException — for an invalid or used path (POLY-WORLDGEN-004)

densityFunction(String, double, double, NoiseFunction)​

ResourceId densityFunction(String path, double minValue, double maxValue, NoiseFunction function)

Since 0.1.0-alpha.4 or earlier

Registers a density function written in code as type <mod id>:<path>. Data packs use it inside the game's noise terrain, for example in a noise settings' final_density: {"type": "minecraft:add", "argument1": …, "argument2": {"type": "<mod id>:<path>"}}.

ParameterTypeDescription
pathString—
minValuedoublethe lowest value function returns; the game uses the bounds to skip work
maxValuedoublethe highest value function returns
functionNoiseFunction—

Returns ResourceId — the density function type ID

Throws IllegalArgumentException — for an invalid or used path (POLY-WORLDGEN-004) or minValue > maxValue

structure(String, StructureDefinition)​

ResourceId structure(String path, StructureDefinition definition)

Since 0.1.0-alpha.4 or earlier

Registers a structure built in code as <mod id>:<path>, with its structure set, in Poly Mod Loader's generated data pack. It generates in new chunks of the selected biomes; /locate structure and /place structure find and place it.

ParameterTypeDescription
pathString—
definitionStructureDefinition—

Returns ResourceId — the structure ID

Throws IllegalArgumentException — for an invalid or used path (POLY-WORLDGEN-004)

Buy me a coffee