Class ConfigurableLevelsSquaredValue
- All Implemented Interfaces:
johnsmith.configoverhauled.api.Property.Listener,net.minecraft.world.item.enchantment.LevelBasedValue
public final class ConfigurableLevelsSquaredValue
extends johnsmith.configoverhauled.api.listener.FloatPropertyListener
implements net.minecraft.world.item.enchantment.LevelBasedValue
Dynamic configuration-backed counterpart to
LevelBasedValue.LevelsSquared.
Evaluates $\text{level}^2 + \text{added}$, where the additive constant is bound to a live float
configuration property resolved via ConfigReference.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.world.item.enchantment.LevelBasedValue
net.minecraft.world.item.enchantment.LevelBasedValue.Clamped, net.minecraft.world.item.enchantment.LevelBasedValue.Constant, net.minecraft.world.item.enchantment.LevelBasedValue.Fraction, net.minecraft.world.item.enchantment.LevelBasedValue.LevelsSquared, net.minecraft.world.item.enchantment.LevelBasedValue.Linear, net.minecraft.world.item.enchantment.LevelBasedValue.Lookup -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ConfigurableLevelsSquaredValue> MapCodec for serializing and deserializingConfigurableLevelsSquaredValueinstances from JSON.static final StringRegistry path identifier for this level based value.Fields inherited from class johnsmith.configoverhauled.api.listener.BoundedPropertyListener
lowerBound, upperBoundFields inherited from class johnsmith.configoverhauled.api.listener.AbstractPropertyListener
cachedProperty, defaultValue, description, initialized, typeDefinitionFields inherited from interface net.minecraft.world.item.enchantment.LevelBasedValue
DISPATCH_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionConfigurableLevelsSquaredValue(ConfigReference reference, Float defaultValue, Float min, Float max) Constructs aConfigurableLevelsSquaredValuebound to the given configuration reference. -
Method Summary
Modifier and TypeMethodDescriptionfloatcalculate(int level) Calculates $\text{level}^2 + \text{added}$ using the currently configured additive float value.@NotNull com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.LevelBasedValue> codec()Returns the default fallback value for the additive constant.booleaninthashCode()max()Returns the upper bound constraint of the configuration property.min()Returns the lower bound constraint of the configuration property.Returns theConfigReferencetargeting the additive constant property.toString()Methods inherited from class johnsmith.configoverhauled.api.listener.BoundedPropertyListener
resolvePropertyMethods inherited from class johnsmith.configoverhauled.api.listener.AbstractPropertyListener
onPropertyChanged, onPropertyInvalidated
-
Field Details
-
KEY
Registry path identifier for this level based value.- See Also:
-
CODEC
MapCodec for serializing and deserializingConfigurableLevelsSquaredValueinstances from JSON.
-
-
Constructor Details
-
ConfigurableLevelsSquaredValue
public ConfigurableLevelsSquaredValue(ConfigReference reference, Float defaultValue, Float min, Float max) Constructs aConfigurableLevelsSquaredValuebound to the given configuration reference.- Parameters:
reference- TheConfigReferenceidentifying the additive constant configuration property.defaultValue- The default fallback value for the added constant.min- The minimum allowed value for the generated configuration property.max- The maximum allowed value for the generated configuration property.
-
-
Method Details
-
calculate
public float calculate(int level) Calculates $\text{level}^2 + \text{added}$ using the currently configured additive float value.- Specified by:
calculatein interfacenet.minecraft.world.item.enchantment.LevelBasedValue- Parameters:
level- The active level of the enchantment.- Returns:
- The calculated float value.
-
reference
Returns theConfigReferencetargeting the additive constant property.- Returns:
- The configuration reference.
-
defaultValue
Returns the default fallback value for the additive constant.- Returns:
- The default added float value.
-
min
Returns the lower bound constraint of the configuration property.- Returns:
- The minimum allowed float value.
-
max
Returns the upper bound constraint of the configuration property.- Returns:
- The maximum allowed float value.
-
codec
@NotNull public @NotNull com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.LevelBasedValue> codec()- Specified by:
codecin interfacenet.minecraft.world.item.enchantment.LevelBasedValue
-
equals
-
hashCode
public int hashCode() -
toString
-