Class ConfigurableClampedValue

java.lang.Object
johnsmith.enchantmentcore.api.enchantment.value.configurable.ConfigurableClampedValue
All Implemented Interfaces:
net.minecraft.world.item.enchantment.LevelBasedValue

public final class ConfigurableClampedValue extends Object implements net.minecraft.world.item.enchantment.LevelBasedValue
Dynamic configuration-backed counterpart to LevelBasedValue.Clamped.

Evaluates an inner LevelBasedValue and clamps its output between live minimum and maximum 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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<ConfigurableClampedValue>
    MapCodec for serializing and deserializing ConfigurableClampedValue 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
    ConfigurableClampedValue(net.minecraft.world.item.enchantment.LevelBasedValue value, ConfigReference minReference, Float minDefault, ConfigReference maxReference, Float maxDefault)
    Constructs a ConfigurableClampedValue bound to the specified min and max configuration references.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    calculate(int level)
    Evaluates the inner LevelBasedValue at level and clamps the result between the currently configured minimum and maximum values.
    @NotNull com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.LevelBasedValue>
     
    boolean
     
    int
     
    Returns the default fallback value for the maximum clamp bound.
    Returns the ConfigReference for the maximum clamp bound.
    Returns the default fallback value for the minimum clamp bound.
    Returns the ConfigReference for the minimum clamp bound.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the inner LevelBasedValue being clamped.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • ConfigurableClampedValue

      public ConfigurableClampedValue(net.minecraft.world.item.enchantment.LevelBasedValue value, ConfigReference minReference, Float minDefault, ConfigReference maxReference, Float maxDefault)
      Constructs a ConfigurableClampedValue bound to the specified min and max configuration references.
      Parameters:
      value - The inner LevelBasedValue to clamp.
      minReference - The ConfigReference governing the lower clamp bound.
      minDefault - The default lower clamp bound.
      maxReference - The ConfigReference governing the upper clamp bound.
      maxDefault - The default upper clamp bound.
  • Method Details

    • calculate

      public float calculate(int level)
      Evaluates the inner LevelBasedValue at level and clamps the result between the currently configured minimum and maximum values.
      Specified by:
      calculate in interface net.minecraft.world.item.enchantment.LevelBasedValue
      Parameters:
      level - The active level of the enchantment.
      Returns:
      The clamped float value.
    • value

      public net.minecraft.world.item.enchantment.LevelBasedValue value()
      Returns the inner LevelBasedValue being clamped.
      Returns:
      The inner LevelBasedValue.
    • minReference

      public ConfigReference minReference()
      Returns the ConfigReference for the minimum clamp bound.
      Returns:
      The minimum bound configuration reference.
    • minDefault

      public Float minDefault()
      Returns the default fallback value for the minimum clamp bound.
      Returns:
      The default minimum float value.
    • maxReference

      public ConfigReference maxReference()
      Returns the ConfigReference for the maximum clamp bound.
      Returns:
      The maximum bound configuration reference.
    • maxDefault

      public Float maxDefault()
      Returns the default fallback value for the maximum clamp bound.
      Returns:
      The default maximum 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