Record Class LogarithmicScalingFunction
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.math.function.LogarithmicScalingFunction
- Record Components:
steepness- The positive curvature parameter k controlling the initial drop-off rate near the origin.
- All Implemented Interfaces:
DistanceScalingFunction
public record LogarithmicScalingFunction(float steepness)
extends Record
implements DistanceScalingFunction
A
f(d, R) = max(0, 1 - ln(1 + k ยท (d / R)) / ln(1 + k))
where k is
DistanceScalingFunction that attenuates effect intensity along a normalized logarithmic curve:
f(d, R) = max(0, 1 - ln(1 + k ยท (d / R)) / ln(1 + k))
where k is
steepness().-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<LogarithmicScalingFunction> MapCodec for serializing and deserializingLogarithmicScalingFunctioninstances from JSON.static final StringRegistry path identifier for this distance scaling function.static final StringJSON field key for the logarithmic steepness parameter. -
Constructor Summary
ConstructorsConstructorDescriptionLogarithmicScalingFunction(float steepness) Creates an instance of aLogarithmicScalingFunctionrecord 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.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.floatReturns the value of thesteepnessrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
STEEPNESS
JSON field key for the logarithmic steepness parameter.- See Also:
-
KEY
Registry path identifier for this distance scaling function.- See Also:
-
CODEC
MapCodec for serializing and deserializingLogarithmicScalingFunctioninstances from JSON.
-
-
Constructor Details
-
LogarithmicScalingFunction
public LogarithmicScalingFunction(float steepness) Creates an instance of aLogarithmicScalingFunctionrecord class.- Parameters:
steepness- the value for thesteepnessrecord 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. -
steepness
-