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.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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<ConfigurableLinearValue>
    MapCodec for serializing and deserializing ConfigurableLinearValue instances from JSON.
    static final String
    Registry path identifier for this level based value.

    Fields inherited from interface net.minecraft.world.item.enchantment.LevelBasedValue

    DISPATCH_CODEC
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConfigurableLinearValue(ConfigReference baseReference, Float baseDefault, Float baseMin, Float baseMax, ConfigReference perLevelReference, Float perLevelDefault, Float perLevelMin, Float perLevelMax)
    Constructs a ConfigurableLinearValue bound to the specified base and per-level configuration references.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the default fallback for the base value.
    Returns the maximum allowed value for the base configuration property.
    Returns the minimum allowed value for the base configuration property.
    Returns the ConfigReference for the base value.
    float
    calculate(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>
     
    boolean
     
    int
     
    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 the ConfigReference for the per-level increment.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ConfigurableLinearValue

      public ConfigurableLinearValue(ConfigReference baseReference, Float baseDefault, Float baseMin, Float baseMax, ConfigReference perLevelReference, Float perLevelDefault, Float perLevelMin, Float perLevelMax)
      Constructs a ConfigurableLinearValue bound to the specified base and per-level configuration references.
      Parameters:
      baseReference - The ConfigReference for 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 - The ConfigReference for 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:
      calculate in interface net.minecraft.world.item.enchantment.LevelBasedValue
      Parameters:
      level - The active level of the enchantment.
      Returns:
      The calculated linear float value.
    • baseReference

      public ConfigReference baseReference()
      Returns the ConfigReference for the base value.
      Returns:
      The base configuration reference.
    • baseDefault

      public Float baseDefault()
      Returns the default fallback for the base value.
      Returns:
      The default base float value.
    • baseMin

      public Float baseMin()
      Returns the minimum allowed value for the base configuration property.
      Returns:
      The minimum base float bound.
    • baseMax

      public Float baseMax()
      Returns the maximum allowed value for the base configuration property.
      Returns:
      The maximum base float bound.
    • perLevelReference

      public ConfigReference perLevelReference()
      Returns the ConfigReference for the per-level increment.
      Returns:
      The per-level configuration reference.
    • perLevelDefault

      public Float perLevelDefault()
      Returns the default fallback for the per-level increment.
      Returns:
      The default per-level float value.
    • perLevelMin

      public Float perLevelMin()
      Returns the minimum allowed value for the per-level configuration property.
      Returns:
      The minimum per-level float bound.
    • perLevelMax

      public Float 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:
      codec in interface net.minecraft.world.item.enchantment.LevelBasedValue
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object