Class RerollWidget
java.lang.Object
johnsmith.enchantingoverhauled.client.gui.widget.enchant.RerollWidget
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
ConstructorsConstructorDescriptionRerollWidget(EnchantmentMenu menu, MenuLayoutConfig layout, Runnable onPress) Constructs a new RerollWidget. -
Method Summary
Modifier and TypeMethodDescriptionbooleanmouseClicked(double mouseX, double mouseY, int button) Executes the reroll logic if the button is hovered and clicked with the primary mouse button.voidrender(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.booleanrenderTooltip(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.voidupdatePosition(int alignX, int alignY) Updates the alignment origin for the widget.
-
Constructor Details
-
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.
-