Record Class EnchantContext

java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.menu.enchant.model.EnchantContext
Record Components:
slotIndex - The specific index order of this context in the generated list. Determines determinism for texture variation and tracking.
applied - The existing enchantment instance currently present on the target item, if any.
pending - The proposed or incoming enchantment instance and its origin source.
xpRequirement - The total enchanting power (e.g., bookshelf count) needed to unlock this option.
lapisCost - The amount of Lapis Lazuli consumed upon executing this action.
xpCost - The amount of experience levels consumed upon executing this action.

public record EnchantContext(int slotIndex, Optional<net.minecraft.world.item.enchantment.EnchantmentInstance> applied, PendingEnchantment pending, int xpRequirement, int lapisCost, int xpCost) extends Record
An immutable data record representing the logical back-end state of a single generated enchantment option within the Enchanting Altar.

This context object holds the raw functional data (costs, requirements, instances) before it is processed into a visual render state for the UI.

  • Constructor Details

    • EnchantContext

      public EnchantContext(int slotIndex, Optional<net.minecraft.world.item.enchantment.EnchantmentInstance> applied, PendingEnchantment pending, int xpRequirement, int lapisCost, int xpCost)
      Creates an instance of a EnchantContext record class.
      Parameters:
      slotIndex - the value for the slotIndex record component
      applied - the value for the applied record component
      pending - the value for the pending record component
      xpRequirement - the value for the xpRequirement record component
      lapisCost - the value for the lapisCost record component
      xpCost - the value for the xpCost record component
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this context, unwrapping the inner optionals for easier debugging and logging.
      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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • slotIndex

      public int slotIndex()
      Returns the value of the slotIndex record component.
      Returns:
      the value of the slotIndex record component
    • applied

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

      public PendingEnchantment pending()
      Returns the value of the pending record component.
      Returns:
      the value of the pending record component
    • xpRequirement

      public int xpRequirement()
      Returns the value of the xpRequirement record component.
      Returns:
      the value of the xpRequirement record component
    • lapisCost

      public int lapisCost()
      Returns the value of the lapisCost record component.
      Returns:
      the value of the lapisCost record component
    • xpCost

      public int xpCost()
      Returns the value of the xpCost record component.
      Returns:
      the value of the xpCost record component