WorldGenSpec class
A whole world described as data: its terrain, biomes, ores, caves and structures, with blocks named by string. compile turns it into a ChunkGenerator against a game's block ids.
const world = WorldGenSpec(
biomes: [
Biome('desert', top: 'sand', under: 'sand', climate: Climate.hotDry),
Biome('plains', top: 'grass', under: 'dirt',
trees: [TreeSpec.oak(log: 'log', leaves: 'leaves')], treeChance: 20),
],
strata: [Stratum('deepslate', belowY: 22)],
ores: [Ore('coal_ore', share: 0.11)],
structures: [StructureSpec('well', Well(rim: 'cobblestone', water: 'water', posts: 'fence', roof: 'planks'))],
);
A world with a cavern has a roof: the underworld a portal leads to. A world with a plaza has a square of it pressed flat: a showroom's floor.
A spec is plain data plus pure callbacks, so it crosses to the worker
isolates: build the generator factory as () => spec.compile(ids, seed)
in a static or top-level function, never in a method that could capture
this.
Constructors
-
WorldGenSpec({required List<
Biome> biomes, int seaLevel = 46, TerrainRecipe terrain = const TerrainRecipe(), String stone = 'stone', String water = 'water', String? bedrock, Biome? ocean, Biome? beach, List<Biome> shores = const [], List<Stratum> strata = const [], List<Ore> ores = const [], CaveSpec caves = const CaveSpec(), List<StructureSpec> structures = const [], CavernSpec? cavern, Plaza? plaza}) -
A world.
biomesare tried in order and the first whose Climate matches a column wins; the last one is the fallback, whatever its climate.oceanandbeachtake the columns below and just aboveseaLevelwhen given, andshoresthe beach's where their climate holds. With acavernthe world is a roofed slab ofstoneinstead (see CavernSpec).const
Properties
-
allBiomes
→ List<
Biome> -
Every biome of the world: the land's, the shores, the ocean and the
beach.
no setter
- beach → Biome?
-
The biome of the shore (at most one block above seaLevel).
final
- bedrock → String?
-
The block at y 0, or null for stone.
final
-
biomes
→ List<
Biome> -
Land biomes, tried in order; at least one.
final
-
blockNames
→ Set<
String> -
Every block name the spec uses, so a game can check its table has them.
no setter
- cavern → CavernSpec?
-
The roof and floor of a world that is one great cave, or null for open
sky over terrain.
final
- caves → CaveSpec
-
Caves.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- ocean → Biome?
-
The biome under the sea (more than two blocks below seaLevel).
final
-
ores
→ List<
Ore> -
Ores, tried in order.
final
- plaza → Plaza?
-
A square of open-sky ground pressed flat, or null for none.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seaLevel → int
-
Water fills every open cell up to this height.
final
-
shores
→ List<
Biome> -
Shores of their own, tried in order on the beach's columns (from two
blocks under seaLevel to one over it): the first whose Climate holds
takes the column, else the beach does (or, with none, the land biomes).
A frozen shore is a cold one whose sea freezes:
final
- stone → String
-
The rock under every biome's soil.
final
-
strata
→ List<
Stratum> -
The rock by depth, tried in order: a cell of rock below a stratum's
belowYis its block instead of stone. Ores vein it as they do stone.final -
structures
→ List<
StructureSpec> -
Structures, each on its own grid, tried in order: a site within reach of
an earlier structure's is dropped, so two never overlap.
final
- terrain → TerrainRecipe
-
How high the ground stands.
final
- water → String
-
What fills the sea.
final
Methods
-
compile(
Map< String, int> ids, int seed) → SpecGenerator -
The generator of this world for
seed, resolving block names throughids. Throws ArgumentError naming the first blockidslacks. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
withPlaza(
Plaza? plaza) → WorldGenSpec -
This world with
plazapressed into it (none when null): the same world as a showroom.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited