Record Class ExponentialScalingFunction
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.math.function.ExponentialScalingFunction
- Record Components:
decayRate- The exponential decay constant λ governing how rapidly intensity drops from the origin.
- All Implemented Interfaces:
DistanceScalingFunction
public record ExponentialScalingFunction(float decayRate)
extends Record
implements DistanceScalingFunction
A
f(d, R) = e-λ · (d / R)
where λ is
DistanceScalingFunction that attenuates effect intensity exponentially with normalized distance:
f(d, R) = e-λ · (d / R)
where λ is
decayRate().-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ExponentialScalingFunction> MapCodec for serializing and deserializingExponentialScalingFunctioninstances from JSON.static final StringJSON field key for the exponential decay rate $\lambda$.static final StringRegistry path identifier for this distance scaling function. -
Constructor Summary
ConstructorsConstructorDescriptionExponentialScalingFunction(float decayRate) Creates an instance of aExponentialScalingFunctionrecord 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.floatReturns the value of thedecayRaterecord 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
-
DECAY_RATE
JSON field key for the exponential decay rate $\lambda$.- See Also:
-
KEY
Registry path identifier for this distance scaling function.- See Also:
-
CODEC
MapCodec for serializing and deserializingExponentialScalingFunctioninstances from JSON.
-
-
Constructor Details
-
ExponentialScalingFunction
public ExponentialScalingFunction(float decayRate) Creates an instance of aExponentialScalingFunctionrecord class.- Parameters:
decayRate- the value for thedecayRaterecord 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. -
decayRate
-