Record Class GradientOutput
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.structure.processor.rule.GradientOutput
- Record Components:
states- The ordered list ofBlockStates from start (0.0) to end (1.0) of the gradient.axis- TheSpatialVectordefining the local and/or global direction of the gradient (default:SpatialVector.UP).minDistance- The scalar projection distance corresponding to the start of the gradient (t = 0.0).maxDistance- The scalar projection distance corresponding to the end of the gradient (t = 1.0).reverse- Whether to invert the normalized gradient fraction (t = 1.0 - t) after curve evaluation.noise- The amplitude of uniform random jitter added totfor organic dithering between palette slices.curve- TheGradientCurveused to warp the normalized distance fractiont.
- All Implemented Interfaces:
RuleOutput
public record GradientOutput(List<net.minecraft.world.level.block.state.BlockState> states, SpatialVector axis, float minDistance, float maxDistance, boolean reverse, float noise, GradientCurve curve)
extends Record
implements RuleOutput
A
RuleOutput implementation that selects a BlockState from an ordered palette
of states based on the block's projected distance along a SpatialVector axis,
shaped by a GradientCurve and perturbed by random noise.
Used extensively in structure processor lists (such as mossifying lower walls or weathering upper roofs) to create natural vertical or directional block transitions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<GradientOutput> TheMapCodecfor serializing and deserializing aGradientOutputfrom JSON. -
Constructor Summary
ConstructorsConstructorDescriptionGradientOutput(List<net.minecraft.world.level.block.state.BlockState> states, SpatialVector axis, float minDistance, float maxDistance, boolean reverse, float noise, GradientCurve curve) Creates an instance of aGradientOutputrecord class. -
Method Summary
Modifier and TypeMethodDescriptionaxis()Returns the value of theaxisrecord component.curve()Returns the value of thecurverecord component.final booleanIndicates whether some other object is "equal to" this one.net.minecraft.world.level.block.state.BlockStategetOutput(net.minecraft.util.RandomSource random, net.minecraft.core.BlockPos localPos, net.minecraft.core.BlockPos absolutePos, net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings settings) Evaluates the spatial projection, curve transformation, optional reversal, and dithering noise for the given block coordinates, mapping the resulting fraction in[0.0, 1.0]to an equal-width slice ofstates.Retrieves the unique string identifier for this output type.final inthashCode()Returns a hash code value for this object.floatReturns the value of themaxDistancerecord component.floatReturns the value of theminDistancerecord component.floatnoise()Returns the value of thenoiserecord component.booleanreverse()Returns the value of thereverserecord component.List<net.minecraft.world.level.block.state.BlockState> states()Returns the value of thestatesrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
TheMapCodecfor serializing and deserializing aGradientOutputfrom JSON.
-
-
Constructor Details
-
GradientOutput
public GradientOutput(List<net.minecraft.world.level.block.state.BlockState> states, SpatialVector axis, float minDistance, float maxDistance, boolean reverse, float noise, GradientCurve curve) Creates an instance of aGradientOutputrecord class.- Parameters:
states- the value for thestatesrecord componentaxis- the value for theaxisrecord componentminDistance- the value for theminDistancerecord componentmaxDistance- the value for themaxDistancerecord componentreverse- the value for thereverserecord componentnoise- the value for thenoiserecord componentcurve- the value for thecurverecord component
-
-
Method Details
-
getTypeId
Retrieves the unique string identifier for this output type.- Specified by:
getTypeIdin interfaceRuleOutput- Returns:
- The type identifier
"gradient".
-
getOutput
public net.minecraft.world.level.block.state.BlockState getOutput(net.minecraft.util.RandomSource random, net.minecraft.core.BlockPos localPos, net.minecraft.core.BlockPos absolutePos, net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings settings) Evaluates the spatial projection, curve transformation, optional reversal, and dithering noise for the given block coordinates, mapping the resulting fraction in[0.0, 1.0]to an equal-width slice ofstates.- Specified by:
getOutputin interfaceRuleOutput- Parameters:
random- The per-block deterministic random source.localPos- The unrotated template-local block position.absolutePos- The transformed world-space block position.settings- The structure placement settings.- Returns:
- The selected
BlockStatefromstates, orBlocks.AIRif the palette is empty.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
states
Returns the value of thestatesrecord component.- Returns:
- the value of the
statesrecord component
-
axis
Returns the value of theaxisrecord component.- Returns:
- the value of the
axisrecord component
-
minDistance
public float minDistance()Returns the value of theminDistancerecord component.- Returns:
- the value of the
minDistancerecord component
-
maxDistance
public float maxDistance()Returns the value of themaxDistancerecord component.- Returns:
- the value of the
maxDistancerecord component
-
reverse
public boolean reverse()Returns the value of thereverserecord component.- Returns:
- the value of the
reverserecord component
-
noise
public float noise()Returns the value of thenoiserecord component.- Returns:
- the value of the
noiserecord component
-
curve
Returns the value of thecurverecord component.- Returns:
- the value of the
curverecord component
-