3D biomes
This commit is contained in:
@@ -202,7 +202,7 @@ ctx.player.is_swimming(); // see ../entities/players.md#swimming
|
||||
ctx.player.biome; // and ctx.player.season, see ../worldgen/biomes.md#seasons
|
||||
ctx.world.get_block(x, y, z); // a block id, what this client sees
|
||||
ctx.world.get_client_data<number>(x, y, z, "speed"); // see ../blocks/tiledata.md#client-data, a copy
|
||||
ctx.world.biome_at(x, z); // and ctx.world.season_at(x, z), undefined where nothing's loaded
|
||||
ctx.world.biome_at(x, y, z); // and ctx.world.season_at(x, y, z), undefined where nothing's loaded
|
||||
ctx.world.time; // see Time
|
||||
ctx.world.min_y; // and ctx.world.max_y, see ../worldgen/terrain.md#height
|
||||
ctx.items.ids(); // every item, in load order
|
||||
|
||||
@@ -4,8 +4,14 @@ A biome says what the ground looks like where it's picked: the blocks on top, th
|
||||
tinted, which trees grow, and whether it has a season of its own. Biomes are data, one file each in a mod's
|
||||
`worldgen/biomes/` folder. The base game's are in `mods/bworld/worldgen/biomes/`.
|
||||
|
||||
Which biome a column gets is up to the generator's biome rules, from the column's climate and height. A mod's biome
|
||||
generates where a rule it adds puts it, see [Adding Biomes](terrain.md#adding-biomes).
|
||||
Which biome a place gets is up to the generator's biome rules, from the column's climate, the ground's height and how
|
||||
far under it the place is. A mod's biome generates where a rule it adds puts it, see
|
||||
[Adding Biomes](terrain.md#adding-biomes).
|
||||
|
||||
Biomes are one per block across and one every 4 blocks up, a cell from `y` to `y + 3` where `y` is a multiple of 4 above
|
||||
the world's bottom. The base game's are the same all the way up a column, and a mod can add biomes under the ground, see
|
||||
[Underground Biomes](terrain.md#underground-biomes). The ground's surface blocks are always its own cell's biome's, and
|
||||
so is the filler under them.
|
||||
|
||||
## A Biome
|
||||
|
||||
@@ -62,14 +68,14 @@ Above the snow line, around y 176, the top block is snow whatever the biome says
|
||||
|
||||
## Biome Ids
|
||||
|
||||
Biome ids are what features' `biome_at` gives and what spawns list. The base game has `bworld:deep_ocean`,
|
||||
Biome ids are what `biome_at` gives and what spawns list. The base game has `bworld:deep_ocean`,
|
||||
`bworld:deep_frozen_ocean`, `bworld:deep_lukewarm_ocean`, `bworld:ocean`, `bworld:frozen_ocean`, `bworld:warm_ocean`,
|
||||
`bworld:river`, `bworld:frozen_river`, `bworld:beach`, `bworld:snowy_beach`, `bworld:stony_shore`, `bworld:plains`,
|
||||
`bworld:meadow`, `bworld:forest`, `bworld:dark_forest`, `bworld:swamp`, `bworld:taiga`, `bworld:snowy_plains`,
|
||||
`bworld:snowy_taiga`, `bworld:savanna`, `bworld:jungle`, `bworld:desert`, `bworld:snowy_slopes`, `bworld:stony_peaks`,
|
||||
`bworld:jagged_peaks` and `bworld:frozen_peaks`.
|
||||
|
||||
`/locatebiome <id>` finds the nearest one.
|
||||
`/locatebiome <id>` finds the nearest one, and how high it is: the ground's y, or under it for a biome under the ground.
|
||||
|
||||
## Biome Tags
|
||||
|
||||
@@ -83,7 +89,9 @@ Biomes have [tags](../resources/tags.md) too, in `tags/biomes/`. Every base game
|
||||
| `#bworld:is_forest` | `forest`, `dark_forest`, `savanna`, `plains`, `snowy_plains`, `taiga`, `snowy_taiga`, `jungle`, `swamp`, `desert` |
|
||||
|
||||
A mod's biome joins one by adding itself to the tag's file, like `tags/biomes/bworld/is_forest.json`, and a script
|
||||
checks a biome with `ctx.tags.has("biomes", "bworld:is_forest", ctx.world.biome_at(x, z))`.
|
||||
checks a biome with `ctx.tags.has("biomes", "bworld:is_forest", ctx.world.biome_at(x, y, z))`.
|
||||
|
||||
Biomes under the ground go in the common tags NeoForge mods check, `#c:is_underground`, and `#c:is_cave` for caves.
|
||||
|
||||
## Seasons
|
||||
|
||||
@@ -94,17 +102,19 @@ summer in `desert`.
|
||||
|
||||
Scripts read the season where something is:
|
||||
|
||||
| Where | Biome | Season |
|
||||
| ------------------------------------------------ | -------------------------- | --------------------------- |
|
||||
| a block in a server component, like `on_tick` | `block.biome` | `block.season` |
|
||||
| an entity from `ctx.world.spawn_entity` | `entity.biome` | `entity.season` |
|
||||
| a player, on the server | `player.biome` | `player.season` |
|
||||
| any column, in server, shared and client scripts | `ctx.world.biome_at(x, z)` | `ctx.world.season_at(x, z)` |
|
||||
| the player on this client | `ctx.player.biome` | `ctx.player.season` |
|
||||
| Where | Biome | Season |
|
||||
| ----------------------------------------------- | ----------------------------- | ------------------------------ |
|
||||
| a block in a server component, like `on_tick` | `block.biome` | `block.season` |
|
||||
| an entity from `ctx.world.spawn_entity` | `entity.biome` | `entity.season` |
|
||||
| a player, on the server | `player.biome` | `player.season` |
|
||||
| any block, in server, shared and client scripts | `ctx.world.biome_at(x, y, z)` | `ctx.world.season_at(x, y, z)` |
|
||||
| the player on this client | `ctx.player.biome` | `ctx.player.season` |
|
||||
| a feature's chunk, see [Features](index.md) | `chunk.biome_at(x, y, z)` | |
|
||||
|
||||
Entities and players go by the column their feet are in. On the server a column always has a biome: in a chunk that
|
||||
isn't loaded it's what generation makes there, which takes a while the first time. In shared rules and client scripts
|
||||
it's what that client has loaded, and `undefined` where it has nothing.
|
||||
`biome_at` is NeoForge's `level.getBiome(pos)`. Entities and players go by the block their feet are in, like
|
||||
`level.getBiome(entity.blockPosition())`. Above and below the world it's the biome at its top or bottom. On the server
|
||||
every block has a biome: in a chunk that isn't loaded it's what generation makes there, which takes a while the first
|
||||
time. In shared rules and client scripts it's what that client has loaded, and `undefined` where it has nothing.
|
||||
|
||||
```ts
|
||||
ctx.components.register_block("my_mod:crop", {
|
||||
|
||||
@@ -90,7 +90,8 @@ export function setup(gen: WorldgenContext) {
|
||||
}
|
||||
```
|
||||
|
||||
`step` and `biomes` are optional. With `biomes`, the feature only runs in chunks that have one of them.
|
||||
`step` and `biomes` are optional. With `biomes`, the feature only runs in chunks that have one of them somewhere, at any
|
||||
height, the way a NeoForge biome modifier adds a feature to the biomes it lists.
|
||||
|
||||
Feature ids are in the mod's namespace. Each feature's `rng` is seeded with the world's seed, the chunk and the
|
||||
feature's id, so adding another mod's feature doesn't change what this one generates.
|
||||
@@ -107,7 +108,8 @@ interface FeatureChunk {
|
||||
noise_2d(name: string): (x: number, z: number) => number;
|
||||
noise_3d(name: string): (x: number, y: number, z: number) => number;
|
||||
height_at(x: number, z: number): number; // surface height, inside this chunk only
|
||||
biome_at(x: number, z: number): string; // like "bworld:plains", inside this chunk only
|
||||
biome_at(x: number, y: number, z: number): string; // like "bworld:plains", inside this chunk only
|
||||
set_biome(x: number, y: number, z: number, biome: string): void; // the 4 blocks tall cell y is in, see biomes.md
|
||||
get_block(x: number, y: number, z: number): string | undefined; // inside this chunk only
|
||||
set_block(x: number, y: number, z: number, id: string): void; // up to one chunk away
|
||||
place_feature(id: string, x: number, y: number, z: number): boolean; // a data feature, see below
|
||||
|
||||
@@ -151,7 +151,7 @@ A generator. The base game's is `worldgen/noise_settings/overworld.json`:
|
||||
| `cell_width` | How far apart across `terrain` and `caves` are sampled, 1 to 16. |
|
||||
| `terrain`, `caves` | Their density function, and how far apart up they're sampled. Solid where both are above 0. |
|
||||
| `preliminary_surface` | The ground's height before 3D noise. Surface rules, `steep` and `/locatebiome` use it. |
|
||||
| `climate` | Named values biome rules look at. Any names, except `surface` and `steep`. |
|
||||
| `climate` | Named values biome rules look at. Any names, except `surface`, `y`, `depth` and `steep`. |
|
||||
| `steep` | A column is steep when its preliminary surface is this much higher or lower than a neighbor's. |
|
||||
| `biome_source` | The biome source that picks its biomes. |
|
||||
| `fluids` | What empty space becomes, the first that applies: below `below`, where there's `open_sky` (nothing but air above) or where a density function is in a range. |
|
||||
@@ -187,8 +187,18 @@ with `bworld:dark_forest`, which holds everywhere:
|
||||
}
|
||||
```
|
||||
|
||||
`when` holds when all its conditions do: a range of one of the generator's `climate` values, a range of `surface` (the y
|
||||
of the column's top solid block), or `"steep": true` or `false`. Rules without `when` always hold.
|
||||
Rules pick a biome for each 4 blocks tall cell of a column, see [Biomes](biomes.md). `when` holds when all its
|
||||
conditions do, each a range of one of these, or `"steep": true` or `false`. Rules without `when` always hold.
|
||||
|
||||
| Name | Meaning |
|
||||
| ----------------- | ---------------------------------------------------------------------------------------- |
|
||||
| a `climate` value | One of the generator's, the same all the way up a column. |
|
||||
| `surface` | The y of the column's top solid block. |
|
||||
| `y` | The cell's lowest y. |
|
||||
| `depth` | How far the cell is below the ground, `surface - y`: 0 at the ground, negative above it. |
|
||||
|
||||
A rule that looks at neither `y` nor `depth` holds all the way up a column, so the base game's rules give a column one
|
||||
biome. When no rule looks at them, a column's biome is worked out once.
|
||||
|
||||
This is bworld's own, not Minecraft's multi-noise biome source: a rule can look at how high the ground really is and
|
||||
whether it's a cliff, which is how beaches, peaks and stony shores are placed.
|
||||
@@ -217,6 +227,34 @@ plains:
|
||||
|
||||
Rules from several mods go in in load order. The biome itself is a [biome file](biomes.md) as usual.
|
||||
|
||||
### Underground Biomes
|
||||
|
||||
A rule with `depth` or `y` puts a biome under the ground. It has to come before the rules it takes the place of, and the
|
||||
base game's all hold all the way down, so it goes before the first one. Mossy caves more than 16 blocks down, where it's
|
||||
humid:
|
||||
|
||||
```json
|
||||
{
|
||||
"format_version": 1,
|
||||
"biome_source": {
|
||||
"id": "my_mod:mossy_caves",
|
||||
"extends": "bworld:overworld",
|
||||
"rules": [{
|
||||
"id": "my_mod:mossy_caves",
|
||||
"before": "bworld:river_bed_frozen",
|
||||
"when": {
|
||||
"depth": { "min_exclusive": 16 },
|
||||
"humidity": { "min_exclusive": 0.4 }
|
||||
},
|
||||
"biome": "my_mod:mossy_caves"
|
||||
}]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The ground keeps the biome of its own cell, surface blocks and all. Spawns, `entity.biome`, seasons and grass, leaf and
|
||||
water colors follow the biome where they are, so an underground biome's spawn list and colors work under the ground.
|
||||
|
||||
## Surface Rules
|
||||
|
||||
What a solid block becomes, like Minecraft's surface rules: a rule gives a block or nothing, and the first one in a
|
||||
|
||||
Reference in New Issue
Block a user