Class EnchantWidget.Available
java.lang.Object
johnsmith.enchantingoverhauled.client.gui.widget.enchant.EnchantWidget
johnsmith.enchantingoverhauled.client.gui.widget.enchant.EnchantWidget.Available
- Enclosing class:
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class johnsmith.enchantingoverhauled.client.gui.widget.enchant.EnchantWidget
EnchantWidget.Available, EnchantWidget.Empty, EnchantWidget.Locked, EnchantWidget.Maxed, EnchantWidget.Overleveled -
Field Summary
Fields inherited from class johnsmith.enchantingoverhauled.client.gui.widget.enchant.EnchantWidget
DISABLED_LEVEL_SPRITES, ENABLED_LEVEL_SPRITES, GALACTIC_FONT_ID, isHovered, layout, onPressAction, state, texIndex, usePlainBackground, x, y -
Constructor Summary
ConstructorsConstructorDescriptionAvailable(int x, int y, EnchantRenderState state, int texIndex, boolean usePlainBackground, Runnable onPressAction) Constructs a new EnchantWidget.Available. -
Method Summary
Modifier and TypeMethodDescriptionbooleanmouseClicked(double mouseX, double mouseY, int button) Handles mouse click events on this widget.protected voidrenderWidget(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.Methods inherited from class johnsmith.enchantingoverhauled.client.gui.widget.enchant.EnchantWidget
drawScrollingString, getFormattedEnchantmentName, getState, render, setOnPressAction, setState, setTexIndex, updatePosition
-
Constructor Details
-
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:
mouseClickedin classEnchantWidget- 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:
renderWidgetin classEnchantWidget- 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.
-