Class ConfigurableConstantValue
- All Implemented Interfaces:
johnsmith.configoverhauled.api.Property.Listener,net.minecraft.world.item.enchantment.LevelBasedValue
public final class ConfigurableConstantValue
extends johnsmith.configoverhauled.api.listener.FloatPropertyListener
implements net.minecraft.world.item.enchantment.LevelBasedValue
Dynamic configuration-backed counterpart to
LevelBasedValue.Constant.
Extends FloatPropertyListener to lazily register and cache a live float configuration
property resolved via ConfigReference, returning its current value regardless of enchantment level.
-
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<ConfigurableConstantValue> MapCodec for serializing and deserializingConfigurableConstantValueinstances 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
ConstructorsConstructorDescriptionConfigurableConstantValue(ConfigReference reference, Float defaultValue, Float min, Float max) Constructs aConfigurableConstantValuebound to the given configuration reference. -
Method Summary
Modifier and TypeMethodDescriptionfloatcalculate(int level) Resolves and returns the current float value from the bound configuration property.@NotNull com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.LevelBasedValue> codec()Returns the default fallback float value.booleaninthashCode()max()Returns the upper bound constraint of the configuration property.min()Returns the lower bound constraint of the configuration property.Returns theConfigReferencetargeting the backing configuration 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 deserializingConfigurableConstantValueinstances from JSON.
-
-
Constructor Details
-
ConfigurableConstantValue
public ConfigurableConstantValue(ConfigReference reference, Float defaultValue, Float min, Float max) Constructs aConfigurableConstantValuebound to the given configuration reference.- Parameters:
reference- TheConfigReferenceidentifying the target configuration property.defaultValue- The fallback constant float value.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) Resolves and returns the current float value from the bound configuration property.- Specified by:
calculatein interfacenet.minecraft.world.item.enchantment.LevelBasedValue- Parameters:
level- The active level of the enchantment (unused for constant values).- Returns:
- The configured constant float value.
-
reference
Returns theConfigReferencetargeting the backing configuration property.- Returns:
- The configuration reference.
-
defaultValue
Returns the default fallback float value.- Returns:
- The default 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
-