World shape for dimension

This commit is contained in:
2026-11-06 22:49:43 -03:00
parent 7458a2d42a
commit 818ce22dd6
60 changed files with 749 additions and 349 deletions
+1
View File
@@ -204,6 +204,7 @@ 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.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
ctx.items.exists(id);
ctx.items.name(id); // "Cooked Rice"
+2 -2
View File
@@ -46,8 +46,8 @@ away before anything is downloaded.
The server sends the world the way Minecraft Java does since 1.20.2. Clients never generate terrain, so worldgen scripts
stay on the server.
- Chunks are 16×256×16 and sent whole, compressed, in batches, nearest first. The server paces batches by how fast each
client says it loads them.
- Chunks are 16×16 and as tall as the dimension, sent whole, compressed, in batches, nearest first. The server paces
batches by how fast each client says it loads them.
- Players see chunks up to their view distance, at most 16 on the server's side. Light isn't sent: clients light chunks
themselves.
- Block changes go only to players who have the chunk. Everyone else gets the change with the chunk when they come
+6 -2
View File
@@ -25,7 +25,8 @@ Each chunk goes through three passes:
2. **Ores.** Every mod's `worldgen/ores.json`, in load order, the base game's first.
3. **Features.** Every mod's features, code and data, by step and then load order, see [Order](#order).
The world is 256 blocks tall and the sea is at y 64.
How tall the world is is up to its [dimension](terrain.md#height): the base game's goes from y 0 to 255, and its sea is
at y 64.
## Ores
@@ -99,6 +100,8 @@ interface FeatureChunk {
readonly x: number; // chunk coordinates. blocks are chunk.x * 16 to chunk.x * 16 + 15
readonly z: number;
readonly seed: string;
readonly min_y: number; // the dimension's blocks go from min_y up to max_y - 1
readonly max_y: number;
readonly rng: { next(): number }; // 0 to 1
random(name: string): { next(): number }; // seeded from the world's seed and name, the same in every chunk
noise_2d(name: string): (x: number, z: number) => number;
@@ -175,7 +178,8 @@ Built in names work with or without `minecraft:`.
`not`, `all_of`, `any_of` and `true`. Each takes an `offset`.
- **Numbers** (int providers): a whole number, or `constant`, `uniform` (`min_inclusive`, `max_inclusive`) or
`weighted_list` (`distribution` of `data` and `weight`).
- **Heights:** `{ "absolute": y }`, `{ "above_bottom": n }` or `{ "below_top": n }`.
- **Heights:** `{ "absolute": y }`, `{ "above_bottom": n }` (`min_y + n`) or `{ "below_top": n }` (`max_y - 1 - n`),
from the dimension's height.
- **Blocks** (`to_place`, `provider`, `state`): an id, or Minecraft's
`{ "type": "simple_state_provider", "state": { "Name": id } }`.
+32 -6
View File
@@ -256,15 +256,40 @@ base game's is `worldgen/dimension/overworld.json`:
"dimension": {
"id": "bworld:overworld",
"generator": "bworld:overworld",
"default": true
"default": true,
"min_y": 0,
"max_y": 256,
"sky_light": true
}
}
```
| Field | Meaning |
| ----------- | --------------------------------------------------------- |
| `generator` | The [noise settings](#noise-settings) that generate it. |
| `default` | `true` for the dimension the world plays. False if unset. |
| Field | Meaning |
| ----------- | ------------------------------------------------------------------------------------------------------- |
| `generator` | The [noise settings](#noise-settings) that generate it. |
| `default` | `true` for the dimension the world plays. False if unset. |
| `min_y` | The lowest y that has blocks. 0 if unset. |
| `max_y` | The first y above the world: blocks go up to `max_y - 1`. 256 if unset. |
| `sky_light` | Whether light comes from the sky. `false` for a dimension that's underground everywhere. True if unset. |
### Height
A dimension's blocks go from `min_y` up to `max_y - 1`, so `"min_y": -64, "max_y": 320` is 384 blocks tall. Both have to
be multiples of 16, `max_y` at least 16 above `min_y`, and the world has to fit in -2048 to 2048. They also have to be
multiples of the generator's `terrain` and `caves` `cell_height`, since the density is sampled every `cell_height`
blocks up from `min_y`. `check-mods` reports any of these, and the server doesn't start with them.
Outside the height there are no blocks: reading one gives air and placing one does nothing. Things that fall 64 blocks
below `min_y` are out of the world. Scripts read the height as `ctx.world.min_y` and `ctx.world.max_y`, on the server
and the client, and features as `chunk.min_y` and `chunk.max_y`.
Chunks are saved with the height they were made with. For now a chunk saved before a dimension's height changed can't be
read, and is generated again.
### Sky Light
Without sky light, there's none anywhere, in the open and above the world too: only blocks that give off light, like
torches, light it, and day and night don't change how bright it is. The sky is still drawn as it is in the overworld.
The world plays the dimension with `"default": true`. Exactly one dimension in the loaded mods can be the default: with
none, or more than one, the server doesn't start, and the error names them. A mod can have dimensions that aren't the
@@ -274,7 +299,8 @@ its own, like a flat world, can't be loaded with the base game's for now.
There's one dimension per world for now, there's no travelling between them yet.
New players spawn in the middle of the world, on the first column, in rings of chunks around 0, 0, whose top block has
collision. Water has none, so they never spawn in the sea, and neither do plants without collision.
collision, looking down from `max_y`. Water has none, so they never spawn in the sea, and neither do plants without
collision.
## Changing the Base Game's Terrain