Class ConfigurableLevelsSquaredValue

java.lang.Object
johnsmith.configoverhauled.api.listener.AbstractPropertyListener<Float>
johnsmith.configoverhauled.api.listener.BoundedPropertyListener<Float>
johnsmith.configoverhauled.api.listener.FloatPropertyListener
johnsmith.enchantmentcore.api.enchantment.value.configurable.ConfigurableLevelsSquaredValue
All Implemented Interfaces:
johnsmith.configoverhauled.api.Property.Listener, net.minecraft.world.item.enchantment.LevelBasedValue

public final class ConfigurableLevelsSquaredValue extends johnsmith.configoverhauled.api.listener.FloatPropertyListener implements net.minecraft.world.item.enchantment.LevelBasedValue
Dynamic configuration-backed counterpart to LevelBasedValue.LevelsSquared.

Evaluates $\text{level}^2 + \text{added}$, where the additive constant is bound to a live float configuration property 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<ConfigurableLevelsSquaredValue>
    MapCodec for serializing and deserializing ConfigurableLevelsSquaredValue instances from JSON.
    static final String
    Registry path identifier for this level based value.

    Fields inherited from class johnsmith.configoverhauled.api.listener.BoundedPropertyListener

    lowerBound, upperBound

    Fields inherited from class johnsmith.configoverhauled.api.listener.AbstractPropertyListener

    cachedProperty, defaultValue, description, initialized, typeDefinition

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

    DISPATCH_CODEC
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConfigurableLevelsSquaredValue(ConfigReference reference, Float defaultValue, Float min, Float max)
    Constructs a ConfigurableLevelsSquaredValue bound to the given configuration reference.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    calculate(int level)
    Calculates $\text{level}^2 + \text{added}$ using the currently configured additive float value.
    @NotNull com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.LevelBasedValue>
     
    Returns the default fallback value for the additive constant.
    boolean
     
    int
     
    max()
    Returns the upper bound constraint of the configuration property.
    min()
    Returns the lower bound constraint of the configuration property.
    Returns the ConfigReference targeting the additive constant property.
     

    Methods inherited from class johnsmith.configoverhauled.api.listener.BoundedPropertyListener

    resolveProperty

    Methods inherited from class johnsmith.configoverhauled.api.listener.AbstractPropertyListener

    onPropertyChanged, onPropertyInvalidated

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • ConfigurableLevelsSquaredValue

      public ConfigurableLevelsSquaredValue(ConfigReference reference, Float defaultValue, Float min, Float max)
      Constructs a ConfigurableLevelsSquaredValue bound to the given configuration reference.
      Parameters:
      reference - The ConfigReference identifying the additive constant configuration property.
      defaultValue - The default fallback value for the added constant.
      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)
      Calculates $\text{level}^2 + \text{added}$ using the currently configured additive float value.
      Specified by:
      calculate in interface net.minecraft.world.item.enchantment.LevelBasedValue
      Parameters:
      level - The active level of the enchantment.
      Returns:
      The calculated float value.
    • reference

      public ConfigReference reference()
      Returns the ConfigReference targeting the additive constant property.
      Returns:
      The configuration reference.
    • defaultValue

      public Float defaultValue()
      Returns the default fallback value for the additive constant.
      Returns:
      The default added float value.
    • min

      public Float min()
      Returns the lower bound constraint of the configuration property.
      Returns:
      The minimum allowed float value.
    • max

      public Float 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:
      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
    • toString

      public String toString()
      Overrides:
      toString in class Object