Skip to content

Commit

Permalink
Write documentation for neighbor based chunk spawning (#51818)
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Candlebury authored Sep 23, 2021
1 parent d28f181 commit 33bac2a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions doc/MAPGEN.md
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,29 @@ an `update_mapgen`, as normal mapgen can just specify the terrain directly.

- "transform": (required, string) the id of the `ter_furn_transform` to run.

### Spawn nested chunks based on overmap neighbors with "place_nested"

Place_nested allows for limited conditional spawning of chunks based on the `"id"`s of their overmap neighbors. This is useful for creating smoother transitions between biome types or to dynamically create walls at the edges of a mutable structure.

| Field | Description
| --- | ---
| chunks/else_chunks | (required, string) the nested_mapgen_id of the chunk that will be conditionally placed. Chunks are placed if the specified neighbor matches, and "else_chunks" otherwise.
| x and y | (required, int) the cardinal position in which the chunk will be placed.
| neighbors | (optional, string ) Any of the neighboring overmaps that should be evaluated before placing the chunk. Despite the plural field name, only a single neighbor direction can be evaluated per chunk. The direction itself can check for any amount of overmap `"id"` substrings.
|

The following adjacent overmaps can be evaluated in this manner: the direct cardinal neighbors ( `"north", "east", "south", "west"` ) the inter cardinal neighbors ( `"north_east", "north_west", "south_east", "south_west"` ), and the direct vertical neighbors ( `"above", "below"` ).

Example:

```json
"place_nested": [
{ "chunks": [ "concrete_wall_ew" ], "x": 0, "y": 0, "neighbors": { "north": [ "empty_rock", "field" ] } },
{ "else_chunks": [ "concrete_wall_ns" ], "x": 0, "y": 0, "neighbors": { "north_west": [ "field", "microlab" ] } }
],
```
The code excerpt above will place the nested chunk "concrete_wall_ew" if the north neighbor is either a field or solid rock, otherwise potentially placing `"concrete_wall_ns"`; the latter will be placed only if the north_west neighbor is neither a field nor any of the microlab overmaps).


## Mapgen values

Expand Down

0 comments on commit 33bac2a

Please sign in to comment.