Class ConfigurableLinearValue
java.lang.Object
johnsmith.enchantmentcore.api.enchantment.value.configurable.ConfigurableLinearValue
- All Implemented Interfaces:
net.minecraft.world.item.enchantment.LevelBasedValue
public final class ConfigurableLinearValue
extends Object
implements net.minecraft.world.item.enchantment.LevelBasedValue
Dynamic configuration-backed counterpart to
LevelBasedValue.Linear.
Evaluates $\text{base} + \text{perLevel} \cdot (\text{level} - 1)$, where both base and
perLevel are 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.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<ConfigurableLinearValue> MapCodec for serializing and deserializingConfigurableLinearValueinstances 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
ConstructorsConstructorDescriptionConfigurableLinearValue(ConfigReference baseReference, Float baseDefault, Float baseMin, Float baseMax, ConfigReference perLevelReference, Float perLevelDefault, Float perLevelMin, Float perLevelMax) Constructs aConfigurableLinearValuebound to the specified base and per-level configuration references. -
Method Summary
Modifier and TypeMethodDescriptionReturns the default fallback for the base value.baseMax()Returns the maximum allowed value for the base configuration property.baseMin()Returns the minimum allowed value for the base configuration property.Returns theConfigReferencefor the base value.floatcalculate(int level) Calculates $\text{base} + \text{perLevel} \cdot (\text{level} - 1)$ 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 per-level increment.Returns the maximum allowed value for the per-level configuration property.Returns the minimum allowed value for the per-level configuration property.Returns theConfigReferencefor the per-level increment.
-
Field Details
-
KEY
Registry path identifier for this level based value.- See Also:
-
CODEC
MapCodec for serializing and deserializingConfigurableLinearValueinstances from JSON.
-
-
Constructor Details
-
ConfigurableLinearValue
public ConfigurableLinearValue(ConfigReference baseReference, Float baseDefault, Float baseMin, Float baseMax, ConfigReference perLevelReference, Float perLevelDefault, Float perLevelMin, Float perLevelMax) Constructs aConfigurableLinearValuebound to the specified base and per-level configuration references.- Parameters:
baseReference- TheConfigReferencefor the base value.baseDefault- The default base value.baseMin- The minimum bound for the base configuration property.baseMax- The maximum bound for the base configuration property.perLevelReference- TheConfigReferencefor the per-level increment.perLevelDefault- The default per-level increment.perLevelMin- The minimum bound for the per-level configuration property.perLevelMax- The maximum bound for the per-level configuration property.
-
-
Method Details
-
calculate
public float calculate(int level) Calculates $\text{base} + \text{perLevel} \cdot (\text{level} - 1)$ 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 linear float value.
-
baseReference
Returns theConfigReferencefor the base value.- Returns:
- The base configuration reference.
-
baseDefault
Returns the default fallback for the base value.- Returns:
- The default base float value.
-
baseMin
Returns the minimum allowed value for the base configuration property.- Returns:
- The minimum base float bound.
-
baseMax
Returns the maximum allowed value for the base configuration property.- Returns:
- The maximum base float bound.
-
perLevelReference
Returns theConfigReferencefor the per-level increment.- Returns:
- The per-level configuration reference.
-
perLevelDefault
Returns the default fallback for the per-level increment.- Returns:
- The default per-level float value.
-
perLevelMin
Returns the minimum allowed value for the per-level configuration property.- Returns:
- The minimum per-level float bound.
-
perLevelMax
Returns the maximum allowed value for the per-level configuration property.- Returns:
- The maximum per-level float bound.
-
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()
-