Record Class EnchantRenderState

java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.menu.enchant.model.EnchantRenderState
Record Components:
visualSource - The origin classification (Target, Source, Table) dictating the widget's texture and color palette.
enchantment - The target enchantment to be displayed.
displayLevel - The specific level integer to format and display in the UI (e.g., "II" or "V").
xpRequirement - The enchanting power required to display the slot as active.
xpCost - The experience cost to execute the action, determining the level sprite shown.
lapisCost - The lapis cost to execute the action.
state - The structural interactivity state of the widget (e.g., AVAILABLE, MAXED, LOCKED).

public record EnchantRenderState(EnchantmentSource visualSource, Optional<net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment>> enchantment, int displayLevel, int xpRequirement, int xpCost, int lapisCost, EnchantState state) extends Record
An immutable data record representing the evaluated visual front-end state of an enchantment slot widget.

This object decouples the pure logic representation (EnchantContext) from the GUI elements, pre-calculating the exact display text levels, textures, and interactivity statuses needed by the widgets.

  • Constructor Details

    • EnchantRenderState

      public EnchantRenderState(EnchantmentSource visualSource, Optional<net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment>> enchantment, int displayLevel, int xpRequirement, int xpCost, int lapisCost, EnchantState state)
      Creates an instance of a EnchantRenderState record class.
      Parameters:
      visualSource - the value for the visualSource record component
      enchantment - the value for the enchantment record component
      displayLevel - the value for the displayLevel record component
      xpRequirement - the value for the xpRequirement record component
      xpCost - the value for the xpCost record component
      lapisCost - the value for the lapisCost record component
      state - the value for the state record component
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this render state, formatting the inner holders for easier debugging and layout tracking.
      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.
    • visualSource

      public EnchantmentSource visualSource()
      Returns the value of the visualSource record component.
      Returns:
      the value of the visualSource record component
    • enchantment

      public Optional<net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment>> enchantment()
      Returns the value of the enchantment record component.
      Returns:
      the value of the enchantment record component
    • displayLevel

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

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

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

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

      public EnchantState state()
      Returns the value of the state record component.
      Returns:
      the value of the state record component