Minecraft Wiki
Advertisement
Information icon
This feature is exclusive to Java Edition. 

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.

JSON Format[]

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

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

If the  type is constant, a shorthand format is:

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

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

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

  • : Root object.
    •  type: The ID of the density function type (in this case, flat_cache).
    •  argument: 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.
    •  type: The ID of the density function type (in this case, cache_2d).
    •  argument: 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.
    •  type: The ID of the density function type (in this case, cache_once).
    •  argument: 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 final_density and should not be referenced in data packs.

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

Functions with one argument[]

abs[]

Calculates the absolute value of the input density function.

  • : Root object.
    •  type: The ID of the density function type (in this case, abs).
    •  argument: 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. (x^2)

  • : Root object.
    •  type: The ID of the density function type (in this case, square).
    •  argument: 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 (x^3).

  • : Root object.
    •  type: The ID of the density function type (in this case, cube).
    •  argument: 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. (x < 0 ? x/2 : x)

  • : Root object.
    •  type: The ID of the density function type (in this case, half_negative).
    •  argument: 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. (x < 0 ? x/4 : x)

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

Functions with two arguments[]

add[]

Adds two density functions together.

  • : Root object.
    •  type: The ID of the density function type (in this case, add).
    •  argument1: 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.
    •  argument2: 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.
    •  type: The ID of the density function type (in this case, mul).
    •  argument1: 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.
    •  argument2: 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.
    •  type: The ID of the density function type (in this case, min).
    •  argument1: 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.
    •  argument2: 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.
    •  type: The ID of the density function type (in this case, max).
    •  argument1: 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.
    •  argument2: 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.

Other density functions[]

blend_alpha[]

Used in vanilla for smooth transition between legacy and new chunks.[more information needed]

  • : Root object.
    •  type: The ID of the density function type (in this case, blend_alpha).

blend_offset[]

Used in vanilla for smooth transition between legacy and new chunks.[more information needed]

  • : Root object.
    •  type: The ID of the density function type (in this case, blend_offset).

blend_density[]

Used in vanilla for smooth transition between legacy and new chunks.[more information needed]

  • : Root object.
    •  type: The ID of the density function type (in this case, blend_density).
    •  argument: 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 terrain_adaptation field in Configured Structure Feature). Its value is added to the final_density in noise setting by the game. Should not be referenced in data packs.

  • : Root object.
    •  type: The ID of the density function type (in this case, beardifier).

old_blended_noise[]

Samples a legacy noise. [more information needed]

  • : Root object.
    •  type: The ID of the density function type (in this case, old_blended_noise).
    •  xz_scale: Value between 0.001 and 1000.0 (both inclusive).
    •  y_scale: Value between 0.001 and 1000.0 (both inclusive).
    •  xz_factor: Value between 0.001 and 1000.0 (both inclusive).
    •  y_factor: Value between 0.001 and 1000.0 (both inclusive).
    •  smear_scale_multiplier: Value between 1.0 and 8.0 (both inclusive).

noise[]

Samples a noise.

  • : Root object.
    •  type: The ID of the density function type (in this case, noise).
    •  noise: An ID of a noise.
    •  xz_scale: Scales the X and Z before sampling.
    •  y_scale: 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.
    •  type: The ID of the density function type (in this case, end_islands).

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.
    •  type: The ID of the density function type (in this case, weird_scaled_sampler).
    •  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.
    •  noise: An ID of a noise.
    •  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.

shifted_noise[]

Similar to noise, but first shifts the input coordinates.

  • : Root object.
    •  type: The ID of the density function type (in this case, shifted_noise).
    •  noise: An ID of a noise.
    •  xz_scale: Scales the X and Z before sampling.
    •  y_scale: Scales the Y before sampling.
    •  shift_x: 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.
    •  shift_y: 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.
    •  shift_z: 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.
    •  type: The ID of the density function type (in this case, range_choice).
    •  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.
    •  min_inclusive: The lower bound of the range. Value between −1000000.0 and 1000000.0 (both inclusive).
    •  max_exclusive: The upper bound of the range. Value between −1000000.0 and 1000000.0 (both inclusive).
    •  when_in_range: 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.
    •  when_out_of_range: 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 (x/4, 0, z/4), then multiplies it by 4.

  • : Root object.
    •  type: The ID of the density function type (in this case, shift_a).
    •  argument: An ID of a noise.

shift_b[]

Samples a noise at (z/4, x/4, 0), then multiplies it by 4.

  • : Root object.
    •  type: The ID of the density function type (in this case, shift_b).
    •  argument: An ID of a noise.

shift[]

Samples a noise at (x/4, y/4, z/4), then multiplies it by 4.

  • : Root object.
    •  type: The ID of the density function type (in this case, shift).
    •  argument: An ID of a noise.

clamp[]

Clamps the input between two values.

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

spline[]

Computes a cubic spline.

  • : Root object.
    •  type: The ID of the density function type (in this case, spline).
    •  spline: The spline. Can be either a number or an object.
      •  coordinate: 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.
      •  points: (Cannot be empty) List of points of the cubic spline.
        •  location: The location of this point.
        •  value: The value of this point. Can be either a number or a spline object.
        •  derivative: The slope at this point.

constant[]

A constant value.

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

y_clamped_gradient[]

Clamps the Y coordinate between from_y and to_y and then linearly maps it to a range.

  • : Root object.
    •  type: The ID of the density function type (in this case, y_clamped_gradient).
    •  from_y: The value to be mapped to from_value. Value between −4064 and 4062 (both inclusive).
    •  to_y: The value to be mapped to to_value. Value between −4064 and 4062 (both inclusive).
    •  from_value: The value to map from_y to. Value between −1000000.0 and 1000000.0 (both inclusive).
    •  to_value: The value to map to_y to. Value between −1000000.0 and 1000000.0 (both inclusive).

Removed density functions[]

This section describes content that exists only in outdated versions of Minecraft. 
This feature used to be in the game, but has ever since been removed.It may or may not return in a future update.

slide[]

Removed in 22w12a

  • : Root object.
    •  type: The ID of the density function type (in this case, slide).
    •  argument: 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.
    •  type: The ID of the density function type (in this case, spline).
    •  spline: The spline. Can be either a number or an object.
      •  coordinate: 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.
      •  points: (Cannot be empty) List of points of the cubic spline.
        •  location: The location of this point.
        •  value: The value of this point. Can be either a number or a spline object.
        •  derivative: The slope at this point.
    •  min_value: The min value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
    •  max_value: 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.
    •  type: The ID of the density function type (in this case, terrain_shaper_spline).
    •  spline: Can be offset, factor, orjaggedness.
    •  min_value: The min value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
    •  max_value: The max value of the output. Value between −1000000.0 and 1000000.0 (both inclusive).
    •  continentalness: Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
    •  erosion: Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.
    •  weirdness: Can be an ID of a density function, or a density function in the form of a JSON object or a constant number.

History[]

Java Edition
1.18.2pre1Added 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.
pre2Added density function spline.
1.1922w11aRemoved density function terrain_shaper_spline.
Removed min_value and max_value fields in spline.
22w12aRemoved 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.

External links[]

This article references Guide of density function by Misode and Technical changelog by Misode.

Advertisement