Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Density function

From SAS Gaming Wiki

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.

Template:TOC

JSON format

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

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

cache_2d

Only computes the input density once per horizontal position.

cache_all_in_cell

Used by the game onto final_density and should not be referenced in data packs.

cache_once

If this density function is referenced twice, it is only computed once per block position.

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.

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.

Mapped density functions

abs

Calculates the absolute value of the input density function.

cube

Cubes the input (x^3).

half_negative

If the input is negative, returns half of the input. Otherwise returns the input. (x < 0 ? x/2 : x)

interval_select

Selects between a number of density functions based on an input density function and a set of threshold values.

invert

Named Template:Cd.Template:Upcoming Inverts the input (1/x).

quarter_negative

If the input is negative, returns a quarter of the input. Otherwise returns the input. (x < 0 ? x/4 : x)

square

Squares the input. (x^2)

squeeze

First clamps the input between −1 and 1, then transforms it using x/2 - x*x*x/24.

Functions with two arguments

add

Adds two density functions together.

div

Performs division between two arguments.Template:Upcoming

mul

Multiplies two inputs.

min

Returns the minimum of two inputs.

max

Returns the maximum of two inputs.

sub

Performs subtraction between two arguments.Template:Upcoming

Other density functions

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.

blend_alpha

Used in vanilla for smooth transition to chunks generated in old versions.Template:Info needed

blend_density

Used in vanilla for smooth transition to chunks generated in old versions.Template:Info needed

blend_offset

Used in vanilla for smooth transition to chunks generated in old versions.Template:Info needed

ceil

Rounds the input value to positive infinity.Template:Upcoming

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, ceil).
    • Template:Nbt: The input to round.
    • Template:Nbt: The output will be rounded to an integer multiple of this value. If not specified, it defaults to a constant 1.

clamp

Clamps the input between two values.

constant

A constant value.

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.

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 within the bounds, the Template:Nbt is returned.

floor

Rounds the input value to negative infinity.Template:Upcoming

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, floor).
    • Template:Nbt: The input to round.
    • Template:Nbt: The output will be rounded to an integer multiple of this value. If not specified, it defaults to a constant 1.

lerp

Performs (unclamped) linear interpolation between two arguments based on an alpha.Template:Upcoming

negate

Negates the input.Template:Upcoming

noise

Samples a noise.

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

range_choice

Computes the input value, and depending on that result returns one of two other density functions. Basically an if-then-else statement.

round

Rounds the input value to to the nearest integer (ties round up).Template:Upcoming

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, round).
    • Template:Nbt: The input to round.
    • Template:Nbt: The output will be rounded to an integer multiple of this value. If not specified, it defaults to a constant 1.

shift

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

shift_a

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

shift_b

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

shifted_noise

Similar to noise, but first shifts the input coordinates.

spline

Computes a cubic spline.

truncate

Rounds the input value to 0.Template:Upcoming

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, truncate).
    • Template:Nbt: The input to round.
    • Template:Nbt: The output will be rounded to an integer multiple of this value. If not specified, it defaults to a constant 1.

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_y to. Value between −1000000.0 and 1000000.0 (both inclusive).
    • Template:Nbt: The value to map to_y to. Value between −1000000.0 and 1000000.0 (both inclusive).

Removed density functions

Template:Outdated

slide

Removed in Minecraft:22w12a

The legacy "spline"

Removed in Minecraft:22w11a

terrain_shaper_spline

Removed in Minecraft:22w11a

Calculate the spline from the noise settings.

weird_scaled_sampler

Removed in Minecraft: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.

History

Template:HistoryTable

Issues

Template:Issue list

References

Template:Reflist

External links

Navigation

Template:Navbox Java Edition technical

Minecraft:de:Dichtefunktion Minecraft:fr:Fonction de densité Minecraft:ko:밀도 함수 Minecraft:pt:Função de densidade Minecraft:zh:密度函数