Density function

Helpers that build a minecraft:density_function object, one for each of its types. Where a field takes one, write the helper's call; its name is the type it makes. Click a type to see what it accepts.

Abs

Abs

The absolute value of input. Turns a noise into sharp ridges along its zero line.

Abs(input)
input
DensityFunctionRef

Add

Add

left + right. Usually written with +.

Add(left, right)
left
DensityFunctionRef
right
DensityFunctionRef
DensityFunction raised = Noise(minecraft:ridge, 1, 0) + 0.2

Beardifier

Beardifier

Adds density around structures that adapt the terrain, such as villages and ancient cities. Vanilla adds it to final_density.

Beardifier()

BlendAlpha

BlendAlpha

Blending with chunks from before 1.18: 1 in new chunks, lower near old ones.

BlendAlpha()

BlendDensity

BlendDensity

Blends input with the terrain of chunks from before 1.18. In new chunks it is input unchanged.

BlendDensity(input)
input
DensityFunctionRef

BlendOffset

BlendOffset

Blending with chunks from before 1.18: 0 in new chunks.

BlendOffset()

Cache

Cache

Computes input once per position, for a function used in several places. The value is unchanged.

Cache(input)
input
DensityFunctionRef

Ceil

Ceil

Rounds input up to a whole multiple of multiple.

Ceil(input, multiple?)
input
DensityFunctionRef
multipleoptional
DensityFunctionRef

Defaults to constant 1.

Clamp

Clamp

Keeps input between min and max.

Clamp(input, min, max)
input
DensityFunctionRef
min
NoiseRange

The lowest value let through.

max
NoiseRange

The highest value let through.

DensityFunction capped = Clamp(Noise(minecraft:ridge, 1, 1), -0.5, 0.5)

Constant

Constant

The same number everywhere. A plain number does the same thing.

Constant(value)
value
NoiseRange

The number.

DensityFunction half = Constant(0.5)

Cube

Cube

input * input * input. Keeps the sign and flattens values near 0.

Cube(input)
input
DensityFunctionRef

DistanceToPoint

DistanceToPoint
DistanceToPoint(point, metric)
point
list of int (exactly 3)
metric
DistanceMetric

Div

Div

left / right. Usually written with /.

Div(left, right)
left
DensityFunctionRef
right
DensityFunctionRef

EndOuterIslands

EndOuterIslands

The End's island terrain: the main island in the middle, and scattered islands beyond 1024 blocks.

EndOuterIslands()

FindTopSurface

FindTopSurface
FindTopSurface(density, upper_bound, lower_bound, cell_height)
density
DensityFunctionRef
upper_bound
DensityFunctionRef
lower_bound
int -4064..4062
cell_height
int 1..

Floor

Floor

Rounds input down to a whole multiple of multiple. Rounding a gradient makes terraces.

Floor(input, multiple?)
input
DensityFunctionRef
multipleoptional
DensityFunctionRef

Defaults to constant 1.

Gradient

Gradient

Changes linearly along one axis: from_value at from_coordinate, to_value at to_coordinate. Beyond the two coordinates it holds the end values, unless tiling says otherwise. Use it to make terrain solid at the bottom and air at the top.

Gradient(axis, from_coordinate, to_coordinate, from_value, to_value, tiling?)
axis
Axis

The axis the gradient runs along: x, y or z.

from_coordinate
any (depends on axis)

Where the gradient starts, in blocks.

to_coordinate
any (depends on axis)

Where the gradient ends, in blocks.

from_value
NoiseRange

The value at from_coordinate.

to_value
NoiseRange

The value at to_coordinate.

tilingoptional
TilingMode

What happens beyond the two coordinates: clamp_to_edge holds the end values, repeat starts over, mirrored_repeat runs back and forth. Defaults to clamp_to_edge.

DensityFunction ground = Gradient(
  axis = y,
  from_coordinate = 0,
  to_coordinate = 128,
  from_value = 1,
  to_value = -1,
)

HalfNegative

HalfNegative

input, with negative values halved. Vanilla uses it to soften cave walls.

HalfNegative(input)
input
DensityFunctionRef

Interpolated

Interpolated

Computes input only at the corners of cells and blends between them. Smoother and much faster than sampling every block; vanilla wraps its terrain in it.

Interpolated(input, cell_size_xz, cell_size_y)
input
DensityFunctionRef

The function to interpolate.

cell_size_xz
int 1..

Cell width, in blocks.

cell_size_y
int 1..

Cell height, in blocks.

IntervalSelect

IntervalSelect

Picks one of functions by which interval of thresholds the value of input falls in: below the first threshold picks the first function, and so on.

IntervalSelect(input, thresholds, functions)
input
DensityFunctionRef
thresholds
list of NoiseRange (at least 1)

Must have exactly one fewer element than functions.

functions
list of DensityFunctionRef (at least 2)

Must have exactly one more element than thresholds.

Lerp

Lerp

Blends from first to second by alpha: first where alpha is 0, second where it is 1.

Lerp(alpha, first, second)
alpha
DensityFunctionRef

How far to blend, usually from 0 to 1.

first
DensityFunctionRef

The value where alpha is 0.

second
DensityFunctionRef

The value where alpha is 1.

Log

Log

The natural logarithm of input.

Log(input)
input
DensityFunctionRef

Max

Max

The larger of the two inputs. Max(a, b) joins two terrains.

Max(left, right)
left
DensityFunctionRef
right
DensityFunctionRef
DensityFunction both = Max(Noise(minecraft:ridge, 1, 0), Noise(minecraft:jagged, 1, 0))

Min

Min

The smaller of the two inputs. Min(a, b) keeps the lower of two terrains.

Min(left, right)
left
DensityFunctionRef
right
DensityFunctionRef

Mul

Mul

left * right. Usually written with *. Vanilla stops computing right where left is 0.

Mul(left, right)
left
DensityFunctionRef
right
DensityFunctionRef

Negate

Negate

-input. Usually written with a leading -.

Negate(input)
input
DensityFunctionRef

Noise

Noise

Samples a noise at the block's position, scaled per axis. The result is roughly between -1 and 1. Most terrain starts here.

Noise(noise, xz_scale, y_scale, shift_x?, shift_y?, shift_z?)
noise
NoiseParametersRef

The noise, by id: a Noise declaration or a vanilla one such as minecraft:ridge.

xz_scale
number

Multiplies x and z before sampling. Below 1 stretches the noise out horizontally; above 1 squeezes it.

y_scale
number

Multiplies y before sampling. 0 makes the noise the same at every height (2D).

shift_xoptional
DensityFunctionRef

Added to x before sampling, so the noise doesn't line up with others. Vanilla uses ShiftA. Defaults to constant 0.

shift_yoptional
DensityFunctionRef

Added to y before sampling. Defaults to constant 0.

shift_zoptional
DensityFunctionRef

Added to z before sampling. Vanilla uses ShiftB. Defaults to constant 0.

Noise hills { base_octave = -7, amplitude_modifiers = [1, 1] }
DensityFunction land = Noise(hills, 1, 0) * 0.5

OldBlendedNoise

OldBlendedNoise

The 3D terrain noise from before 1.18, which vanilla still uses as the base of overworld and nether terrain.

OldBlendedNoise(xz_scale, y_scale, xz_factor, y_factor, smear_scale_multiplier)
xz_scale
number
y_scale
number
xz_factor
number
y_factor
number
smear_scale_multiplier
number 1..8

Pow

Pow

base raised to the power exponent.

Pow(base, exponent)
base
DensityFunctionRef
exponent
DensityFunctionRef

QuarterNegative

QuarterNegative

input, with negative values divided by four.

QuarterNegative(input)
input
DensityFunctionRef

RangeChoice

RangeChoice

Picks between two functions by the value of input: when_in_range where min_inclusive <= input < max_exclusive, when_out_of_range elsewhere. Only the chosen one is computed.

RangeChoice(input, min_inclusive, max_exclusive, when_in_range, when_out_of_range)
input
DensityFunctionRef

The value to test.

min_inclusive
NoiseRange

The lowest value that counts as in range.

max_exclusive
NoiseRange

The value above the range; it counts as out of range.

when_in_range
DensityFunctionRef

Used where input is in range.

when_out_of_range
DensityFunctionRef

Used everywhere else.

Reciprocal

Reciprocal

1 / input.

Reciprocal(input)
input
DensityFunctionRef

Round

Round

Rounds input to the nearest whole multiple of multiple.

Round(input, multiple?)
input
DensityFunctionRef
multipleoptional
DensityFunctionRef

Defaults to constant 1.

Shift

Shift

Samples noise at a quarter of the block's x, y and z and multiplies it by 4. Used as a shift for another noise.

Shift(noise)
noise
NoiseParametersRef

ShiftA

ShiftA

Samples noise at a quarter of the block's x and z (y is 0) and multiplies it by 4. Vanilla uses it as shift_x of its climate noises.

ShiftA(noise)
noise
NoiseParametersRef

ShiftB

ShiftB

Like ShiftA, with x and z swapped. Vanilla uses it as shift_z of its climate noises.

ShiftB(noise)
noise
NoiseParametersRef

Sign

Sign

-1, 0 or 1, following the sign of input.

Sign(input)
input
DensityFunctionRef

Slice

Slice
Slice(axis, coordinate, input)
axis
Axis
coordinate
int
input
DensityFunctionRef

Slide

Slide
Slide(input)
input
DensityFunctionRef

Spline

Spline

Maps a value through a cubic spline: a curve through points, each with a location, a value and a derivative. Vanilla shapes continents, erosion and peaks into terrain height with splines.

Spline(spline)
spline
CubicSpline

Sqrt

Sqrt

The square root of input.

Sqrt(input)
input
DensityFunctionRef

Square

Square

input * input. Always 0 or more, and flattens values near 0.

Square(input)
input
DensityFunctionRef

Squeeze

Squeeze

Clamps input to -1..1, then bends it to x / 2 - x³ / 24. Vanilla applies it near the end of final_density to smooth sharp values.

Squeeze(input)
input
DensityFunctionRef

Sub

Sub

left - right. Usually written with -.

Sub(left, right)
left
DensityFunctionRef
right
DensityFunctionRef

Truncate

Truncate

Rounds input toward zero, to a whole multiple of multiple.

Truncate(input, multiple?)
input
DensityFunctionRef
multipleoptional
DensityFunctionRef

Defaults to constant 1.