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: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: new page from Minecraft
 
SyncBot (talk | contribs)
Sync: updated from Minecraft
 
(5 intermediate revisions by the same user not shown)
Line 20: Line 20:


== Marker functions ==
== Marker functions ==
=== interpolated ===
=== {{cd|cache_2d}} ===
Only computes the input density once per horizontal position.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_2d</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be cached.
</div>
 
=== {{cd|cache_all_in_cell}} ===
Used by the game onto <code>final_density</code> and should not be referenced in data packs.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_all_in_cell</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be cached.
</div>
 
=== {{cd|cache_once}} ===
If this density function is referenced twice, it is only computed once per block position.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_once</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be cached.
</div>
 
=== {{cd|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 <code>interpolated</code>.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>flat_cache</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be cached.
</div>
 
=== {{cd|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 <code>size_horizontal * 4</code> and <code>size_vertical * 4</code>. Used often in combination with <code>flat_cache</code>.
Interpolates at each block in one cell based on the input density function value of some cells around. The size of each cell is <code>size_horizontal * 4</code> and <code>size_vertical * 4</code>. Used often in combination with <code>flat_cache</code>.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>interpolated</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>interpolated</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input to be interpolated.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input to be interpolated.
</div>
 
== Noise sampling functions ==
These density functions are used to sample [[Minecraft:Custom noise|noises]].
 
=== {{cd|noise}} ===
Samples a noise.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>noise</code>).
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|double|xz_scale}}: Scales the X and Z before sampling.
** {{Nbt|double|y_scale}}: Scales the Y before sampling.
</div>
 
=== {{cd|old_blended_noise}} ===
Samples a legacy noise. {{Info needed}}
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>old_blended_noise</code>).
** {{Nbt|double|xz_scale}}: Value between 0.001 and 1000.0 (both inclusive).
** {{Nbt|double|y_scale}}: Value between 0.001 and 1000.0 (both inclusive).
** {{Nbt|double|xz_factor}}: Value between 0.001 and 1000.0 (both inclusive).
** {{Nbt|double|y_factor}}: Value between 0.001 and 1000.0 (both inclusive).
** {{Nbt|double|smear_scale_multiplier}}: Value between 1.0 and 8.0 (both inclusive).
</div>
</div>


=== flat_cache ===
=== {{cd|shift}} ===
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 <code>interpolated</code>.
Samples a noise at <code>(x/4, y/4, z/4)</code>, then multiplies it by 4.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>flat_cache</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input to be cached.
** {{Nbt|string|argument}}{{until|JE 26.3}} / {{nbt|string|noise}}{{upcoming|JE 26.3}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
</div>
</div>


=== cache_2d ===
=== {{cd|shift_a}} ===
Only computes the input density once per horizontal position.
Samples a noise at <code>(x/4, 0, z/4)</code>, then multiplies it by 4.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_2d</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift_a</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input to be cached.
** {{Nbt|string|argument}}{{until|JE 26.3}} / {{nbt|string|noise}}{{upcoming|JE 26.3}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
</div>
</div>


=== cache_once ===
=== {{cd|shift_b}} ===
If this density function is referenced twice, it is only computed once per block position.
Samples a noise at <code>(z/4, x/4, 0)</code>, then multiplies it by 4.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_once</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift_b</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input to be cached.
** {{Nbt|string|argument}}{{until|JE 26.3}} / {{nbt|string|noise}}{{upcoming|JE 26.3}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
</div>
</div>


=== cache_all_in_cell ===
=== {{cd|shifted_noise}} ===
Used by the game onto <code>final_density</code> and should not be referenced in data packs.
Similar to <code>noise</code>, but first shifts the input coordinates.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cache_all_in_cell</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shifted_noise</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input to be cached.
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|double|xz_scale}}: Scales the X and Z before sampling.
** {{Nbt|double|y_scale}}: Scales the Y before sampling.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_x}}: {{json ref/density function}} &mdash; offset of the position in the X direction.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_y}}: {{json ref/density function}} &mdash; offset of the position in the Y direction.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_z}}: {{json ref/density function}} &mdash; offset of the position in the Z direction.
</div>
</div>


== Mapped density functions ==
== Mathematical density functions ==
=== abs ===
These density functions are used to perform mathematical operations.
 
=== {{cd|abs}} ===
Calculates the absolute value of the input density function.
Calculates the absolute value of the input density function.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>abs</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>abs</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
 
=== {{cd|add}} ===
Adds two density functions together.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>add</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}{{until|JE 26.3}} / {{nbt|double|left}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}{{until|JE 26.3}} / {{nbt|double|right}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The second input of the calculation.
</div>
 
=== {{cd|ceil}} ===
Rounds the input value to positive infinity.{{upcoming|JE 26.3}}
 
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>ceil</code>).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function to round.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|multiple}}: The output will be rounded to an integer multiple of the value returned by this Density Function. If not specified, defaults to a constant 1.
</div>
</div>


=== square ===
=== {{cd|clamp}} ===
Squares the input. (<code>x^2</code>)
Clamps the input between two values.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>square</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>clamp</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: One density function &mdash; The input to clamp.
** {{Nbt|double|min}}: The lower bound. Value between −1000000.0 and 1000000.0 (both inclusive).
** {{Nbt|double|max}}: The upper bound. Value between −1000000.0 and 1000000.0 (both inclusive).
</div>
</div>


=== cube ===
=== {{cd|constant}} ===
Cubes the input (<code>x^3</code>).
A constant value.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cube</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>constant</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|double|argument}}{{until|JE 26.3}} / {{nbt|double|value}}{{upcoming|JE 26.3}}: A constant value. Value between −1000000.0 and 1000000.0 (both inclusive).
</div>
</div>


=== half_negative ===
=== {{cd|cube}} ===
If the input is negative, returns half of the input. Otherwise returns the input. (<code>x < 0 ? x/2 : x</code>)
Cubes the input (<code>x^3</code>).
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>half_negative</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>cube</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


=== quarter_negative ===
=== {{cd|div}} ===
If the input is negative, returns a quarter of the input. Otherwise returns the input. (<code>x < 0 ? x/4 : x</code>)
Performs division between two arguments.{{upcoming|JE 26.3}}
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>quarter_negative</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>div</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|left}} &mdash; The left-hand side of the operation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|right}} &mdash; The right-hand side of the operation.
</div>
</div>


=== squeeze ===
=== {{cd|floor}} ===
First clamps the input between −1 and 1, then transforms it using x/2 - x*x*x/24.
Rounds the input value to negative infinity.{{upcoming|JE 26.3}}
 
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>squeeze</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>floor</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function to round.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|multiple}}: The output will be rounded to an integer multiple of the value returned by this Density Function. If not specified, defaults to a constant 1.
</div>
</div>


=== invert ===
=== {{cd|invert}} ===
Renamed to {{cd|reciprocal}}.{{upcoming|JE 26.3}}
Inverts the input (<code>1/x</code>).
Inverts the input (<code>1/x</code>).
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>invert</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>invert</code>{{until|JE 26.3}} / <code>reciprocal</code>{{upcoming|JE 26.3}}).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


== Functions with two arguments ==
=== {{cd|log}} ===
=== add ===
Computes the natural logarithm of the given input.{{upcoming|JE 26.3}}
Adds two density functions together.
 
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>add</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>log</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function for which to compute the natural logarithm.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}: {{json ref/density function}} &mdash; The second input of the calculation.
</div>
</div>


=== mul ===
=== {{cd|mul}} ===
Multiplies two inputs.
Multiplies two inputs.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>mul</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>mul</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}{{until|JE 26.3}} / {{nbt|double|left}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}: {{json ref/density function}} &mdash; The second input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}{{until|JE 26.3}} / {{nbt|double|right}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The second input of the calculation.
</div>
</div>


=== min ===
=== {{cd|min}} ===
Returns the minimum of two inputs.
Returns the minimum of two inputs.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>min</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>min</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}{{until|JE 26.3}} / {{nbt|double|left}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}: {{json ref/density function}} &mdash; The second input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}{{until|JE 26.3}} / {{nbt|double|right}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The second input of the calculation.
</div>
</div>


=== max ===
=== {{cd|max}} ===
Returns the maximum of two inputs.
Returns the maximum of two inputs.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>max</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>max</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument1}}{{until|JE 26.3}} / {{nbt|double|left}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The first input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}: {{json ref/density function}} &mdash; The second input of the calculation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument2}}{{until|JE 26.3}} / {{nbt|double|right}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The second input of the calculation.
</div>
</div>


== Other density functions ==
=== {{cd|negate}} ===
=== blend_alpha ===
Negates the input.{{upcoming|JE 26.3}}
Used in vanilla for smooth transition to chunks generated in old versions.{{Info needed}}
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{nbt|string|type}}: The ID of the density function type (in this case, <code>negate</code>).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function to negate.
</div>
 
=== {{cd|pow}} ===
Raises the given base value to an exponent.{{upcoming|JE 26.3}}
 
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>pow</code>).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|base}}: the base value (Density Function).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|exponent}}: the exponent (Density Function).
</div>
 
=== {{cd|round}} ===
Rounds the input value to to the nearest integer (ties round up).{{upcoming|JE 26.3}}
 
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>round</code>).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function to round.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|multiple}}: The output will be rounded to an integer multiple of the value returned by this Density Function. If not specified, defaults to a constant 1.
</div>
 
=== {{cd|sub}} ===
Performs subtraction between two arguments.{{upcoming|JE 26.3}}
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>sub</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|left}} &mdash; The left-hand side of the operation.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|right}} &mdash; The right-hand side of the operation.
</div>
 
=== {{cd|sign}} ===
Computes the sign of the given input.  If positive, it returns as 1. If the input is 0, it returns 0. If negative, it returns as -1.{{upcoming|JE 26.3}}
 
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>sign</code>).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function for which to compute the sign.
</div>
 
=== {{cd|sqrt}} ===
Computes the square root of the given input.{{upcoming|JE 26.3}}
 
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>sqrt</code>).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function for which to compute the square root.
</div>
 
=== {{cd|square}} ===
Squares the input. (<code>x^2</code>)
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>blend_alpha</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>square</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
</div>
</div>


=== blend_offset ===
=== {{cd|truncate}} ===
Used in vanilla for smooth transition to chunks generated in old versions.{{Info needed}}
Rounds the input value to 0.{{upcoming|JE 26.3}}
 
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>blend_offset</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>truncate</code>).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function to round.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|multiple}}: The output will be rounded to an integer multiple of the value returned by this Density Function. If not specified, defaults to a constant 1.
</div>
</div>


=== blend_density ===
== Mapped density functions ==
Used in vanilla for smooth transition to chunks generated in old versions.{{Info needed}}
These density functions map a set of values onto another set of values.
 
=== {{cd|gradient}} ===
[[File:Gradient tiling.png|thumb|Demonstration of the different tiling options for the {{cd|gradient}} density function{{upcoming|JE 26.3}}, using both an input range of -100 to 100 and an output range of -1 to 1.]]
Clamps the given coordinate and maps the gradient to a range.{{upcoming|JE 26.3}}
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>blend_density</code>).
** {{nbt|string|type}}: The ID of the density function type (in this case, <code>gradient</code>).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}: {{json ref/density function}} &mdash; The desired density of new chunks.
** {{nbt|string|axis}}: {{cd|x}}, {{cd|y}}. or {{cd|z}}: The axis over which to define the gradient .
** {{nbt|string|tiling}}: How the density function handles values outside the specified coordinate range. 3 options:
*** <code>clamp_to_edge</code>: outside the gradient boundaries, the value at the nearest boundary will be used.
*** <code>repeat</code>: The gradient will be repeated outside its boundaries.
*** <code>mirrored_repeat</code>: The gradient will be repeated as such that odd repetitions are mirrored, ensuring continuity between repetitions.
** {{nbt|int|from_coordinate}}{{upcoming|JE 26.3}}: The coordinate at which the gradient starts.
** {{nbt|int|to_coordinate}}: The coordinate at which the gradient ends. It must not equal {{cd|from_coordinate}}.
** {{nbt|float|from_value}}: The value at which the gradient starts.
** {{nbt|float|to_value}}: The value at which the gradient ends.
</div>
</div>


=== beardifier ===
=== {{cd|lerp}} ===
Adds beards for structures (see the <code>terrain_adaptation</code> field in [[Minecraft:Structure/JSON format|structures]]). Its value is added to the <code>final_density</code> in noise setting by the game. Should not be referenced in data packs.
Performs (unclamped) linear interpolation between two arguments based on an alpha.{{upcoming|JE 26.3}} The returned value is: <code>first*(1-alpha) + second*alpha</code>
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>beardifier</code>).
** {{nbt|string|type}}: The ID of the density function type (in this case, <code>lerp</code>).
** {{nbt|string}}{{nbt|double}}{{nbt|compound|alpha}}: Density function representing the interpolation factor (e.g. 0 = first, 1 = second). Any value outside of {{cd|[0; 1]}} will extrapolate.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|first}}: Density Function to use at {{cd|<nowiki>alpha=0</nowiki>}}.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|second}}: Density Function to use at {{cd|<nowiki>alpha=1</nowiki>}}.
</div>
</div>


=== old_blended_noise ===
=== {{cd|squeeze}} ===
Samples a legacy noise. {{Info needed}}
First clamps the input between −1 and 1, then transforms it using x/2 - x*x*x/24.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>old_blended_noise</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>squeeze</code>).
** {{Nbt|double|xz_scale}}: Value between 0.001 and 1000.0 (both inclusive).
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|double|y_scale}}: Value between 0.001 and 1000.0 (both inclusive).
** {{Nbt|double|xz_factor}}: Value between 0.001 and 1000.0 (both inclusive).
** {{Nbt|double|y_factor}}: Value between 0.001 and 1000.0 (both inclusive).
** {{Nbt|double|smear_scale_multiplier}}: Value between 1.0 and 8.0 (both inclusive).
</div>
</div>


=== noise ===
=== {{cd|spline}} ===
Samples a [[Minecraft:Custom_noise|noise]].
Computes a cubic spline.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>noise</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>spline</code>).
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|float}}{{Nbt|compound|spline}}: The spline. Can be either a number or an object.
** {{Nbt|double|xz_scale}}: Scales the X and Z before sampling.
*** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|coordinate}}: {{json ref/density function}} &mdash; Input determining the location on the spline.
** {{Nbt|double|y_scale}}: Scales the Y before sampling.
*** {{Nbt|list|points}}: (Cannot be empty) List of points of the cubic spline.
**** {{Nbt|compound}}: A point of the cubic spline.
***** {{Nbt|float|location}}: The location of this point.
***** {{Nbt|float}}{{Nbt|compound|value}}: The value of this point. Can be either a number or a spline object.
***** {{Nbt|float|derivative}}: The slope at this point.
</div>
</div>


=== end_islands ===
=== {{cd|y_clamped_gradient}} ===
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.
Replaced with {{cd|gradient}}.{{upcoming|JE 26.3}}
 
Clamps the Y coordinate between <code>from_y</code> and <code>to_y</code> and then linearly maps it to a range.{{until|JE 26.3}}
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>end_islands</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>y_clamped_gradient</code>).
** {{Nbt|int|from_y}}: The value to be mapped to <code>from_value</code>. Value between −4064 and 4062 (both inclusive).
** {{Nbt|int|to_y}}: The value to be mapped to <code>to_value</code>. Value between −4064 and 4062 (both inclusive).
** {{Nbt|double|from_value}}: The value to map <code>from_y</code> to. Value between −1000000.0 and 1000000.0 (both inclusive).
** {{Nbt|double|to_value}}: The value to map <code>to_y</code> to. Value between −1000000.0 and 1000000.0 (both inclusive).
</div>
</div>


=== weird_scaled_sampler ===
== Conditional density functions ==
{{in development|section=1|JE||26.2|removed=1}}
These density functions are used to apply "if-then" logic.
According to the input value, scales and enhances (or weakens) some regions of the specified noise, and then returns the absolute value.
 
=== {{cd|half_negative}} ===
If the input is negative, returns half of the input. Otherwise returns the input. (<code>x < 0 ? x/2 : x</code>)
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>weird_scaled_sampler</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>half_negative</code>).
** {{Nbt|string|rarity_value_mapper}}: Can be <code>type_1</code>(The minimum scale is 0.75, and the maximum is 2.0)or <code>type_2</code>(The minimum scale is 0.5, and the maximum is 3.0.)
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
</div>
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|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.
</div><!--
TYPE2
if (d < −0.75) {
return 0.5;
} else if (d < −0.5) {
return 0.75;
} else if (d < 0.5) {
return 1.0;
} else {
return d < 0.75 ? 2.0 : 3.0;
}


TYPE1
=== {{cd|interval_select}} ===
if (d < −0.5) {
Selects between a number of density functions based on an input density function and a set of threshold values.
return 0.75;
<div class="treeview">
} else if (d < 0.0) {
* {{nbt|compound}}: Root object.
return 1.0;
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>interval_select</code>).
} else {
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: Density Function to be compared with any given {{cd|thresholds}}.
return d < 0.5 ? 1.5 : 2.0;
** {{nbt|list|thresholds}}: (List of Floats) The threshold values to compare {{cd|input}} with.
}
*** If the input value is less than the threshold values, the result of {{cd|functions[i]}} will be selected.
-->
*** If the input value is greater than the last threshold value, the last function will be selected.
*** There must be one fewer {{cd|thresholds}} than {{cd|functions}}.
** {{nbt|list|functions}}: The resulting functions (at least two) to be selected from.
*** There must be one more element in {{cd|functions}} than {{cd|thresholds}}.
</div>


=== shifted_noise ===
=== {{cd|quarter_negative}} ===
Similar to <code>noise</code>, but first shifts the input coordinates.
If the input is negative, returns a quarter of the input. Otherwise returns the input. (<code>x < 0 ? x/4 : x</code>)
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shifted_noise</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>quarter_negative</code>).
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The input of the calculation.
** {{Nbt|double|xz_scale}}: Scales the X and Z before sampling.
** {{Nbt|double|y_scale}}: Scales the Y before sampling.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_x}}: {{json ref/density function}} &mdash; offset of the position in the X direction.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_y}}: {{json ref/density function}} &mdash; offset of the position in the Y direction.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|shift_z}}: {{json ref/density function}} &mdash; offset of the position in the Z direction.
</div>
</div>


=== range_choice ===
=== {{cd|range_choice}} ===
Computes the input value, and depending on that result returns one of two other density functions. Basically an if-then-else statement.
Computes the input value, and depending on that result returns one of two other density functions. Basically an if-then-else statement.
<div class="treeview">
<div class="treeview">
Line 269: Line 425:
</div>
</div>


=== shift_a ===
== Other density functions ==
Samples a noise at <code>(x/4, 0, z/4)</code>, then multiplies it by 4.
=== {{cd|beardifier}} ===
Adds beards for structures (see the <code>terrain_adaptation</code> field in [[Minecraft:Structure/JSON format|structures]]). Its value is added to the <code>final_density</code> in noise setting by the game. Should not be referenced in data packs.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift_a</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>beardifier</code>).
** {{Nbt|string|argument}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
</div>
</div>


=== shift_b ===
=== {{cd|blend_alpha}} ===
Samples a noise at <code>(z/4, x/4, 0)</code>, then multiplies it by 4.
Used in vanilla for smooth transition to chunks generated in old versions.{{Info needed}}
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift_b</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>blend_alpha</code>).
** {{Nbt|string|argument}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
</div>
</div>


=== shift ===
=== {{cd|blend_density}} ===
Samples a noise at <code>(x/4, y/4, z/4)</code>, then multiplies it by 4.
Used in vanilla for smooth transition to chunks generated in old versions.{{Info needed}}
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>shift</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>blend_density</code>).
** {{Nbt|string|argument}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|argument}}{{until|JE 26.3}} / {{nbt|double|input}}{{upcoming|JE 26.3}}: {{json ref/density function}} &mdash; The desired density of new chunks.
</div>
</div>


=== clamp ===
=== {{cd|blend_offset}} ===
Clamps the input between two values.
Used in vanilla for smooth transition to chunks generated in old versions.{{Info needed}}
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>clamp</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>blend_offset</code>).
** {{Nbt|double}}{{Nbt|compound|input}}: One '''density function''' (a new {{Nbt|double}}{{Nbt|compound}} density function definition, an {{Nbt|string|}}[[Minecraft:resource location|ID]] is not allowed here<ref>{{cite bug|MC|252814|Clamp density function takes a direct input and doesn't allow a reference|date=June 11, 2022}}</ref>) &mdash; The input to clamp.
** {{Nbt|double|min}}: The lower bound. Value between −1000000.0 and 1000000.0 (both inclusive).
** {{Nbt|double|max}}: The upper bound. Value between −1000000.0 and 1000000.0 (both inclusive).
</div>
</div>


=== spline ===
=== {{cd|distance_to_point}} ===
Computes a cubic spline.
[[File:Distance to point options.png|thumb|Demonstration of the different metric options for the {{cd|distance_to_point}} density function{{upcoming|JE 26.3}}, using the distance from the point (0, 0).]]
<div class="treeview">
Computes the distance to a fixed point using the specified distance function.{{upcoming|JE 26.3}}
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>spline</code>).
** {{Nbt|float}}{{Nbt|compound|spline}}: The spline. Can be either a number or an object.
*** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|coordinate}}: {{json ref/density function}} &mdash; Input determining the location on the spline.
*** {{Nbt|list|points}}: (Cannot be empty) List of points of the cubic spline.
**** {{Nbt|compound}}: A point of the cubic spline.
***** {{Nbt|float|location}}: The location of this point.
***** {{Nbt|float}}{{Nbt|compound|value}}: The value of this point. Can be either a number or a spline object.
***** {{Nbt|float|derivative}}: The slope at this point.
</div>


=== constant ===
A constant value.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>constant</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>distance_to_point</code>).
** {{Nbt|double|argument}}: A constant value. Value between −1000000.0 and 1000000.0 (both inclusive).
** {{nbt|int-array|point}}: {{cd|[x, y, z]}}; the point to compute distance to
** {{nbt|string|metric}}:
*** {{nbt|string|euclidean}}: (i.e. {{cd|sqrt(dx^2 + dy^2 + dz^2)}})
*** {{nbt|string|euclidean_squared}}: (i.e. {{cd|dx^2 + dy^2 + dz^2}})
*** {{nbt|string|manhattan}}: (i.e. {{cd|abs(dx) + abs(dy) + abs(dz)}})
*** {{nbt|string|chebyshev}}: (i.e. {{cd|max(abs(dx), abs(dy), abs(dz))}})
</div>
</div>


=== y_clamped_gradient ===
=== {{cd|end_islands}} ===
Clamps the Y coordinate between <code>from_y</code> and <code>to_y</code> and then linearly maps it to a range.
Renamed to {{cd|end_outer_islands}}.{{upcoming|JE 26.3}}
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.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>y_clamped_gradient</code>).
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>end_islands</code>{{until|JE 26.3}} / <code>end_outer_islands</code>{{upcoming|JE 26.3}}).
** {{Nbt|int|from_y}}: The value to be mapped to <code>from_value</code>. Value between −4064 and 4062 (both inclusive).
** {{Nbt|int|to_y}}: The value to be mapped to <code>to_value</code>. Value between −4064 and 4062 (both inclusive).
** {{Nbt|double|from_value}}: The value to map <code>from_y</code> to. Value between −1000000.0 and 1000000.0 (both inclusive).
** {{Nbt|double|to_value}}: The value to map <code>to_y</code> to. Value between −1000000.0 and 1000000.0 (both inclusive).
</div>
</div>


=== find_top_surface ===
=== {{cd|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 withing the bounds, the {{Nbt|int|lower_bound}} is returned.
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 {{Nbt|int|lower_bound}} is returned.
<div class="treeview">
<div class="treeview">
* {{nbt|compound}}: Root object.
* {{nbt|compound}}: Root object.
Line 345: Line 487:
** {{Nbt|int|lower_bound}}: The y-level to stop the scan.
** {{Nbt|int|lower_bound}}: The y-level to stop the scan.
** {{Nbt|int|cell_height}}: The resolution of the scan. E.g. if set to <code>4</code>, then only every 4th block is checked.
** {{Nbt|int|cell_height}}: The resolution of the scan. E.g. if set to <code>4</code>, then only every 4th block is checked.
</div>
=== {{cd|slice}} ===
Removes a dimension from the input domain by taking a "slice" along an axis with a specific coordinate (e.g. with the axis equaling y and the coordinate of 0, a slice will be taken along the XZ plane, with all values sampled at y=0).{{upcoming|JE 26.3}}
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>slice</code>).
** {{nbt|string|axis}}: {{cd|x}}, {{cd|y}}, or {{cd|z}}; the axis to remove.
** {{nbt|int|coordinate}}: The fixed coordinate to be passed to the input function.
** {{nbt|string}}{{nbt|double}}{{nbt|compound|input}}: The input function.
</div>
</div>


Line 350: Line 503:
{{outdated|section=1}}
{{outdated|section=1}}


=== slide ===
=== {{cd|slide}} ===
Removed in [[Minecraft:22w12a]]
Removed in [[Minecraft:22w12a]]
<div class="treeview">
<div class="treeview">
Line 373: Line 526:
</div>
</div>


=== terrain_shaper_spline ===
=== {{cd|terrain_shaper_spline}} ===
Removed in [[Minecraft:22w11a]]
Removed in [[Minecraft:22w11a]]


Line 387: Line 540:
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|weirdness}}: {{json ref/density function}}
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|weirdness}}: {{json ref/density function}}
</div>
</div>
=== {{cd|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.
<div class="treeview">
* {{nbt|compound}}: Root object.
** {{Nbt|string|type}}: The ID of the density function type (in this case, <code>weird_scaled_sampler</code>).
** {{Nbt|string|rarity_value_mapper}}: Can be <code>type_1</code>(The minimum scale is 0.75, and the maximum is 2.0)or <code>type_2</code>(The minimum scale is 0.5, and the maximum is 3.0.)
** {{Nbt|string|noise}}: {{json ref|noise|Custom noise}} &mdash; The noise to sample.
** {{Nbt|string}}{{Nbt|double}}{{Nbt|compound|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.
</div><!--
TYPE2
if (d < −0.75) {
return 0.5;
} else if (d < −0.5) {
return 0.75;
} else if (d < 0.5) {
return 1.0;
} else {
return d < 0.75 ? 2.0 : 3.0;
}
TYPE1
if (d < −0.5) {
return 0.75;
} else if (d < 0.0) {
return 1.0;
} else {
return d < 0.5 ? 1.5 : 2.0;
}
-->


== History ==
== History ==
Line 397: Line 582:
Added fields to {{cd|old_blended_noise}} density function: xz_scale, y_scale, xz_factor, y_factor, and smear_scale_multiplier.}}
Added fields to {{cd|old_blended_noise}} density function: xz_scale, y_scale, xz_factor, y_factor, and smear_scale_multiplier.}}
|{{HistoryLine||1.21.9|dev=25w31a|Added density functions {{cd|minecraft:find_top_surface}} and {{cd|minecraft:invert}}.}}
|{{HistoryLine||1.21.9|dev=25w31a|Added density functions {{cd|minecraft:find_top_surface}} and {{cd|minecraft:invert}}.}}
|{{HistoryLine||26.2|dev=snap1|Density function {{cd|minecraft:clamp}} can now take a density function ID as an input.}}
|{{HistoryLine|||dev=snap5|Added density function {{cd|minecraft:interval_select}}.|Removed density function {{cd|minecraft:weird_scale_sampler}}. Its functionality has been replaced with {{cd|interval_select}}.}}
|{{HistoryLine|java upcoming}}
|{{HistoryLine|java upcoming}}
|{{HistoryLine||26.2|dev=snap5|Added density function {{cd|minecraft:interval_select}}.|Removed density function {{cd|minecraft:weird_scale_sampler}}. Its functionality has been replaced with {{cd|interval_select}}.}}
|{{HistoryLine||26.3|dev=snap4|Added the following density functions:
* {{cd|ceil}}
* {{cd|div}}
* {{cd|floor}}
* {{cd|negate}}
* {{cd|lerp}}
* {{cd|round}}
* {{cd|sub}}
* {{cd|truncate}}
|{{cd|invert}} has been renamed to {{cd|reciprocal}}.
|Numerous {{cd|argument}} fields in density functions have been renamed.}}
|{{HistoryLine|||dev=snap6|Added the following density functions:
* {{cd|distance_to_point}}
* {{cd|log}}
* {{cd|pow}}
* {{cd|sign}}
* {{cd|slice}}
* {{cd|sqrt}}
|{{cd|end_islands}} has been renamed to {{cd|end_outer_islands}}.
|{{cd|y_clamped_gradient}} has been replaced with {{cd|gradient}}.
}}
}}
}}



Latest revision as of 11:04, 2 August 2026

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

Template:Cd

Only computes the input density once per horizontal position.

Template:Cd

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

Template:Cd

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

Template:Cd

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.

Template:Cd

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.

Noise sampling functions

These density functions are used to sample noises.

Template:Cd

Samples a noise.

Template:Cd

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

Template:Cd

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

Template:Cd

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

Template:Cd

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

Template:Cd

Similar to noise, but first shifts the input coordinates.

Mathematical density functions

These density functions are used to perform mathematical operations.

Template:Cd

Calculates the absolute value of the input density function.

Template:Cd

Adds two density functions together.

Template:Cd

Rounds the input value to positive infinity.Template:Upcoming

Template:Cd

Clamps the input between two values.

Template:Cd

A constant value.

Template:Cd

Cubes the input (x^3).

Template:Cd

Performs division between two arguments.Template:Upcoming

Template:Cd

Rounds the input value to negative infinity.Template:Upcoming

Template:Cd

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

Template:Cd

Computes the natural logarithm of the given input.Template:Upcoming

Template:Cd

Multiplies two inputs.

Template:Cd

Returns the minimum of two inputs.

Template:Cd

Returns the maximum of two inputs.

Template:Cd

Negates the input.Template:Upcoming

Template:Cd

Raises the given base value to an exponent.Template:Upcoming

Template:Cd

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

Template:Cd

Performs subtraction between two arguments.Template:Upcoming

Template:Cd

Computes the sign of the given input. If positive, it returns as 1. If the input is 0, it returns 0. If negative, it returns as -1.Template:Upcoming

Template:Cd

Computes the square root of the given input.Template:Upcoming

Template:Cd

Squares the input. (x^2)

Template:Cd

Rounds the input value to 0.Template:Upcoming

Mapped density functions

These density functions map a set of values onto another set of values.

Template:Cd

File:Gradient tiling.png
Demonstration of the different tiling options for the Template:Cd density functionTemplate:Upcoming, using both an input range of -100 to 100 and an output range of -1 to 1.

Clamps the given coordinate and maps the gradient to a range.Template:Upcoming

  • Template:Nbt: Root object.
    • Template:Nbt: The ID of the density function type (in this case, gradient).
    • Template:Nbt: Template:Cd, Template:Cd. or Template:Cd: The axis over which to define the gradient .
    • Template:Nbt: How the density function handles values outside the specified coordinate range. 3 options:
      • clamp_to_edge: outside the gradient boundaries, the value at the nearest boundary will be used.
      • repeat: The gradient will be repeated outside its boundaries.
      • mirrored_repeat: The gradient will be repeated as such that odd repetitions are mirrored, ensuring continuity between repetitions.
    • Template:NbtTemplate:Upcoming: The coordinate at which the gradient starts.
    • Template:Nbt: The coordinate at which the gradient ends. It must not equal Template:Cd.
    • Template:Nbt: The value at which the gradient starts.
    • Template:Nbt: The value at which the gradient ends.

Template:Cd

Performs (unclamped) linear interpolation between two arguments based on an alpha.Template:Upcoming The returned value is: first*(1-alpha) + second*alpha

Template:Cd

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

Template:Cd

Computes a cubic spline.

Template:Cd

Replaced with Template:Cd.Template:Upcoming

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

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

Conditional density functions

These density functions are used to apply "if-then" logic.

Template:Cd

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

Template:Cd

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

Template:Cd

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

Template:Cd

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

Other density functions

Template:Cd

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.

Template:Cd

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

Template:Cd

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

Template:Cd

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

Template:Cd

File:Distance to point options.png
Demonstration of the different metric options for the Template:Cd density functionTemplate:Upcoming, using the distance from the point (0, 0).

Computes the distance to a fixed point using the specified distance function.Template:Upcoming

Template:Cd

Renamed to Template:Cd.Template:Upcoming 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.

Template:Cd

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.

Template:Cd

Removes a dimension from the input domain by taking a "slice" along an axis with a specific coordinate (e.g. with the axis equaling y and the coordinate of 0, a slice will be taken along the XZ plane, with all values sampled at y=0).Template:Upcoming

Removed density functions

Template:Outdated

Template:Cd

Removed in Minecraft:22w12a

The legacy "spline"

Removed in Minecraft:22w11a

Template:Cd

Removed in Minecraft:22w11a

Calculate the spline from the noise settings.

Template:Cd

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:密度函数