Interface DensityFunction
- All Known Subinterfaces:
BlendAlpha, BlendOffset, ClampedTransformer, ConstantSimpleFunction, EndIslands, FindTopSurface, MappedNoiseFunction, MappedTransformer, Marker, NoiseFunction, NoiseParameterFunction, PureTransformer, RangeChoice, ReferencedDensityFunction, ShiftedFunction, ShiftedNoise2dFunction, SimpleFunction, TwoArgumentSimpleFunction, YClampedGradient, ZeroSimpleFunction
A density function. Either a reference to a registered one or an authored composition of other
density functions.
- Since:
- 2.4.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault MappedTransformerabs()Calculates the absolute value of this density function.default TwoArgumentSimpleFunctionadd(DensityFunction other) Adds this density function to another density function.static BlendAlphaThe blend alpha density function, used in vanilla for smooth transitions to chunks generated in old versions.default MarkerWraps this density function for smooth blending with chunks generated in old versions.static BlendOffsetThe blend offset density function, used in vanilla for smooth transitions to chunks generated in old versions.default Markercache2d()Computes this density function only once per horizontal position.default MarkerCaches this density function across a whole cell.default MarkerComputes this density function only once per block position, even when it is referenced twice.default ClampedTransformerclamp(double min, double max) Clamps this density function between two values.static ConstantSimpleFunctionconstant(double value) Creates a constant density function that always returns the given value.default MappedTransformercube()Cubes this density function.static DensityFunctionConverts a Minecraft density function into a Wyck density function.static EndIslandsendIslands(long seed) Samples at the current position using the noise algorithm used for end islands.static FindTopSurface.BuilderCreates a new builder for aFindTopSurface.default FindTopSurfacefindTopSurface(DensityFunction upperBound, int lowerBound, int cellHeight) Scans a column of this density function and returns the topmost Y-level whose value is above 0, orlowerBoundif no such position exists within the bounds.static FindTopSurfacefindTopSurface(DensityFunction density, DensityFunction upperBound, int lowerBound, int cellHeight) Scans a column ofdensityand returns the topmost Y-level whose value is above 0, orlowerBoundif no such position exists within the bounds.default MarkerCaches this density function per 4×4 column, computing it only once per column atY=0.default MappedTransformerHalves this density function where it is negative, leaving it unchanged where positive.default MarkerInterpolates this density function at each block in a cell based on the values of surrounding cells.default MappedTransformerinvert()Inverts this density function.static MappedNoiseFunction.BuilderCreates a new builder for aMappedNoiseFunction.static MappedNoiseFunctionmappedNoise(NoiseParameters noiseParameters, double xzScale, double yScale, double minTarget, double maxTarget) Samples a noise and linearly maps its output to the range[minTarget, maxTarget].default TwoArgumentSimpleFunctionmax(DensityFunction other) Returns the maximum of this density function and another density function.default TwoArgumentSimpleFunctionmin(DensityFunction other) Returns the minimum of this density function and another density function.default TwoArgumentSimpleFunctionmul(DensityFunction other) Multiplies this density function by another density function.static NoiseFunction.Buildernoise()Creates a new builder for aNoiseFunction.static NoiseFunctionnoise(NoiseParameters noiseParameters, double xzScale, double yScale) Samples a noise.default MappedTransformerQuarters this density function where it is negative, leaving it unchanged where positive.static RangeChoice.BuilderCreates a new builder for aRangeChoice.default RangeChoicerangeChoice(double minInclusive, double maxExclusive, DensityFunction whenInRange, DensityFunction whenOutOfRange) Uses this density function as the value to compare, returningwhenInRangewhen it falls within[minInclusive, maxExclusive)andwhenOutOfRangeotherwise.static RangeChoicerangeChoice(DensityFunction input, double minInclusive, double maxExclusive, DensityFunction whenInRange, DensityFunction whenOutOfRange) Computesinputand returnswhenInRangewhen it falls within[minInclusive, maxExclusive)andwhenOutOfRangeotherwise.static ReferencedDensityFunctionreference(ResourceKey key) Creates a reference to a density function already registered under the given key.The resource key of the density function, if present.static ShiftedFunctionshift(NoiseParameters noiseParameters) Samples a noise at(x/4, y/4, z/4), then multiplies it by 4.static ShiftedFunctionshiftA(NoiseParameters noiseParameters) Samples a noise at(x/4, 0, z/4), then multiplies it by 4.static ShiftedFunctionshiftB(NoiseParameters noiseParameters) Samples a noise at(z/4, x/4, 0), then multiplies it by 4.Creates a new builder for aShiftedNoise2dFunction.static ShiftedNoise2dFunctionshiftedNoise2d(DensityFunction shiftX, DensityFunction shiftZ, double xzScale, NoiseParameters noiseParameters) Samples a noise likenoise(NoiseParameters, double, double), but first shifts the input coordinates on the X and Z axes.default MappedTransformersquare()Squares this density function.default MappedTransformersqueeze()Clamps this density function between-1and1, then transforms it usingx / 2 - x * x * x / 24.default DensityFunctionwrap()Resolves this object's key in Minecraft's density-function registry and decodes the registered value.static YClampedGradient.BuilderCreates a new builder for aYClampedGradient.static YClampedGradientyClampedGradient(int fromY, int toY, double fromValue, double toValue) Clamps the Y coordinate betweenfromYandtoYand then linearly maps it to the range[fromValue, toValue].static ZeroSimpleFunctionzero()The density function that always returns zero.Methods inherited from interface Wrapper
asHandle, toMinecraft, unwrap
-
Method Details
-
resourceKey
The resource key of the density function, if present.- Returns:
- the resource key of the density function, if present
- Since:
- 3.0.0
-
add
Adds this density function to another density function.- Parameters:
other- the density function to add to this one- Returns:
- a density function that is the sum of the two inputs
- Since:
- 3.0.0
-
mul
Multiplies this density function by another density function.- Parameters:
other- the density function to multiply this one by- Returns:
- a density function that is the product of the two inputs
- Since:
- 3.0.0
-
min
Returns the minimum of this density function and another density function.- Parameters:
other- the density function to compare with- Returns:
- a density function that is the minimum of the two inputs
- Since:
- 3.0.0
-
max
Returns the maximum of this density function and another density function.- Parameters:
other- the density function to compare with- Returns:
- a density function that is the maximum of the two inputs
- Since:
- 3.0.0
-
abs
Calculates the absolute value of this density function.- Returns:
- a density function producing
|x| - Since:
- 3.0.0
-
square
Squares this density function.- Returns:
- a density function producing
x * x - Since:
- 3.0.0
-
cube
Cubes this density function.- Returns:
- a density function producing
x * x * x - Since:
- 3.0.0
-
halfNegative
Halves this density function where it is negative, leaving it unchanged where positive.- Returns:
- a density function producing
x < 0 ? x / 2 : x - Since:
- 3.0.0
-
quarterNegative
Quarters this density function where it is negative, leaving it unchanged where positive.- Returns:
- a density function producing
x < 0 ? x / 4 : x - Since:
- 3.0.0
-
invert
Inverts this density function.- Returns:
- a density function producing
1 / x - Since:
- 3.0.0
-
squeeze
Clamps this density function between-1and1, then transforms it usingx / 2 - x * x * x / 24.- Returns:
- a density function producing the squeezed value
- Since:
- 3.0.0
-
clamp
Clamps this density function between two values.- Parameters:
min- the lower boundmax- the upper bound- Returns:
- a density function clamped to
[min, max] - Since:
- 3.0.0
-
interpolated
Interpolates this density function at each block in a cell based on the values of surrounding cells. Often used in combination withflatCache().- Returns:
- an interpolating marker over this density function
- Since:
- 3.0.0
-
flatCache
Caches this density function per 4×4 column, computing it only once per column atY=0. Often used in combination withinterpolated().- Returns:
- a flat-cache marker over this density function
- Since:
- 3.0.0
-
cache2d
-
cacheOnce
-
cacheAllInCell
-
blendDensity
-
rangeChoice
@AsOf("3.0.0") default RangeChoice rangeChoice(double minInclusive, double maxExclusive, DensityFunction whenInRange, DensityFunction whenOutOfRange) Uses this density function as the value to compare, returningwhenInRangewhen it falls within[minInclusive, maxExclusive)andwhenOutOfRangeotherwise. Essentially an if-then-else statement.- Parameters:
minInclusive- the lower bound of the range, inclusivemaxExclusive- the upper bound of the range, exclusivewhenInRange- the density function used when this value is inside the rangewhenOutOfRange- the density function used when this value is outside the range- Returns:
- a range choice density function
- Since:
- 3.0.0
-
findTopSurface
@AsOf("3.0.0") default FindTopSurface findTopSurface(DensityFunction upperBound, int lowerBound, int cellHeight) Scans a column of this density function and returns the topmost Y-level whose value is above 0, orlowerBoundif no such position exists within the bounds.- Parameters:
upperBound- the Y-level to start the scan at, usually a 2D density functionlowerBound- the Y-level to stop the scan at, and the value returned when no surface is foundcellHeight- the resolution of the scan; e.g.4checks only every 4th block- Returns:
- a find top surface density function over this density function
- Since:
- 3.0.0
-
constant
Creates a constant density function that always returns the given value.- Parameters:
value- the value to return- Returns:
- a constant density function
- Since:
- 3.0.0
-
noise
@AsOf("3.0.0") static NoiseFunction noise(NoiseParameters noiseParameters, double xzScale, double yScale) Samples a noise.- Parameters:
noiseParameters- the noise to samplexzScale- scales the X and Z before samplingyScale- scales the Y before sampling- Returns:
- a noise density function
- Since:
- 3.0.0
-
noise
Creates a new builder for aNoiseFunction.- Returns:
- a new noise function builder
- Since:
- 3.0.0
-
mappedNoise
@AsOf("3.0.0") static MappedNoiseFunction mappedNoise(NoiseParameters noiseParameters, double xzScale, double yScale, double minTarget, double maxTarget) Samples a noise and linearly maps its output to the range[minTarget, maxTarget].- Parameters:
noiseParameters- the noise to samplexzScale- scales the X and Z before samplingyScale- scales the Y before samplingminTarget- the minimum value of the outputmaxTarget- the maximum value of the output- Returns:
- a mapped noise density function
- Since:
- 3.0.0
-
mappedNoise
Creates a new builder for aMappedNoiseFunction.- Returns:
- a new mapped noise function builder
- Since:
- 3.0.0
-
shift
Samples a noise at(x/4, y/4, z/4), then multiplies it by 4.- Parameters:
noiseParameters- the noise to sample- Returns:
- a shift density function
- Since:
- 3.0.0
-
shiftA
Samples a noise at(x/4, 0, z/4), then multiplies it by 4.- Parameters:
noiseParameters- the noise to sample- Returns:
- a shift_a density function
- Since:
- 3.0.0
-
shiftB
Samples a noise at(z/4, x/4, 0), then multiplies it by 4.- Parameters:
noiseParameters- the noise to sample- Returns:
- a shift_b density function
- Since:
- 3.0.0
-
shiftedNoise2d
@AsOf("3.0.0") static ShiftedNoise2dFunction shiftedNoise2d(DensityFunction shiftX, DensityFunction shiftZ, double xzScale, NoiseParameters noiseParameters) Samples a noise likenoise(NoiseParameters, double, double), but first shifts the input coordinates on the X and Z axes.- Parameters:
shiftX- offsets the position in the X directionshiftZ- offsets the position in the Z directionxzScale- scales the X and Z before samplingnoiseParameters- the noise to sample- Returns:
- a shifted noise density function
- Since:
- 3.0.0
-
shiftedNoise2d
Creates a new builder for aShiftedNoise2dFunction.- Returns:
- a new shifted noise function builder
- Since:
- 3.0.0
-
rangeChoice
@AsOf("3.0.0") static RangeChoice rangeChoice(DensityFunction input, double minInclusive, double maxExclusive, DensityFunction whenInRange, DensityFunction whenOutOfRange) Computesinputand returnswhenInRangewhen it falls within[minInclusive, maxExclusive)andwhenOutOfRangeotherwise. Essentially an if-then-else statement.- Parameters:
input- the value to compare against the rangeminInclusive- the lower bound of the range, inclusivemaxExclusive- the upper bound of the range, exclusivewhenInRange- the density function used when the input is inside the rangewhenOutOfRange- the density function used when the input is outside the range- Returns:
- a range choice density function
- Since:
- 3.0.0
-
rangeChoice
Creates a new builder for aRangeChoice.- Returns:
- a new range choice builder
- Since:
- 3.0.0
-
yClampedGradient
@AsOf("3.0.0") static YClampedGradient yClampedGradient(int fromY, int toY, double fromValue, double toValue) Clamps the Y coordinate betweenfromYandtoYand then linearly maps it to the range[fromValue, toValue].- Parameters:
fromY- the Y coordinate mapped tofromValuetoY- the Y coordinate mapped totoValuefromValue- the value thatfromYmaps totoValue- the value thattoYmaps to- Returns:
- a y clamped gradient density function
- Since:
- 3.0.0
-
yClampedGradient
Creates a new builder for aYClampedGradient.- Returns:
- a new y clamped gradient builder
- Since:
- 3.0.0
-
endIslands
Samples at the current position using the noise algorithm used for end islands. Its minimum value is-0.84375and its maximum value is0.5625.- Parameters:
seed- the seed used to generate the end islands noise- Returns:
- an end islands density function
- Since:
- 3.0.0
-
blendAlpha
The blend alpha density function, used in vanilla for smooth transitions to chunks generated in old versions.- Returns:
- the blend alpha density function
- Since:
- 3.0.0
-
blendOffset
The blend offset density function, used in vanilla for smooth transitions to chunks generated in old versions.- Returns:
- the blend offset density function
- Since:
- 3.0.0
-
zero
The density function that always returns zero.- Returns:
- the zero density function
- Since:
- 3.0.0
-
findTopSurface
@AsOf("3.0.0") static FindTopSurface findTopSurface(DensityFunction density, DensityFunction upperBound, int lowerBound, int cellHeight) Scans a column ofdensityand returns the topmost Y-level whose value is above 0, orlowerBoundif no such position exists within the bounds.- Parameters:
density- the density function to scanupperBound- the Y-level to start the scan at, usually a 2D density functionlowerBound- the Y-level to stop the scan at, and the value returned when no surface is foundcellHeight- the resolution of the scan; e.g.4checks only every 4th block- Returns:
- a find top surface density function
- Since:
- 3.0.0
-
findTopSurface
Creates a new builder for aFindTopSurface.- Returns:
- a new find top surface builder
- Since:
- 3.0.0
-
reference
Creates a reference to a density function already registered under the given key.- Parameters:
key- the key of an entry in the density function registry- Returns:
- a reference to that density function
- Since:
- 3.0.0
-
wrap
Resolves this object's key in Minecraft's density-function registry and decodes the registered value.- Returns:
- the decoded density function
- Throws:
IllegalStateException- if this object has no resource key- Since:
- 3.3.0
-
decode
Converts a Minecraft density function into a Wyck density function.- Parameters:
minecraftDensityFunction- the Minecraft density function to convert- Returns:
- the Wyck density function
- Since:
- 3.3.0
-