Class ConfigurableConstantValue

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.ConfigurableConstantValue
All Implemented Interfaces:
johnsmith.configoverhauled.api.Property.Listener, net.minecraft.world.item.enchantment.LevelBasedValue

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

Extends FloatPropertyListener to lazily register and cache a live float configuration property resolved via ConfigReference, returning its current value regardless of enchantment level.

  • 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<ConfigurableConstantValue>
    MapCodec for serializing and deserializing ConfigurableConstantValue 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
    ConfigurableConstantValue(ConfigReference reference, Float defaultValue, Float min, Float max)
    Constructs a ConfigurableConstantValue bound to the given configuration reference.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    calculate(int level)
    Resolves and returns the current float value from the bound configuration property.
    @NotNull com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.LevelBasedValue>
     
    Returns the default fallback float value.
    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 backing configuration 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

    • ConfigurableConstantValue

      public ConfigurableConstantValue(ConfigReference reference, Float defaultValue, Float min, Float max)
      Constructs a ConfigurableConstantValue bound to the given configuration reference.
      Parameters:
      reference - The ConfigReference identifying the target configuration property.
      defaultValue - The fallback constant float value.
      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)
      Resolves and returns the current float value from the bound configuration property.
      Specified by:
      calculate in interface net.minecraft.world.item.enchantment.LevelBasedValue
      Parameters:
      level - The active level of the enchantment (unused for constant values).
      Returns:
      The configured constant float value.
    • reference

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

      public Float defaultValue()
      Returns the default fallback float value.
      Returns:
      The default 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