Class ConfigurablePolynomialValue
java.lang.Object
johnsmith.enchantmentcore.api.enchantment.value.configurable.ConfigurablePolynomialValue
- All Implemented Interfaces:
net.minecraft.world.item.enchantment.LevelBasedValue
public final class ConfigurablePolynomialValue
extends Object
implements net.minecraft.world.item.enchantment.LevelBasedValue
Dynamic configuration-backed counterpart to
PolynomialValue.
Evaluates $\text{offset} + \text{scale} \cdot (\text{level} + \text{levelOffset})^{\text{power}}$,
where scale, power, offset, and levelOffset are each bound to live
float configuration properties 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.Exponent, 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<ConfigurablePolynomialValue> MapCodec for serializing and deserializingConfigurablePolynomialValueinstances from JSON.static final StringRegistry path identifier for this level based value.Fields inherited from interface net.minecraft.world.item.enchantment.LevelBasedValue
DISPATCH_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionConfigurablePolynomialValue(ConfigReference scaleReference, Float scaleDefault, ConfigReference powerReference, Float powerDefault, ConfigReference offsetReference, Float offsetDefault, ConfigReference levelOffsetReference, Float levelOffsetDefault) Constructs aConfigurablePolynomialValuebound to the specified configuration references. -
Method Summary
Modifier and TypeMethodDescriptionfloatcalculate(int level) Calculates $\text{offset} + \text{scale} \cdot (\text{level} + \text{levelOffset})^{\text{power}}$ using the active configuration values.@NotNull com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.LevelBasedValue> codec()booleaninthashCode()Returns the default fallback for the pre-exponent level offset.Returns theConfigReferencefor the pre-exponent level offset.Returns the default fallback for the additive output offset.Returns theConfigReferencefor the additive output offset.Returns the default fallback for the exponent power.Returns theConfigReferencefor the exponent power.Returns the default fallback for the scale coefficient.Returns theConfigReferencefor the scale coefficient.
-
Field Details
-
KEY
-
CODEC
MapCodec for serializing and deserializingConfigurablePolynomialValueinstances from JSON.
-
-
Constructor Details
-
ConfigurablePolynomialValue
public ConfigurablePolynomialValue(ConfigReference scaleReference, Float scaleDefault, ConfigReference powerReference, Float powerDefault, ConfigReference offsetReference, Float offsetDefault, ConfigReference levelOffsetReference, Float levelOffsetDefault) Constructs aConfigurablePolynomialValuebound to the specified configuration references.- Parameters:
scaleReference- TheConfigReferencefor the scale coefficient.scaleDefault- The default scale coefficient.powerReference- TheConfigReferencefor the exponent power.powerDefault- The default exponent power.offsetReference- TheConfigReferencefor the additive output offset.offsetDefault- The default additive output offset.levelOffsetReference- TheConfigReferencefor the pre-exponent level offset.levelOffsetDefault- The default pre-exponent level offset.
-
-
Method Details
-
calculate
public float calculate(int level) Calculates $\text{offset} + \text{scale} \cdot (\text{level} + \text{levelOffset})^{\text{power}}$ using the active configuration values.- Specified by:
calculatein interfacenet.minecraft.world.item.enchantment.LevelBasedValue- Parameters:
level- The active level of the enchantment.- Returns:
- The calculated polynomial float value.
-
scaleReference
Returns theConfigReferencefor the scale coefficient.- Returns:
- The scale configuration reference.
-
scaleDefault
Returns the default fallback for the scale coefficient.- Returns:
- The default scale float value.
-
powerReference
Returns theConfigReferencefor the exponent power.- Returns:
- The power configuration reference.
-
powerDefault
Returns the default fallback for the exponent power.- Returns:
- The default power float value.
-
offsetReference
Returns theConfigReferencefor the additive output offset.- Returns:
- The offset configuration reference.
-
offsetDefault
Returns the default fallback for the additive output offset.- Returns:
- The default offset float value.
-
levelOffsetReference
Returns theConfigReferencefor the pre-exponent level offset.- Returns:
- The level-offset configuration reference.
-
levelOffsetDefault
Returns the default fallback for the pre-exponent level offset.- Returns:
- The default level-offset 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
-