Record Class PolynomialScalingFunction
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.math.function.PolynomialScalingFunction
- Record Components:
degree- The polynomial exponent p (e.g., p = 2.0 yields quadratic falloff).
- All Implemented Interfaces:
DistanceScalingFunction
public record PolynomialScalingFunction(float degree)
extends Record
implements DistanceScalingFunction
A
f(d, R) = max(0, 1 - (d / R)p)
where p is
DistanceScalingFunction that attenuates effect intensity according to a power curve of
normalized distance:
f(d, R) = max(0, 1 - (d / R)p)
where p is
degree().-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<PolynomialScalingFunction> MapCodec for serializing and deserializingPolynomialScalingFunctioninstances from JSON.static final StringJSON field key for the polynomial exponent degree.static final StringRegistry path identifier for this distance scaling function. -
Constructor Summary
ConstructorsConstructorDescriptionPolynomialScalingFunction(float degree) Creates an instance of aPolynomialScalingFunctionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfloatapply(float distance, float maxRadius) Evaluates the distance scaling function at the given distance relative tomaxRadius.com.mojang.serialization.MapCodec<? extends DistanceScalingFunction> codec()Retrieves theMapCodecresponsible for serializing and deserializing this function type.floatdegree()Returns the value of thedegreerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEGREE
-
KEY
Registry path identifier for this distance scaling function.- See Also:
-
CODEC
MapCodec for serializing and deserializingPolynomialScalingFunctioninstances from JSON.
-
-
Constructor Details
-
PolynomialScalingFunction
public PolynomialScalingFunction(float degree) Creates an instance of aPolynomialScalingFunctionrecord class.- Parameters:
degree- the value for thedegreerecord component
-
-
Method Details
-
apply
public float apply(float distance, float maxRadius) Description copied from interface:DistanceScalingFunctionEvaluates the distance scaling function at the given distance relative tomaxRadius.- Specified by:
applyin interfaceDistanceScalingFunction- Parameters:
distance- The measured distance from the spatial origin or reference axis.maxRadius- The maximum operational radius of the topological component.- Returns:
- The calculated intensity multiplier scalar (typically bounded in $[0.0, 1.0]$).
-
codec
Description copied from interface:DistanceScalingFunctionRetrieves theMapCodecresponsible for serializing and deserializing this function type.- Specified by:
codecin interfaceDistanceScalingFunction- Returns:
- The registered
MapCodecinstance.
-
toString
-
hashCode
-
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. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
degree
-