Record Class PointerValue

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.value.PointerValue
Record Components:
id - The unique string key used to reference this value in translation strings (e.g., <val:id> or <array:id>).
value - The underlying LevelBasedValue delegated to during calculation and tooltip rendering.
All Implemented Interfaces:
net.minecraft.world.item.enchantment.LevelBasedValue

public record PointerValue(String id, net.minecraft.world.item.enchantment.LevelBasedValue value) extends Record implements net.minecraft.world.item.enchantment.LevelBasedValue
A proxy LevelBasedValue used to tag and expose mathematical curves inside complex enchantment JSON structures for dynamic tooltip interpolation.

During data loading, EnchantmentCodecMixin scans the enchantment's DFU tree, extracts each PointerValue by its id(), and binds its inner value() into the EnchantmentEffectComponents.DESCRIPTION_ARGS component map for $\mathcal{O}(1)$ runtime lookup by DynamicDescriptionParser.

  • 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<PointerValue>
    The codec responsible for serializing and deserializing PointerValue 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
    PointerValue(String id, net.minecraft.world.item.enchantment.LevelBasedValue value)
    Creates an instance of a PointerValue record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    calculate(int level)
    Delegates calculation directly to the wrapped value().
    @NotNull com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.LevelBasedValue>
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    id()
    Returns the value of the id record component.
    final String
    Returns a string representation of this record class.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the value record component.

    Methods inherited from class java.lang.Object

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

    • KEY

      public static final String KEY
      Registry path identifier for this level based value.
      See Also:
    • CODEC

      public static final com.mojang.serialization.MapCodec<PointerValue> CODEC
      The codec responsible for serializing and deserializing PointerValue instances from JSON.
  • Constructor Details

    • PointerValue

      public PointerValue(String id, net.minecraft.world.item.enchantment.LevelBasedValue value)
      Creates an instance of a PointerValue record class.
      Parameters:
      id - the value for the id record component
      value - the value for the value record component
  • Method Details

    • calculate

      public float calculate(int level)
      Delegates calculation directly to the wrapped 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 from the inner provider.
    • 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
      Returns:
      The MapCodec for this class.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • value

      public net.minecraft.world.item.enchantment.LevelBasedValue value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component