Class EnchantWidget.Available

java.lang.Object
johnsmith.enchantingoverhauled.client.gui.widget.enchant.EnchantWidget
johnsmith.enchantingoverhauled.client.gui.widget.enchant.EnchantWidget.Available
Enclosing class:
EnchantWidget

public static final class EnchantWidget.Available extends EnchantWidget
Represents a standard, interactable enchantment option within the Enchantment Screen.

This widget actively evaluates the player's current experience and lapis lazuli to determine if the enchantment is affordable. If the player cannot afford the action, the widget dynamically switches to a disabled visual state while remaining in the "Available" structural category.

  • Constructor Details

    • Available

      public Available(int x, int y, EnchantRenderState state, int texIndex, boolean usePlainBackground, Runnable onPressAction)
      Constructs a new EnchantWidget.Available.
      Parameters:
      x - The X screen coordinate.
      y - The Y screen coordinate.
      state - The visual and data state representing this specific enchantment.
      texIndex - The deterministic texture index (0-9) used to select the randomized background variant.
      usePlainBackground - True if the user configuration requests plain backgrounds.
      onPressAction - The callback to execute when this widget is successfully clicked.
  • Method Details

    • mouseClicked

      public boolean mouseClicked(double mouseX, double mouseY, int button)
      Handles mouse click events on this widget. Intercepts the click and denies it if the player cannot afford the enchantment.
      Overrides:
      mouseClicked in class EnchantWidget
      Parameters:
      mouseX - The X coordinate of the mouse pointer.
      mouseY - The Y coordinate of the mouse pointer.
      button - The mouse button being pressed.
      Returns:
      true if the click was consumed and processed, false otherwise.
    • renderWidget

      protected void renderWidget(net.minecraft.client.gui.GuiGraphics context, int mouseX, int mouseY, float partialTick)
      Renders the widget's background, cost sprites, and text components to the screen. Dynamically adjusts colors and textures based on hover state and affordability.
      Specified by:
      renderWidget in class EnchantWidget
      Parameters:
      context - The GUI graphics context to draw to.
      mouseX - The current mouse X coordinate.
      mouseY - The current mouse Y coordinate.
      partialTick - The partial tick time for animations.