Record Class PendingEnchantment

java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.menu.enchant.model.PendingEnchantment
Record Components:
enchantment - The proposed enchantment instance.
source - The origin source of the enchantment.

public record PendingEnchantment(Optional<net.minecraft.world.item.enchantment.EnchantmentInstance> enchantment, EnchantmentSource source) extends Record
A data record that pairs a potential EnchantmentInstance with the EnchantmentSource origin from which it was derived.

Used during the context building pipeline to track where an incoming enchantment originated (e.g., generated by the Table vs. supplied by a Tome) so the conflict resolution logic can determine the appropriate action.

  • Constructor Details

    • PendingEnchantment

      public PendingEnchantment(Optional<net.minecraft.world.item.enchantment.EnchantmentInstance> enchantment, EnchantmentSource source)
      Creates an instance of a PendingEnchantment record class.
      Parameters:
      enchantment - the value for the enchantment record component
      source - the value for the source record component
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this pending enchantment, unwrapping the optional for clarity in logs.
      Specified by:
      toString in class Record
      Returns:
      The formatted string.
    • 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.
    • enchantment

      public Optional<net.minecraft.world.item.enchantment.EnchantmentInstance> enchantment()
      Returns the value of the enchantment record component.
      Returns:
      the value of the enchantment record component
    • source

      public EnchantmentSource source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component