This article needs to be updated.
Please update this article to reflect recent updates or newly available information. The
talk page may contain suggestions.
Reason: Add "interval_select" function.
Density functions make up mathematical expressions to obtain a number from a position, stored as JSON files within a data pack in the path data/<namespace>/worldgen/density_function. They are referenced from the noise router in noise settings.
A density function can be a constant number or an object.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type.
- Other additional fields depend on the value of [String] type, described below.
If the [String] type is constant, a shorthand format is:
- [Double]: A constant number. Value between −1000000.0 and 1000000.0 (both inclusive).
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.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
interpolated).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input to be interpolated.
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.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
flat_cache).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input to be cached.
Only computes the input density once per horizontal position.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
cache_2d).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input to be cached.
If this density function is referenced twice, it is only computed once per block position.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
cache_once).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input to be cached.
Used by the game onto final_density and should not be referenced in data packs.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
cache_all_in_cell).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input to be cached.
Calculates the absolute value of the input density function.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
abs).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input of the calculation.
Squares the input. (x^2)
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
square).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input of the calculation.
Cubes the input (x^3).
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
cube).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input of the calculation.
If the input is negative, returns half of the input. Otherwise returns the input. (x < 0 ? x/2 : x)
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
half_negative).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input of the calculation.
If the input is negative, returns a quarter of the input. Otherwise returns the input. (x < 0 ? x/4 : x)
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
quarter_negative).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input of the calculation.
First clamps the input between −1 and 1, then transforms it using x/2 - x*x*x/24.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
squeeze).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input of the calculation.
Inverts the input (1/x).
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
invert).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The input of the calculation.
Adds two density functions together.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
add).
- [String][Double][NBT Compound / JSON Object] argument1: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The first input of the calculation.
- [String][Double][NBT Compound / JSON Object] argument2: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The second input of the calculation.
Multiplies two inputs.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
mul).
- [String][Double][NBT Compound / JSON Object] argument1: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The first input of the calculation.
- [String][Double][NBT Compound / JSON Object] argument2: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The second input of the calculation.
Returns the minimum of two inputs.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
min).
- [String][Double][NBT Compound / JSON Object] argument1: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The first input of the calculation.
- [String][Double][NBT Compound / JSON Object] argument2: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The second input of the calculation.
Returns the maximum of two inputs.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
max).
- [String][Double][NBT Compound / JSON Object] argument1: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The first input of the calculation.
- [String][Double][NBT Compound / JSON Object] argument2: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The second input of the calculation.
Used in vanilla for smooth transition to chunks generated in old versions.[more information needed]
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
blend_alpha).
Used in vanilla for smooth transition to chunks generated in old versions.[more information needed]
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
blend_offset).
Used in vanilla for smooth transition to chunks generated in old versions.[more information needed]
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
blend_density).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The desired density of new chunks.
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.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
beardifier).
Samples a legacy noise. [more information needed]
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
old_blended_noise).
- [Double] xz_scale: Value between 0.001 and 1000.0 (both inclusive).
- [Double] y_scale: Value between 0.001 and 1000.0 (both inclusive).
- [Double] xz_factor: Value between 0.001 and 1000.0 (both inclusive).
- [Double] y_factor: Value between 0.001 and 1000.0 (both inclusive).
- [Double] smear_scale_multiplier: Value between 1.0 and 8.0 (both inclusive).
Samples a noise.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
noise).
- [String] noise: One noise (an [String] ID) — The noise to sample.
- [Double] xz_scale: Scales the X and Z before sampling.
- [Double] y_scale: Scales the Y before sampling.
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.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
end_islands).
Similar to noise, but first shifts the input coordinates.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
shifted_noise).
- [String] noise: One noise (an [String] ID) — The noise to sample.
- [Double] xz_scale: Scales the X and Z before sampling.
- [Double] y_scale: Scales the Y before sampling.
- [String][Double][NBT Compound / JSON Object] shift_x: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — offset of the position in the X direction.
- [String][Double][NBT Compound / JSON Object] shift_y: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — offset of the position in the Y direction.
- [String][Double][NBT Compound / JSON Object] shift_z: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — offset of the position in the Z direction.
Computes the input value, and depending on that result returns one of two other density functions. Basically an if-then-else statement.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
range_choice).
- [String][Double][NBT Compound / JSON Object] input: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The value to compare
- [Double] min_inclusive: The lower bound of the range. Value between −1000000.0 and 1000000.0 (both inclusive).
- [Double] max_exclusive: The upper bound of the range. Value between −1000000.0 and 1000000.0 (both inclusive).
- [String][Double][NBT Compound / JSON Object] when_in_range: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — Used when the input is inside the range.
- [String][Double][NBT Compound / JSON Object] when_out_of_range: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — Used when the input is outside the range.
Samples a noise at (x/4, 0, z/4), then multiplies it by 4.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
shift_a).
- [String] argument: One noise (an [String] ID) — The noise to sample.
Samples a noise at (z/4, x/4, 0), then multiplies it by 4.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
shift_b).
- [String] argument: One noise (an [String] ID) — The noise to sample.
Samples a noise at (x/4, y/4, z/4), then multiplies it by 4.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
shift).
- [String] argument: One noise (an [String] ID) — The noise to sample.
Clamps the input between two values.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
clamp).
- [Double][NBT Compound / JSON Object] input: One density function (a new [Double][NBT Compound / JSON Object] density function definition, an [String]ID is not allowed here[1]) — The input to clamp.
- [Double] min: The lower bound. Value between −1000000.0 and 1000000.0 (both inclusive).
- [Double] max: The upper bound. Value between −1000000.0 and 1000000.0 (both inclusive).
Computes a cubic spline.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
spline).
- [Float][NBT Compound / JSON Object] spline: The spline. Can be either a number or an object.
- [String][Double][NBT Compound / JSON Object] coordinate: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — Input determining the location on the spline.
- [NBT List / JSON Array] points: (Cannot be empty) List of points of the cubic spline.
- [NBT Compound / JSON Object]: A point of the cubic spline.
- [Float] location: The location of this point.
- [Float][NBT Compound / JSON Object] value: The value of this point. Can be either a number or a spline object.
- [Float] derivative: The slope at this point.
A constant value.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
constant).
- [Double] argument: A constant value. Value between −1000000.0 and 1000000.0 (both inclusive).
Clamps the Y coordinate between from_y and to_y and then linearly maps it to a range.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
y_clamped_gradient).
- [Int] from_y: The value to be mapped to
from_value. Value between −4064 and 4062 (both inclusive).
- [Int] to_y: The value to be mapped to
to_value. Value between −4064 and 4062 (both inclusive).
- [Double] from_value: The value to map
from_y to. Value between −1000000.0 and 1000000.0 (both inclusive).
- [Double] to_value: The value to map
to_y to. Value between −1000000.0 and 1000000.0 (both inclusive).
Scans through a column of an input density and returns the topmost y-level that is above 0. If no such position exists within the bounds, the [Int] lower_bound is returned.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
find_top_surface).
- [String][Double][NBT Compound / JSON Object] density: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The density function to scan.
- [String][Double][NBT Compound / JSON Object] upper_bound: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — The y-level to start the scan at. Usually a 2D density function.
- [Int] lower_bound: The y-level to stop the scan.
- [Int] cell_height: The resolution of the scan. E.g. if set to
4, then only every 4th block is checked.
This section describes content that has been removed from
Minecraft.
This feature was present in earlier versions of
Minecraft, but has since been removed.
Removed in 22w12a
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
slide).
- [String][Double][NBT Compound / JSON Object] argument: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition)
Removed in 22w11a
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
spline).
- [Float][NBT Compound / JSON Object] spline: The spline. Can be either a number or an object.
- [String][Double][NBT Compound / JSON Object] coordinate: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition) — Input determining the location on the spline.
- [NBT List / JSON Array] points: (Cannot be empty) List of points of the cubic spline.
- [Float] location: The location of this point.
- [Float][NBT Compound / JSON Object] value: The value of this point. Can be either a number or a spline object.
- [Float] derivative: The slope at this point.
- [Double] min_value: The min value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
- [Double] max_value: The max value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
Removed in 22w11a
Calculate the spline from the noise settings.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
terrain_shaper_spline).
- [String] spline: Can be
offset, factor, orjaggedness.
- [Double] min_value: The min value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
- [Double] max_value: The max value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
- [String][Double][NBT Compound / JSON Object] continentalness: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition)
- [String][Double][NBT Compound / JSON Object] erosion: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition)
- [String][Double][NBT Compound / JSON Object] weirdness: One (an [String] ID, or a new [Double][NBT Compound / JSON Object] density function definition)
Removed in 26.2-snap5
According to the input value, scales and enhances (or weakens) some regions of the specified noise, and then returns the absolute value.
- [NBT Compound / JSON Object]: Root object.
- [String] type: The ID of the density function type (in this case,
weird_scaled_sampler).
- [String] rarity_value_mapper: Can be
type_1(The minimum scale is 0.75, and the maximum is 2.0)or type_2(The minimum scale is 0.5, and the maximum is 3.0.)
- [String] noise: One noise (an [String] ID) — The noise to sample.
- [String][Double][NBT Compound / JSON Object] input: 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.
| Java Edition |
|---|
| 1.18.2 | pre1 | Added density functions: abs, add, beardifier, blend_alpha, blend_density, blend_offset, cache_2d, cache_all_in_cell, cache_once, clamp, constant, cube, end_islands, flat_cache, half_negative, interpolated, max, min, mul, noise, old_blended_noise, quarter_negative, range_choice, shift, shift_a, shift_b, shifted_noise, slide, square, squeeze, terrain_shaper_spline, weird_scaled_sampler, and y_clamped_gradient. |
|---|
| pre2 | Added density function spline. |
|---|
| 1.19 | 22w11a | Removed density function terrain_shaper_spline. |
|---|
Removed min_value and max_value fields in spline. |
| 22w12a | Removed density function slide. Instead a combination of add, mul, and y_clamped_gradient is used to achieve the same result. |
|---|
Added fields to old_blended_noise density function: xz_scale, y_scale, xz_factor, y_factor, and smear_scale_multiplier. |
| 1.21.9 | 25w31a | Added density functions minecraft:find_top_surface and minecraft:invert. |
|---|
| 26.2 | snap5 | Added density function minecraft:interval_select. |
|---|
Removed density function minecraft:weird_scale_sampler. Its functionality has been replaced with interval_select. |
Issues relating to "Density function" are maintained on the bug tracker. Issues should be reported and viewed there.