diff --git a/src/app/pages/Guide.tsx b/src/app/pages/Guide.tsx index fb046152..a6612d2f 100644 --- a/src/app/pages/Guide.tsx +++ b/src/app/pages/Guide.tsx @@ -65,6 +65,40 @@ export function Guide({ id }: Props) { const headings: marked.Tokens.Heading[] = [] let insertedToc = false marked.use({ + extensions: [ + { + name: 'styledCode', + level: 'inline', + start(src) { + return src.match(/\b[fsnj]`/)?.index ?? -1 + }, + tokenizer(src) { + const match = src.match(/^([fsnj])`([^`]+)`/) + if (match) { + return { + type: 'styledCode', + raw: match[0], + prefix: match[1], + text: match[2], + } + } + return undefined + }, + renderer(token) { + let content = token.text + let c = { + f: 'hljs-attr', + s: 'hljs-string', + n: 'hljs-number', + }[token.prefix as string] + if (token.prefix === 'j') { + content = hljs.highlight('json', token.text).value + c = 'language-json' + } + return `${content}` + }, + }, + ], walkTokens(token) { if (token.type === 'heading') { headings.push(token) diff --git a/src/guides/adding-custom-structures.md b/src/guides/adding-custom-structures.md index bb2ac912..efa83bed 100644 --- a/src/guides/adding-custom-structures.md +++ b/src/guides/adding-custom-structures.md @@ -44,14 +44,14 @@ A structure set is where the placement starts. It defines where in the world the } ``` Structure sets are made up of two parts: -* `structures`: A weighted list of configured structure features [(see next step)](#the{#[1.18.2] -configured #}-structure). -* `placement`: The structure placement - * `placement.type`: Either `random_spread` or `concentric_rings`. The latter is only used by strongholds in vanilla, so we'll focus on `random_spread` - * `placement.spacing`: Roughly the average distance in chunks between two structures in this set. - * `placement.separation`: The minimum distance in chunks. Needs to be smaller than spacing. - * `placement.salt`: A random number that is combined with the world seed. Always use a different random number for different structures, otherwise they will end up being placed in the same spot! +* f`structures`: A weighted list of configured structure features [(see next step)](#the{#[1.18.2] -configured #}-structure). +* f`placement`: The structure placement + * f`type`: Either s`random_spread` or s`concentric_rings`. The latter is only used by strongholds in vanilla, so we'll focus on s`random_spread` + * f`spacing`: Roughly the average distance in chunks between two structures in this set. + * f`separation`: The minimum distance in chunks. Needs to be smaller than spacing. + * f`salt`: A random number that is combined with the world seed. Always use a different random number for different structures, otherwise they will end up being placed in the same spot! -When using the `random_spread` placement type, it generates structures grid-based. Here's an illustration of the above example with `spacing = 5`, `separation = 2`. There will be one structure attempt in each 5x5 chunk grid, and only at `X` a structure can spawn. +When using the s`random_spread` placement type, it generates structures grid-based. Here's an illustration of the above example with `spacing = 5`, `separation = 2`. There will be one structure attempt in each 5x5 chunk grid, and only at `X` a structure can spawn. ``` ............. ..XXX..XXX..X @@ -100,23 +100,24 @@ The {#[1.18.2] configured structure (feature) #}{#[1.19] structure #} is the ID ``` Let's go over all the fields. {#[1.18.2] -* `type`: This is the structure feature type. When making custom structures, you almost always want to set this to `village` or `bastion_remnant`. There is one important difference between the two: using `village` will spawn the structure on the surface, while `bastion_remnant` will always spawn the structure at Y=33. -* `config.start_pool`: This is a reference to the **template pool** [(see next step)](#the-template-pool). -* `config.size`: This is a number between 1 and 7. This is important if your structure uses jigsaw. In this simple example, we'll leave it at 1. -* `biomes`: This controls in which biomes this structure is allowed to generate. You can give it any biome tag, a list of biomes, or a single biome. For easy testing we'll set it to every biome with mineshafts. -* `adapt_noise`: When true, it will add extra terrain below each structure piece. -* `spawn_overrides`: This field allows you to override mob spawning inside the structure bounding boxes. This is outside the scope of this guide, but you could look at the [vanilla monument](/worldgen/structure-feature/?preset=monument&version={#version#}) structure feature as a reference. +* f`type`: This is the structure feature type. When making custom structures, you almost always want to set this to s`village` or s`bastion_remnant`. There is one important difference between the two: using s`village` will spawn the structure on the surface, while s`bastion_remnant` will always spawn the structure at Y=33. +* f`config`: + * f`start_pool`: This is a reference to the **template pool** [(see next step)](#the-template-pool). + * f`size`: This is a number between 1 and 7. This is important if your structure uses jigsaw. In this simple example, we'll leave it at 1. +* f`biomes`: This controls in which biomes this structure is allowed to generate. You can give it any biome tag, a list of biomes, or a single biome. For easy testing we'll set it to every biome with mineshafts. +* f`adapt_noise`: When true, it will add extra terrain below each structure piece. +* f`spawn_overrides`: This field allows you to override mob spawning inside the structure bounding boxes. This is outside the scope of this guide, but you could look at the [vanilla monument](/worldgen/structure-feature/?preset=monument&version={#version#}) structure feature as a reference. #}{#[1.19] -* `type`: This is the structure type. When making custom structures, you almost always want to set this to `jigsaw`. -* `biomes`: This controls in which biomes this structure is allowed to generate. You can give it any biome tag, a list of biomes, or a single biome. For easy testing we'll set it to every biome with mineshafts. -* `step`: The generation step to place the features in. This matches the steps in a biome's `feature` list. Possible values: `raw_generation`, `lakes`, `local_modifications`, `underground_structures`, `surface_structures`, `strongholds`, `underground_ores`, `underground_decoration`, `fluid_springs`, `vegetal_decoration`, and `top_layer_modification`. -* `spawn_overrides`: This field allows you to override mob spawning inside the structure bounding boxes. This is outside the scope of this guide, but you could look at the [vanilla monument](/worldgen/structure/?preset=monument&version={#version#}) structure feature as a reference. -* `start_pool`: This is a reference to the **template pool** [(see next step)](#the-template-pool). -* `size`: This is a number between 1 and 7. This is important if your structure uses jigsaw. In this simple example, we'll leave it at 1. -* `start_height`: A height provider specifying at which height the structure should spawn. The example uses the constant shorthand so it just specifies a vertical anchor. -* `project_start_to_heightmap`: An optional heightmap type. Possible values: `WORLD_SURFACE_WG`, `WORLD_SURFACE`, `OCEAN_FLOOR_WG`, `OCEAN_FLOOR`, `MOTION_BLOCKING`, and `MOTION_BLOCKING_NO_LEAVES`. If `start_height` is not 0, will move the start relative to the heightmap. -* `max_distance_from_center`: Value between 1 and 128. The maximum distance that a jigsaw can branch out. -* `use_expansion_hack`: You should always set this to false. Vanilla villages set this to true to fix an issue with their streets. +* f`type`: This is the structure type. When making custom structures, you almost always want to set this to s`jigsaw`. +* f`biomes`: This controls in which biomes this structure is allowed to generate. You can give it any biome tag, a list of biomes, or a single biome. For easy testing we'll set it to every biome with mineshafts. +* f`step`: The generation step to place the features in. This matches the steps in a biome's `feature` list. Possible values: s`raw_generation`, s`lakes`, s`local_modifications`, s`underground_structures`, s`surface_structures`, s`strongholds`, s`underground_ores`, s`underground_decoration`, s`fluid_springs`, s`vegetal_decoration`, and s`top_layer_modification`. +* f`spawn_overrides`: This field allows you to override mob spawning inside the structure bounding boxes. This is outside the scope of this guide, but you could look at the [vanilla monument](/worldgen/structure/?preset=monument&version={#version#}) structure feature as a reference. +* f`start_pool`: This is a reference to the **template pool** [(see next step)](#the-template-pool). +* f`size`: This is a number between 1 and 7. This is important if your structure uses jigsaw. In this simple example, we'll leave it at 1. +* f`start_height`: A height provider specifying at which height the structure should spawn. The example uses the constant shorthand so it just specifies a vertical anchor. +* f`project_start_to_heightmap`: An optional heightmap type. Possible values: s`WORLD_SURFACE_WG`, s`WORLD_SURFACE`, s`OCEAN_FLOOR_WG`, s`OCEAN_FLOOR`, s`MOTION_BLOCKING`, and s`MOTION_BLOCKING_NO_LEAVES`. If f`start_height` is not 0, will move the start relative to the heightmap. +* f`max_distance_from_center`: Value between 1 and 128. The maximum distance that a jigsaw can branch out. +* f`use_expansion_hack`: You should always set this to false. Vanilla villages set this to true to fix an issue with their streets. #} ## The template pool @@ -141,13 +142,13 @@ The template pool defines how to build up your structure. Since we're not using } ``` Again, let's go over the fields: -* `name`: For some reason, the game needs the name of this template pool. Just set this to the ID of the template pool. -* `fallback`: Used in jigsaw structures, but we can simply use `minecraft:empty`. -* `elements`: A weighted list of pool elements to choose from. You can add multiple elements here if your structure has different starting structure files. For example in vanilla a plains village has different town center variants. - * `element_type`: The type of this element. One of `empty_pool_element` (placing nothing), `feature_pool_element` (placing a placed feature), `legacy_single_pool_element`, `list_pool_element`, and `single_pool_element` (placing a structure). - * `location`: The path to the structure NBT file. [(see next step)](#the-structure-nbt). - * `projection`: Either `rigid` or `terrain_matching`. Use the latter if you want the structure to match the terrain, just like village paths do. - * `processors`: If you want to run any processor lists, this is quite complicated so again we'll skip this for now and set it to `minecraft:empty`. +* f`name`: For some reason, the game needs the name of this template pool. Just set this to the ID of the template pool. +* f`fallback`: Used in jigsaw structures, but we can simply use s`minecraft:empty`. +* f`elements`: A weighted list of pool elements to choose from. You can add multiple elements here if your structure has different starting structure files. For example in vanilla a plains village has different town center variants. + * f`element_type`: The type of this element. One of s`empty_pool_element` (placing nothing), s`feature_pool_element` (placing a placed feature), s`legacy_single_pool_element`, s`list_pool_element`, and s`single_pool_element` (placing a structure). + * f`location`: The path to the structure NBT file. [(see next step)](#the-structure-nbt). + * f`projection`: Either s`rigid` or s`terrain_matching`. Use the latter if you want the structure to match the terrain, just like village paths do. + * f`processors`: If you want to run any processor lists, this is quite complicated so again we'll skip this for now and set it to s`minecraft:empty`. ## The structure NBT Creating the structure NBT file is entirely up to you. In this example I'm going to use a tower structure from [Gamemode 4](https://gm4.co/modules/tower-structures). diff --git a/src/guides/density-functions.md b/src/guides/density-functions.md index 767d2fe4..7554ac34 100644 --- a/src/guides/density-functions.md +++ b/src/guides/density-functions.md @@ -11,9 +11,9 @@ tags: [Density functions](/worldgen/density-function/) are used by the dimension generator to generate the terrain. They make up mathematical expressions that decide whether or not a block should be solid terrain. ## Noise router -The noise router is a piece of configuration in [noise settings](/worldgen/noise-settings/). It's a collection of density functions, some used for the biome layout, aquifers, or ore veins. The one that decides the terrain is **`final_density`**. This density function will be computed for every block position. If it returns a value greater than `0` the default block will be placed, otherwise either air or the default fluid will be placed. +The noise router is a piece of configuration in [noise settings](/worldgen/noise-settings/). It's a collection of density functions, some used for the biome layout, aquifers, or ore veins. The one that decides the terrain is **f`final_density`**. This density function will be computed for every block position. If it returns a value greater than n`0` the default block will be placed, otherwise either air or the default fluid will be placed. -With this information we can make the most basic noise router, one where every density function is set to `0`. As predicted, this will result in a void world. Similarly, setting `"final_density": 1` will result in a world completely filled with stone. +With this information we can make the most basic noise router, one where every density function is set to n`0`. As predicted, this will result in a void world. Similarly, setting `"final_density": 1` will result in a world completely filled with stone. **`data/minecraft/worldgen/noise_settings/overworld.json`** ```json @@ -86,12 +86,12 @@ The following is a list of all density functions in {#version#} ### `abs` Calculates the absolute value of another density function. -* `argument`: The input density function +* f`argument`: The input density function ### `add` Adds two density functions together. -* `argument1`: The first density function -* `argument2`: The second density function +* f`argument1`: The first density function +* f`argument2`: The second density function ### `beardifier` Adds beards for structures (see the `terrain_adaptation` field). @@ -103,7 +103,7 @@ Adds beards for structures (see the `terrain_adaptation` field). *This density function has no extra fields* ### `blend_density` -* `argument`: The input density function +* f`argument`: The input density function ### `blend_offset` @@ -111,29 +111,29 @@ Adds beards for structures (see the `terrain_adaptation` field). ### `cache_2d` Only computes the input density once for each column, at Y=0 -* `argument`: The input density function +* f`argument`: The input density function ### `cache_all_in_cell` Used in combination with [`interpolated`](#interpolated). -* `argument`: The input density function +* f`argument`: The input density function ### `cache_once` If this density function is referenced twice, it is only computed once per block position. -* `argument`: The input density function +* f`argument`: The input density function ### `clamp` Clamps the input between two values. -* `input`: The input density function -* `min`: The lower bound -* `max`: The upper bound +* f`input`: The input density function +* f`min`: The lower bound +* f`max`: The upper bound ### `constant` -A constant value. `{"type": "constant", "argument": 2}` is equivalent to `2`. -* `argument`: The constant number +A constant value. j`{"type": "constant", "argument": 2}` is equivalent to n`2`. +* f`argument`: The constant number ### `cube` Cubes the input. (`x^3`) -* `argument`: The input density function +* f`argument`: The input density function ### `end_islands` @@ -144,114 +144,114 @@ Similar to [`cache_2d`](#cache_2d) in that it only computes the input once for e ### `half_negative` If the input is negative, returns half of the input. Otherwise returns the input. (`x < 0 ? x/2 : x`) -* `argument`: The input density function +* f`argument`: The input density function ### `interpolated` Computes the input density at each of the 8 corners of a cell and interpolates between them. The size of a cell if determined by `size_horizontal * 4` and `size_vertical * 4`. -* `argument`: The input density function +* f`argument`: The input density function ### `max` Returns the maximum of two density functions. -* `argument1`: The first density function -* `argument2`: The second density function +* f`argument1`: The first density function +* f`argument2`: The second density function ### `min` Returns the minimum of two density functions. -* `argument1`: The first density function -* `argument2`: The second density function +* f`argument1`: The first density function +* f`argument2`: The second density function ### `mul` Multiplies two density functions. -* `argument1`: The first density function -* `argument2`: The second density function +* f`argument1`: The first density function +* f`argument2`: The second density function ### `noise` The noise density function samples a noise. -* `noise`: A reference to a `worldgen/noise` file -* `xz_scale`: Scales the X and Z inputs before sampling -* `y_scale`: Scales the Y input before sampling +* f`noise`: A reference to a `worldgen/noise` file +* f`xz_scale`: Scales the X and Z inputs before sampling +* f`y_scale`: Scales the Y input before sampling ### `old_blended_noise` Uses a different kind of noise than [`noise`](#noise). -* `xz_scale` -* `y_scale` -* `xz_factor` -* `y_factor` -* `smear_scale_multiplier` +* f`xz_scale` +* f`y_scale` +* f`xz_factor` +* f`y_factor` +* f`smear_scale_multiplier` ### `quarter_negative` If the input is negative, returns a quarter of the input. Otherwise returns the input. (`x < 0 ? x/4 : x`) -* `argument`: The input density function +* f`argument`: The input density function ### `range_choice` Computes the input value, and depending on that result returns one of two other density functions. -* `input`: The input density function -* `min_inclusive`: The lower bound of the range -* `max_exclusive`: The upper bound of the range -* `when_in_range`: Density function that will be returned when the input is inside the range -* `when_out_of_range`: Density function that will be returned When the input is outside the range +* f`input`: The input density function +* f`min_inclusive`: The lower bound of the range +* f`max_exclusive`: The upper bound of the range +* f`when_in_range`: Density function that will be returned when the input is inside the range +* f`when_out_of_range`: Density function that will be returned When the input is outside the range ### `shift` Computes the input density at `(x/4, y/4, z/4)`. -* `argument`: The input density function +* f`argument`: The input density function ### `shift_a` Computes the input density at `(x/4, 0, z/4)`. -* `argument`: The input density function +* f`argument`: The input density function ### `shift_b` Computes the input density at `(z/4, x/4, 0)`. -* `argument`: The input density function +* f`argument`: The input density function ### `shifted_noise` Similar to [`noise`](#noise), but first shifts the input coordinates. -* `noise`: A reference to a `worldgen/noise` file -* `xz_scale`: Scales the X and Z inputs before sampling -* `y_scale`: Scales the Y input before sampling -* `shift_x`: Density function used to offset the X input -* `shift_y`: Density function used to offset the Y input -* `shift_z`: Density function used to offset the Z input +* f`noise`: A reference to a `worldgen/noise` file +* f`xz_scale`: Scales the X and Z inputs before sampling +* f`y_scale`: Scales the Y input before sampling +* f`shift_x`: Density function used to offset the X input +* f`shift_y`: Density function used to offset the Y input +* f`shift_z`: Density function used to offset the Z input ### `spline` Computes a spline. More information about splines will follow in a future guide. -* `spline`: The spline, can be either a number or an object: - * `coordinate`: The density function that will be used for the locations - * `points`: List of points of the cubic spline, cannot be empty - * `location`: Input value - * `value`: Output value, can be either a number or a spline object - * `derivative`: The slope at this point +* f`spline`: The spline, can be either a number or an object: + * f`coordinate`: The density function that will be used for the locations + * f`points`: List of points of the cubic spline, cannot be empty + * f`location`: Input value + * f`value`: Output value, can be either a number or a spline object + * f`derivative`: The slope at this point {#[1.18.2] -* `min_value`: The minimum output value of the spline -* `max_value`: The maximum output value of the spline +* f`min_value`: The minimum output value of the spline +* f`max_value`: The maximum output value of the spline #} ### `square` Squares the input. (`x^2`) -* `argument`: The input density function +* f`argument`: The input density function ### `squeeze` First clamps the input between `-1` and `1`, then transforms it using `x/2 - x*x*x/24`. -* `argument`: The input density function +* f`argument`: The input density function {#[1.18.2] ### `terrain_shaper_spline` Computes a terrain shaper spline from the noise settings. -* `spline`: The terrain shaper spline to use. One of `offset`, `factor`, or `jaggedness` -* `min_value`: The minimum output value of the spline -* `max_value`: The maximum output value of the spline -* `continentalness`: The density function to use for the `continents` spline coordinate -* `erosion`: The density function to use for the `erosion` spline coordinate -* `weirdness`: The density function to use for the `weirdness` spline coordinate +* f`spline`: The terrain shaper spline to use. One of s`offset`, s`factor`, or s`jaggedness` +* f`min_value`: The minimum output value of the spline +* f`max_value`: The maximum output value of the spline +* f`continentalness`: The density function to use for the s`continents` spline coordinate +* f`erosion`: The density function to use for the s`erosion` spline coordinate +* f`weirdness`: The density function to use for the s`weirdness` spline coordinate #} ### `weird_scaled_sampler` -* `rarity_value_mapper`: One of `type_1` or `type_2` -* `noise`: A reference to a `worldgen/noise` file -* `input`: The input density function +* f`rarity_value_mapper`: One of s`type_1` or s`type_2` +* f`noise`: A reference to a `worldgen/noise` file +* f`input`: The input density function ### `y_clamped_gradient` Returns the Y position after mapping it to a range. -* `from_y` -* `to_y` -* `from_value`: The value to map `from_y` to -* `to_value`: The value to map `to_y` to +* f`from_y` +* f`to_y` +* f`from_value`: The value to map f`from_y` to +* f`to_value`: The value to map f`to_y` to diff --git a/src/guides/feature-order-cycle.md b/src/guides/feature-order-cycle.md index b8c83eb0..db97d76d 100644 --- a/src/guides/feature-order-cycle.md +++ b/src/guides/feature-order-cycle.md @@ -49,10 +49,10 @@ Let's try with an example. We have two biomes here: } ``` -When we try to load these biomes, data pack validation will fail because in the `example:forest` biome in step 2, `blue_tree` is before `rocks`; while in the `example:plains` biome, `rocks` is before `blue_tree`. +When we try to load these biomes, data pack validation will fail because in the `example:forest` biome in step 2, s`blue_tree` is before s`rocks`; while in the `example:plains` biome, s`rocks` is before s`blue_tree`. ## How to fix it -The rule is that for each step in `"features"`, all features need to be ordered consistently across biomes. +The rule is that for each step in f`"features"`, all feature IDs need to be ordered consistently across biomes. The above example can be fixed by swapping the features in step 2 of the `plains` biome: **`data/example/worldgen/biome/plains.json`** diff --git a/src/styles/global.css b/src/styles/global.css index a7220871..8019c385 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -1668,19 +1668,19 @@ hr { overflow-x: auto; } -.guide-content code .hljs-attr { +.guide-content .hljs-attr { color: var(--editor-variable); } -.guide-content code .hljs-string { +.guide-content .hljs-string { color: var(--editor-string); } -.guide-content code .hljs-number { +.guide-content .hljs-number { color: var(--editor-number); } -.guide-content code .hljs-keyword { +.guide-content .hljs-keyword { color: var(--editor-constant); }