Record Class CostPropertyWrapper

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.config.wrapper.CostPropertyWrapper
Record Components:
baseWrapper - The integer property wrapper governing the base enchanting cost, or null.
perLevelWrapper - The integer property wrapper governing the cost increment per level above the first, or null.

public record CostPropertyWrapper(IntPropertyWrapper baseWrapper, IntPropertyWrapper perLevelWrapper) extends Record
Composite configuration wrapper for dynamically evaluating an Enchantment.Cost structure (min_cost or max_cost), encapsulating independent IntPropertyWrapper instances for the base cost and the per_level_above_first increment.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a CostPropertyWrapper record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the baseWrapper record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Determines whether either the base cost wrapper or the per-level cost wrapper holds an active configuration.
    boolean
    isDifferent(net.minecraft.world.item.enchantment.Enchantment.Cost original)
    Checks whether the currently configured cost parameters differ from the provided baseline Enchantment.Cost.
    Returns the value of the perLevelWrapper record component.
    net.minecraft.world.item.enchantment.Enchantment.Cost
    resolve(net.minecraft.world.item.enchantment.Enchantment.Cost original)
    Constructs an updated Enchantment.Cost using the active configuration values, or returns original if neither sub-property is configured.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • CostPropertyWrapper

      public CostPropertyWrapper(IntPropertyWrapper baseWrapper, IntPropertyWrapper perLevelWrapper)
      Creates an instance of a CostPropertyWrapper record class.
      Parameters:
      baseWrapper - the value for the baseWrapper record component
      perLevelWrapper - the value for the perLevelWrapper record component
  • Method Details

    • isConfigured

      public boolean isConfigured()
      Determines whether either the base cost wrapper or the per-level cost wrapper holds an active configuration.
      Returns:
      true if at least one sub-wrapper is non-null and configured, false otherwise.
    • isDifferent

      public boolean isDifferent(net.minecraft.world.item.enchantment.Enchantment.Cost original)
      Checks whether the currently configured cost parameters differ from the provided baseline Enchantment.Cost.
      Parameters:
      original - The original baseline Enchantment.Cost from the enchantment definition.
      Returns:
      true if the resolved base or per-level cost differs from original, false otherwise.
    • resolve

      public net.minecraft.world.item.enchantment.Enchantment.Cost resolve(net.minecraft.world.item.enchantment.Enchantment.Cost original)
      Constructs an updated Enchantment.Cost using the active configuration values, or returns original if neither sub-property is configured.
      Parameters:
      original - The original baseline Enchantment.Cost used for fallback values.
      Returns:
      A new Enchantment.Cost reflecting the active configuration, or original if unconfigured.
    • 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.
    • baseWrapper

      public IntPropertyWrapper baseWrapper()
      Returns the value of the baseWrapper record component.
      Returns:
      the value of the baseWrapper record component
    • perLevelWrapper

      public IntPropertyWrapper perLevelWrapper()
      Returns the value of the perLevelWrapper record component.
      Returns:
      the value of the perLevelWrapper record component