Record Class ConstantScalingFunction
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.math.function.ConstantScalingFunction
- Record Components:
value- The constant scalar multiplier returned across the entire radius.
- All Implemented Interfaces:
DistanceScalingFunction
public record ConstantScalingFunction(float value)
extends Record
implements DistanceScalingFunction
A
DistanceScalingFunction that returns a uniform constant multiplier regardless of distance
(f(d) = value).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ConstantScalingFunction> MapCodec for serializing and deserializingConstantScalingFunctioninstances from JSON.static final StringRegistry path identifier for this distance scaling function.static final ConstantScalingFunctionShared identity instance returning a uniform multiplier of1.0F(no distance falloff).static final StringJSON field key for the constant scalar value. -
Constructor Summary
ConstructorsConstructorDescriptionConstantScalingFunction(float value) Creates an instance of aConstantScalingFunctionrecord 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.final StringtoString()Returns a string representation of this record class.floatvalue()Returns the value of thevaluerecord component.
-
Field Details
-
VALUE
-
KEY
Registry path identifier for this distance scaling function.- See Also:
-
NONE
Shared identity instance returning a uniform multiplier of1.0F(no distance falloff). -
CODEC
MapCodec for serializing and deserializingConstantScalingFunctioninstances from JSON.
-
-
Constructor Details
-
ConstantScalingFunction
public ConstantScalingFunction(float value) Creates an instance of aConstantScalingFunctionrecord class.- Parameters:
value- the value for thevaluerecord 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. -
value
-