Single module modding
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# World Generation
|
||||
|
||||
The server generates chunks from the world's seed, and players get the finished chunks. Mods add to what it generates
|
||||
with ores (data) and features (a worldgen script).
|
||||
with ores (data) and features (the worldgen phase).
|
||||
|
||||
## Determinism
|
||||
|
||||
@@ -13,7 +13,7 @@ isn't the same, trees are cut off at chunk borders.
|
||||
- **Never use `Math.random`, `Date`, `performance.now` or anything else that changes between runs.** Use the chunk's
|
||||
`rng` and noise helpers, which are seeded from the world's seed.
|
||||
- Don't keep state between chunks. Chunks generate in any order, and in several worldgen workers at once, each with its
|
||||
own copy of the worldgen scripts (and the game generates a few itself).
|
||||
own copy of the worldgen phases (and the game generates a few itself).
|
||||
- Adding or removing a mod's features only changes chunks that haven't been generated yet, with seams where they meet
|
||||
saved ones.
|
||||
|
||||
@@ -76,12 +76,12 @@ order they were registered. The base game's trees are in `vegetal_decoration`, s
|
||||
|
||||
### Code Features
|
||||
|
||||
The worldgen script registers them:
|
||||
The worldgen phase registers them:
|
||||
|
||||
```ts
|
||||
import type { WorldgenContext } from "cubi/worldgen";
|
||||
|
||||
export function setup(gen: WorldgenContext) {
|
||||
export function worldgen(gen: WorldgenContext) {
|
||||
gen.register_feature("copper_tools:boulders", (chunk) => {
|
||||
if (chunk.rng.next() > 0.1) return;
|
||||
const x = chunk.x * 16 + Math.floor(chunk.rng.next() * 16);
|
||||
@@ -125,7 +125,7 @@ cell agrees on where its tree is.
|
||||
`set_block` can write up to one chunk away, so a tree near the border can grow into the next chunk. Writes into another
|
||||
chunk only fill air, so the result doesn't depend on which chunk generates first.
|
||||
|
||||
Generated blocks don't run `on_create`, and worldgen scripts can't use the server or client API.
|
||||
Generated blocks don't run `on_create`, and worldgen phases can't use the server or client API.
|
||||
|
||||
### Data Features
|
||||
|
||||
@@ -185,7 +185,7 @@ Built in names work with or without `minecraft:`.
|
||||
|
||||
### Types and Modifiers in Code
|
||||
|
||||
A worldgen script can add types and placement modifiers for data features to use, by id:
|
||||
The worldgen phase can add types and placement modifiers for data features to use, by id:
|
||||
|
||||
```ts
|
||||
gen.register_feature_type<{ block: string; height: number }>("copper_tools:pillar", (chunk, config, origin) => {
|
||||
|
||||
Reference in New Issue
Block a user