Class ConfigurableDiminishingReturnsValue
java.lang.Object
johnsmith.enchantmentcore.api.enchantment.value.configurable.ConfigurableDiminishingReturnsValue
- All Implemented Interfaces:
net.minecraft.world.item.enchantment.LevelBasedValue
public final class ConfigurableDiminishingReturnsValue
extends Object
implements net.minecraft.world.item.enchantment.LevelBasedValue
Dynamic configuration-backed counterpart to
DiminishingReturnsValue.
Binds the base, decrement, and minimum parameters of the diminishing returns
progression 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<ConfigurableDiminishingReturnsValue> MapCodec for serializing and deserializingConfigurableDiminishingReturnsValueinstances 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
ConstructorsConstructorDescriptionConfigurableDiminishingReturnsValue(ConfigReference baseReference, Float baseDefault, ConfigReference decrementReference, Float decrementDefault, ConfigReference minimumReference, Float minimumDefault) Constructs aConfigurableDiminishingReturnsValuebound to the specified configuration references. -
Method Summary
Modifier and TypeMethodDescriptionReturns the default fallback for the base value.Returns theConfigReferencefor the base value.floatcalculate(int level) Calculates the cumulative diminishing-returns value at the specified enchantment level using the active configuration values forbase,decrement, andminimum.@NotNull com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.LevelBasedValue> codec()Returns the default fallback for the per-level decrement value.Returns theConfigReferencefor the per-level decrement value.booleaninthashCode()Returns the default fallback for the minimum floor value.Returns theConfigReferencefor the minimum floor value.
-
Field Details
-
KEY
-
CODEC
MapCodec for serializing and deserializingConfigurableDiminishingReturnsValueinstances from JSON.
-
-
Constructor Details
-
ConfigurableDiminishingReturnsValue
public ConfigurableDiminishingReturnsValue(ConfigReference baseReference, Float baseDefault, ConfigReference decrementReference, Float decrementDefault, ConfigReference minimumReference, Float minimumDefault) Constructs aConfigurableDiminishingReturnsValuebound to the specified configuration references.- Parameters:
baseReference- TheConfigReferencefor the initial base value.baseDefault- The default initial base value.decrementReference- TheConfigReferencefor the per-level decrement.decrementDefault- The default per-level decrement.minimumReference- TheConfigReferencefor the minimum floor increment.minimumDefault- The default minimum floor increment.
-
-
Method Details
-
calculate
public float calculate(int level) Calculates the cumulative diminishing-returns value at the specified enchantment level using the active configuration values forbase,decrement, andminimum.- Specified by:
calculatein interfacenet.minecraft.world.item.enchantment.LevelBasedValue- Parameters:
level- The active level of the enchantment.- Returns:
- The cumulative calculated float value, or
0iflevel <= 0.
-
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.
-
decrementReference
Returns theConfigReferencefor the per-level decrement value.- Returns:
- The decrement configuration reference.
-
decrementDefault
Returns the default fallback for the per-level decrement value.- Returns:
- The default decrement float value.
-
minimumReference
Returns theConfigReferencefor the minimum floor value.- Returns:
- The minimum floor configuration reference.
-
minimumDefault
Returns the default fallback for the minimum floor value.- Returns:
- The default minimum floor 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
-