Density 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.

JSON Format
A density function can be a constant number or an object.


 * : Root object.
 * : The ID of the density function type.
 * Other additional fields depend on the value of, described below.

If the is , a shorthand format is:


 * : A constant number. Value between −1000000.0 and 1000000.0 (both inclusive).

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  and. Used often in combination with.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

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.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

cache_2d
Only computes the input density once per horizonal position.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

cache_once
If this density function is referenced twice, it is only computed once per block position.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

cache_all_in_cell
Used by the game onto  and should not be referenced in data packs.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

abs
Calculates the absolute value of the input density function.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

square
Squares the input.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

cube
Cubes the input.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

half_negative
If the input is negative, returns half of the input. Otherwise returns the input.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

quarter_negative
If the input is negative, returns a quarter of the input. Otherwise returns the input.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : A 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.

squeeze
First clamps the input between −1 and 1, then transforms it using x/2 - x*x*x/24.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

add
Adds two density functions together.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : A 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.
 * : A 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.

mul
Multiplies two inputs.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : A 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.
 * : A 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.

min
Returns the mininum of two inputs.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : A 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.
 * : A 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.

max
Returns the maximum of two inputs.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : A 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.
 * : A 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.

blend_alpha
Used in vanilla for smooth transition between legacy and new chunks.
 * : Root object.
 * : The ID of the density function type (in this case, ).

blend_offset
Used in vanilla for smooth transition between legacy and new chunks.
 * : Root object.
 * : The ID of the density function type (in this case, ).

blend_density
Used in vanilla for smooth transition between legacy and new chunks.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

beardifier
Adds beards for structures (see the  field in Configured Structure Feature). Its value is added to the  in noise setting by the game. Should not be referenced in data packs.
 * : Root object.
 * : The ID of the density function type (in this case, ).

old_blended_noise
Samples a legacy noise.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : Value between 0.001 and 1000.0 (both inclusive).
 * : Value between 0.001 and 1000.0 (both inclusive).
 * : Value between 0.001 and 1000.0 (both inclusive).
 * : Value between 0.001 and 1000.0 (both inclusive).
 * : Value between 1.0 and 8.0 (both inclusive).

noise
Samples a noise.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : An ID of a noise, or a noise object.
 * : Scales the X and Z before sampling.
 * : Scales the Y before sampling.

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.
 * : Root object.
 * : The ID of the density function type (in this case, ).

weird_scaled_sampler
According to the input value, scales and enhances (or weakens) some regions of the specified noise, and then returns the absolute value.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : Can be （The minimum scale is 0.75, and the maximum is 2.0）或 （The minimum scale is 0.5, and the maximum is 3.0）.
 * : An ID of a noise, or a noise object.
 * : 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.

shifted_noise
Similar to, but first shifts the input coordinates.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : An ID of a noise, or a noise object.
 * : Scales the X and Z before sampling.
 * : Scales the Y before sampling.
 * : Density function used to offset the X value. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
 * : Density function used to offset the Y value. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
 * : Density function used to offset the Z value. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.

range_choice
Computes the input value, and depending on that result returns one of two other density functions. Basically an if-then-else statement.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.
 * : The lower bound of the range. Value between −1000000.0 and 1000000.0 (both inclusive).
 * : The upper bound of the range. Value between −1000000.0 and 1000000.0 (both inclusive).
 * : Density function whose value is returned when the input is inside the range. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
 * : Density function whose value is returned when the input is outside the range. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.

shift_a
Samples a noise at, then multiplies it by 4.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : An ID of a noise, or a noise object.

shift_b
Samples a noise at, then multiplies it by 4.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : An ID of a noise, or a noise object.

shift
Samples a noise at, then multiplies it by 4.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : An ID of a noise, or a noise object.

clamp
Clamps the input between two values.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : The input density function. Can only be a density function in the form of a JSON object or a constant number.
 * : The lower bound. Value between −1000000.0 and 1000000.0 (both inclusive).
 * : The upper bound. Value between −1000000.0 and 1000000.0 (both inclusive).

spline
Computes a cubic spline.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : The spline. Can be either a number or an object.
 * : The density function used to get a location on the spline. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
 * : (Cannot be empty) List of points of the cubic spline.
 * : The location of this point.
 * : The value of this point. Can be either a number or a spline object.
 * : The slope at this point.

constant
A constant value.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : A constant value. Value between −1000000.0 and 1000000.0 (both inclusive).

y_clamped_gradient
Clamps the Y coordinate between  and   and then linearly maps it to a range.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : The value to be mapped to . Value between −4064 and 4062 (both inclusive).
 * : The value to be mapped to . Value between −4064 and 4062 (both inclusive).
 * : The value to map  to. Value between −1000000.0 and 1000000.0 (both inclusive).
 * : The value to map  to. Value between −1000000.0 and 1000000.0 (both inclusive).

slide
Removed in 22w12a
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : 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.

The legacy "spline"
Removed in 22w11a
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : The spline. Can be either a number or an object.
 * : The density function used to get a location on the spline. Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
 * : (Cannot be empty) List of points of the cubic spline.
 * : The location of this point.
 * : The value of this point. Can be either a number or a spline object.
 * : The slope at this point.
 * : The min value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
 * : The max value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).

terrain_shaper_spline
Removed in 22w11a

Calculate the spline from the noise settings.
 * : Root object.
 * : The ID of the density function type (in this case, ).
 * : Can be,  , or.
 * : The min value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
 * : The max value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
 * : Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
 * : Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
 * : Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.