java.lang.Object
johnsmith.enchantingoverhauled.client.gui.widget.enchant.RerollWidget

public class RerollWidget extends Object
Handles the rendering, tooltip generation, and interaction logic for the "Reroll" button within the Enchantment Screen.

Re-rolling consumes resources based on the item's existing enchantments to refresh the generated table offerings without needing to physically remove and replace the item.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new RerollWidget.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    mouseClicked(double mouseX, double mouseY, int button)
    Executes the reroll logic if the button is hovered and clicked with the primary mouse button.
    void
    render(net.minecraft.client.gui.GuiGraphics context, int mouseX, int mouseY, float partialTick, int lapisCount, net.minecraft.client.Minecraft minecraft)
    Renders the button background and cost sprite based on affordability and hover states.
    boolean
    renderTooltip(net.minecraft.client.gui.GuiGraphics context, int mouseX, int mouseY, net.minecraft.client.gui.Font font, int lapisCount, net.minecraft.client.Minecraft minecraft)
    Evaluates and renders the tooltip describing the reroll action and its resource costs.
    void
    updatePosition(int alignX, int alignY)
    Updates the alignment origin for the widget.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RerollWidget

      public RerollWidget(EnchantmentMenu menu, MenuLayoutConfig layout, Runnable onPress)
      Constructs a new RerollWidget.
      Parameters:
      menu - The active EnchantmentMenu providing container state.
      layout - The screen layout configuration for drawing boundaries.
      onPress - The callback fired when the button is successfully clicked.
  • Method Details

    • updatePosition

      public void updatePosition(int alignX, int alignY)
      Updates the alignment origin for the widget.
      Parameters:
      alignX - The parent screen's left position.
      alignY - The parent screen's top position.
    • render

      public void render(net.minecraft.client.gui.GuiGraphics context, int mouseX, int mouseY, float partialTick, int lapisCount, net.minecraft.client.Minecraft minecraft)
      Renders the button background and cost sprite based on affordability and hover states.
      Parameters:
      context - The GUI graphics context.
      mouseX - The current mouse X coordinate.
      mouseY - The current mouse Y coordinate.
      partialTick - The partial tick time.
      lapisCount - The available lapis lazuli in the container.
      minecraft - The Minecraft client instance.
    • renderTooltip

      public boolean renderTooltip(net.minecraft.client.gui.GuiGraphics context, int mouseX, int mouseY, net.minecraft.client.gui.Font font, int lapisCount, net.minecraft.client.Minecraft minecraft)
      Evaluates and renders the tooltip describing the reroll action and its resource costs.
      Parameters:
      context - The GUI graphics context.
      mouseX - The mouse X coordinate.
      mouseY - The mouse Y coordinate.
      font - The client font renderer.
      lapisCount - The available lapis lazuli in the container.
      minecraft - The Minecraft client instance.
      Returns:
      true if the tooltip was drawn, false otherwise.
    • mouseClicked

      public boolean mouseClicked(double mouseX, double mouseY, int button)
      Executes the reroll logic if the button is hovered and clicked with the primary mouse button.
      Parameters:
      mouseX - The mouse X coordinate.
      mouseY - The mouse Y coordinate.
      button - The mouse button pressed.
      Returns:
      true if the click was consumed, false otherwise.