Minecraft:Density function
More actions
Template:Exclusive
Density functions make up mathematical expressions to obtain a number from a position, stored as Minecraft:JSON files within a Minecraft:data pack in the path data/<namespace>/worldgen/density_function. They are referenced from the Minecraft:noise router in Minecraft:noise settings.
JSON format
A density function can be a constant number or an object.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type.
- Other additional fields depend on the value of Template:Nbt, described below.
If the Template:Nbt is constant, a shorthand format is:
- Template:Nbt: A constant number. Value between −1000000.0 and 1000000.0 (both inclusive).
Marker functions
interpolated
Interpolates at each block in one cell based on the input density function value of some cells around. The size of each cell is size_horizontal * 4 and size_vertical * 4. Used often in combination with flat_cache.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
interpolated). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input to be interpolated.
- Template:Nbt: The ID of the density function type (in this case,
flat_cache
Calculate the value per 4×4 column (Value at each block in one column is the same). And it is calculated only once per column, at Y=0. Used often in combination with interpolated.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
flat_cache). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input to be cached.
- Template:Nbt: The ID of the density function type (in this case,
cache_2d
Only computes the input density once per horizontal position.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
cache_2d). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input to be cached.
- Template:Nbt: The ID of the density function type (in this case,
cache_once
If this density function is referenced twice, it is only computed once per block position.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
cache_once). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input to be cached.
- Template:Nbt: The ID of the density function type (in this case,
cache_all_in_cell
Used by the game onto final_density and should not be referenced in data packs.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
cache_all_in_cell). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input to be cached.
- Template:Nbt: The ID of the density function type (in this case,
Mapped density functions
abs
Calculates the absolute value of the input density function.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
abs). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
square
Squares the input. (x^2)
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
square). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
cube
Cubes the input (x^3).
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
cube). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
half_negative
If the input is negative, returns half of the input. Otherwise returns the input. (x < 0 ? x/2 : x)
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
half_negative). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
quarter_negative
If the input is negative, returns a quarter of the input. Otherwise returns the input. (x < 0 ? x/4 : x)
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
quarter_negative). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
squeeze
First clamps the input between −1 and 1, then transforms it using x/2 - x*x*x/24.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
squeeze). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
invert
Inverts the input (1/x).
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
invert). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
Functions with two arguments
add
Adds two density functions together.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
add). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The first input of the calculation.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The second input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
mul
Multiplies two inputs.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
mul). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The first input of the calculation.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The second input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
min
Returns the minimum of two inputs.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
min). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The first input of the calculation.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The second input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
max
Returns the maximum of two inputs.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
max). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The first input of the calculation.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The second input of the calculation.
- Template:Nbt: The ID of the density function type (in this case,
Other density functions
blend_alpha
Used in vanilla for smooth transition to chunks generated in old versions.Template:Info needed
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
blend_alpha).
- Template:Nbt: The ID of the density function type (in this case,
blend_offset
Used in vanilla for smooth transition to chunks generated in old versions.Template:Info needed
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
blend_offset).
- Template:Nbt: The ID of the density function type (in this case,
blend_density
Used in vanilla for smooth transition to chunks generated in old versions.Template:Info needed
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
blend_density). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The desired density of new chunks.
- Template:Nbt: The ID of the density function type (in this case,
beardifier
Adds beards for structures (see the terrain_adaptation field in structures). Its value is added to the final_density in noise setting by the game. Should not be referenced in data packs.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
beardifier).
- Template:Nbt: The ID of the density function type (in this case,
old_blended_noise
Samples a legacy noise. Template:Info needed
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
old_blended_noise). - Template:Nbt: Value between 0.001 and 1000.0 (both inclusive).
- Template:Nbt: Value between 0.001 and 1000.0 (both inclusive).
- Template:Nbt: Value between 0.001 and 1000.0 (both inclusive).
- Template:Nbt: Value between 0.001 and 1000.0 (both inclusive).
- Template:Nbt: Value between 1.0 and 8.0 (both inclusive).
- Template:Nbt: The ID of the density function type (in this case,
noise
Samples a noise.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
noise). - Template:Nbt: Template:Json ref — The noise to sample.
- Template:Nbt: Scales the X and Z before sampling.
- Template:Nbt: Scales the Y before sampling.
- Template:Nbt: The ID of the density function type (in this case,
end_islands
Samples at current position using a noise algorithm used for end islands. Its minimum value is −0.84375 and its maximum value is 0.5625.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
end_islands).
- Template:Nbt: The ID of the density function type (in this case,
weird_scaled_sampler
Template:In development According to the input value, scales and enhances (or weakens) some regions of the specified noise, and then returns the absolute value.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
weird_scaled_sampler). - Template:Nbt: Can be
type_1(The minimum scale is 0.75, and the maximum is 2.0)ortype_2(The minimum scale is 0.5, and the maximum is 3.0.) - Template:Nbt: Template:Json ref — The noise to sample.
- Template:NbtTemplate:NbtTemplate:Nbt: The input density function. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
- Template:Nbt: The ID of the density function type (in this case,
shifted_noise
Similar to noise, but first shifts the input coordinates.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
shifted_noise). - Template:Nbt: Template:Json ref — The noise to sample.
- Template:Nbt: Scales the X and Z before sampling.
- Template:Nbt: Scales the Y before sampling.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — offset of the position in the X direction.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — offset of the position in the Y direction.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — offset of the position in the Z direction.
- Template:Nbt: The ID of the density function type (in this case,
range_choice
Computes the input value, and depending on that result returns one of two other density functions. Basically an if-then-else statement.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
range_choice). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The value to compare
- Template:Nbt: The lower bound of the range. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:Nbt: The upper bound of the range. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — Used when the input is inside the range.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — Used when the input is outside the range.
- Template:Nbt: The ID of the density function type (in this case,
shift_a
Samples a noise at (x/4, 0, z/4), then multiplies it by 4.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
shift_a). - Template:Nbt: Template:Json ref — The noise to sample.
- Template:Nbt: The ID of the density function type (in this case,
shift_b
Samples a noise at (z/4, x/4, 0), then multiplies it by 4.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
shift_b). - Template:Nbt: Template:Json ref — The noise to sample.
- Template:Nbt: The ID of the density function type (in this case,
shift
Samples a noise at (x/4, y/4, z/4), then multiplies it by 4.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
shift). - Template:Nbt: Template:Json ref — The noise to sample.
- Template:Nbt: The ID of the density function type (in this case,
clamp
Clamps the input between two values.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
clamp). - Template:NbtTemplate:Nbt: One density function (a new Template:NbtTemplate:Nbt density function definition, an Template:NbtID is not allowed here<ref>Template:Cite bug</ref>) — The input to clamp.
- Template:Nbt: The lower bound. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:Nbt: The upper bound. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:Nbt: The ID of the density function type (in this case,
spline
Computes a cubic spline.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
spline). - Template:NbtTemplate:Nbt: The spline. Can be either a number or an object.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — Input determining the location on the spline.
- Template:Nbt: (Cannot be empty) List of points of the cubic spline.
- Template:Nbt: A point of the cubic spline.
- Template:Nbt: The location of this point.
- Template:NbtTemplate:Nbt: The value of this point. Can be either a number or a spline object.
- Template:Nbt: The slope at this point.
- Template:Nbt: A point of the cubic spline.
- Template:Nbt: The ID of the density function type (in this case,
constant
A constant value.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
constant). - Template:Nbt: A constant value. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:Nbt: The ID of the density function type (in this case,
y_clamped_gradient
Clamps the Y coordinate between from_y and to_y and then linearly maps it to a range.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
y_clamped_gradient). - Template:Nbt: The value to be mapped to
from_value. Value between −4064 and 4062 (both inclusive). - Template:Nbt: The value to be mapped to
to_value. Value between −4064 and 4062 (both inclusive). - Template:Nbt: The value to map
from_yto. Value between −1000000.0 and 1000000.0 (both inclusive). - Template:Nbt: The value to map
to_yto. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:Nbt: The ID of the density function type (in this case,
find_top_surface
Scans through a column of an input density and returns the topmost y-level that is above 0. If no such position exists withing the bounds, the Template:Nbt is returned.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
find_top_surface). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The density function to scan.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — The y-level to start the scan at. Usually a 2D density function.
- Template:Nbt: The y-level to stop the scan.
- Template:Nbt: The resolution of the scan. E.g. if set to
4, then only every 4th block is checked.
- Template:Nbt: The ID of the density function type (in this case,
Removed density functions
slide
Removed in Minecraft:22w12a
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
slide). - Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function
- Template:Nbt: The ID of the density function type (in this case,
The legacy "spline"
Removed in Minecraft:22w11a
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
spline). - Template:NbtTemplate:Nbt: The spline. Can be either a number or an object.
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function — Input determining the location on the spline.
- Template:Nbt: (Cannot be empty) List of points of the cubic spline.
- Template:Nbt: The location of this point.
- Template:NbtTemplate:Nbt: The value of this point. Can be either a number or a spline object.
- Template:Nbt: The slope at this point.
- Template:Nbt: The min value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:Nbt: The max value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:Nbt: The ID of the density function type (in this case,
terrain_shaper_spline
Removed in Minecraft:22w11a
Calculate the spline from the noise settings.
- Template:Nbt: Root object.
- Template:Nbt: The ID of the density function type (in this case,
terrain_shaper_spline). - Template:Nbt: Can be
offset,factor, orjaggedness. - Template:Nbt: The min value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:Nbt: The max value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function
- Template:NbtTemplate:NbtTemplate:Nbt: Template:Json ref/density function
- Template:Nbt: The ID of the density function type (in this case,
History
Issues
References
External links
Template:Navbox Java Edition technical
Minecraft:de:Dichtefunktion Minecraft:fr:Fonction de densité Minecraft:ko:밀도 함수 Minecraft:pt:Função de densidade Minecraft:zh:密度函数