Class AbstractWidget
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
- All Implemented Interfaces:
GuiEventListener
,Renderable
,TabOrderedElement
,LayoutElement
,NarratableEntry
,NarrationSupplier
,IAbstractWidgetExtension
- Direct Known Subclasses:
AbstractButton
,AbstractContainerWidget
,AbstractScrollWidget
,AbstractSliderButton
,AbstractStringWidget
,EditBox
,GameModeSwitcherScreen.GameModeSlot
,ImageWidget
,LoadingDotsWidget
,OverlayRecipeComponent.OverlayRecipeButton
,PlayerSkinWidget
,RecipeButton
,StateSwitchingButton
,TabButton
public abstract class AbstractWidget
extends Object
implements Renderable, GuiEventListener, LayoutElement, NarratableEntry, IAbstractWidgetExtension
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry
NarratableEntry.NarrationPriority
-
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
protected float
private boolean
protected int
protected boolean
private Component
private static final double
protected int
private static final double
private int
private final WidgetTooltipHolder
static final int
boolean
protected int
private int
private int
Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected boolean
clicked
(double pMouseX, double pMouseY) protected MutableComponent
protected void
defaultButtonNarrationText
(NarrationElementOutput pNarrationElementOutput) int
int
int
int
getRight()
int
int
getWidth()
int
getX()
int
getY()
boolean
isActive()
boolean
boolean
boolean
boolean
isMouseOver
(double pMouseX, double pMouseY) Checks if the given mouse coordinates are over the GUI element.protected boolean
isValidClickButton
(int pButton) boolean
mouseClicked
(double pMouseX, double pMouseY, int pButton) Called when a mouse button is clicked within the GUI element.boolean
mouseDragged
(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY) Called when the mouse is dragged within the GUI element.boolean
mouseReleased
(double pMouseX, double pMouseY, int pButton) Called when a mouse button is released within the GUI element.nextFocusPath
(FocusNavigationEvent pEvent) Retrieves the next focus path based on the given focus navigation event.void
onClick
(double pMouseX, double pMouseY) Deprecated.protected void
onDrag
(double pMouseX, double pMouseY, double pDragX, double pDragY) void
onRelease
(double pMouseX, double pMouseY) void
playDownSound
(SoundManager pHandler) final void
render
(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) Renders the graphical user interface (GUI) element.protected void
renderScrollingString
(GuiGraphics pGuiGraphics, Font pFont, int pWidth, int pColor) static void
renderScrollingString
(GuiGraphics pGuiGraphics, Font pFont, Component pText, int pMinX, int pMinY, int pMaxX, int pMaxY, int pColor) static void
renderScrollingString
(GuiGraphics pGuiGraphics, Font pFont, Component pText, int pCenterX, int pMinX, int pMinY, int pMaxX, int pMaxY, int pColor) protected abstract void
renderWidget
(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) void
setAlpha
(float pAlpha) void
setFGColor
(int color) void
setFocused
(boolean pFocused) Sets the focus state of the GUI element.void
setHeight
(int pHeight) void
setMessage
(Component pMessage) void
setRectangle
(int pWidth, int pHeight, int pX, int pY) void
setSize
(int pWidth, int pHeight) void
setTabOrderGroup
(int pTabOrderGroup) void
setTooltip
(Tooltip pTooltip) void
setTooltipDelay
(Duration pTooltipDelay) void
setWidth
(int pWidth) void
setX
(int pX) void
setY
(int pY) final void
updateNarration
(NarrationElementOutput pNarrationElementOutput) Updates the narration output with the current narration information.protected abstract void
updateWidgetNarration
(NarrationElementOutput pNarrationElementOutput) void
visitWidgets
(Consumer<AbstractWidget> pConsumer) static MutableComponent
wrapDefaultNarrationMessage
(Component pMessage) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
charTyped, getCurrentFocusPath, keyPressed, keyReleased, mouseMoved, mouseScrolled
Methods inherited from interface net.neoforged.neoforge.client.extensions.IAbstractWidgetExtension
onClick
Methods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPosition
-
Field Details
-
PERIOD_PER_SCROLLED_PIXEL
private static final double PERIOD_PER_SCROLLED_PIXEL- See Also:
-
MIN_SCROLL_PERIOD
private static final double MIN_SCROLL_PERIOD- See Also:
-
width
protected int width -
height
protected int height -
x
private int x -
y
private int y -
message
-
isHovered
protected boolean isHovered -
active
public boolean active -
visible
public boolean visible -
alpha
protected float alpha -
tabOrderGroup
private int tabOrderGroup -
focused
private boolean focused -
tooltip
-
UNSET_FG_COLOR
public static final int UNSET_FG_COLOR- See Also:
-
packedFGColor
protected int packedFGColor
-
-
Constructor Details
-
AbstractWidget
-
-
Method Details
-
getHeight
public int getHeight()- Specified by:
getHeight
in interfaceLayoutElement
-
render
Renders the graphical user interface (GUI) element.- Specified by:
render
in interfaceRenderable
- Parameters:
pGuiGraphics
- the GuiGraphics object used for rendering.pMouseX
- the x-coordinate of the mouse cursor.pMouseY
- the y-coordinate of the mouse cursor.pPartialTick
- the partial tick time.
-
setTooltip
-
getTooltip
-
setTooltipDelay
-
createNarrationMessage
-
wrapDefaultNarrationMessage
-
renderWidget
protected abstract void renderWidget(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) -
renderScrollingString
public static void renderScrollingString(GuiGraphics pGuiGraphics, Font pFont, Component pText, int pMinX, int pMinY, int pMaxX, int pMaxY, int pColor) -
renderScrollingString
public static void renderScrollingString(GuiGraphics pGuiGraphics, Font pFont, Component pText, int pCenterX, int pMinX, int pMinY, int pMaxX, int pMaxY, int pColor) -
renderScrollingString
-
onClick
Deprecated.Neo: UseIAbstractWidgetExtension.onClick(double, double, int)
instead. -
onRelease
public void onRelease(double pMouseX, double pMouseY) -
onDrag
protected void onDrag(double pMouseX, double pMouseY, double pDragX, double pDragY) -
mouseClicked
public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) Called when a mouse button is clicked within the GUI element.- Specified by:
mouseClicked
in interfaceGuiEventListener
- Parameters:
pMouseX
- the X coordinate of the mouse.pMouseY
- the Y coordinate of the mouse.pButton
- the button that was clicked.- Returns:
true
if the event is consumed,false
otherwise.
-
mouseReleased
public boolean mouseReleased(double pMouseX, double pMouseY, int pButton) Called when a mouse button is released within the GUI element.- Specified by:
mouseReleased
in interfaceGuiEventListener
- Parameters:
pMouseX
- the X coordinate of the mouse.pMouseY
- the Y coordinate of the mouse.pButton
- the button that was released.- Returns:
true
if the event is consumed,false
otherwise.
-
isValidClickButton
protected boolean isValidClickButton(int pButton) -
mouseDragged
public boolean mouseDragged(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY) Called when the mouse is dragged within the GUI element.- Specified by:
mouseDragged
in interfaceGuiEventListener
- Parameters:
pMouseX
- the X coordinate of the mouse.pMouseY
- the Y coordinate of the mouse.pButton
- the button that is being dragged.pDragX
- the X distance of the drag.pDragY
- the Y distance of the drag.- Returns:
true
if the event is consumed,false
otherwise.
-
clicked
protected boolean clicked(double pMouseX, double pMouseY) -
isMouseOver
public boolean isMouseOver(double pMouseX, double pMouseY) Checks if the given mouse coordinates are over the GUI element.- Specified by:
isMouseOver
in interfaceGuiEventListener
- Parameters:
pMouseX
- the X coordinate of the mouse.pMouseY
- the Y coordinate of the mouse.- Returns:
true
if the mouse is over the GUI element,false
otherwise.
-
playDownSound
-
getWidth
public int getWidth()- Specified by:
getWidth
in interfaceLayoutElement
-
setWidth
public void setWidth(int pWidth) -
setHeight
public void setHeight(int pHeight) -
setAlpha
public void setAlpha(float pAlpha) -
setMessage
-
getMessage
-
isFocused
public boolean isFocused()- Specified by:
isFocused
in interfaceGuiEventListener
-
isHovered
public boolean isHovered() -
isHoveredOrFocused
public boolean isHoveredOrFocused() -
isActive
public boolean isActive()- Specified by:
isActive
in interfaceNarratableEntry
-
setFocused
public void setFocused(boolean pFocused) Sets the focus state of the GUI element.- Specified by:
setFocused
in interfaceGuiEventListener
- Parameters:
pFocused
-true
to apply focus,false
to remove focus
-
getFGColor
public int getFGColor() -
setFGColor
public void setFGColor(int color) -
clearFGColor
public void clearFGColor() -
narrationPriority
- Specified by:
narrationPriority
in interfaceNarratableEntry
-
updateNarration
Updates the narration output with the current narration information.- Specified by:
updateNarration
in interfaceNarrationSupplier
- Parameters:
pNarrationElementOutput
- the output to update with narration information.
-
updateWidgetNarration
-
defaultButtonNarrationText
-
getX
public int getX()- Specified by:
getX
in interfaceLayoutElement
-
setX
public void setX(int pX) - Specified by:
setX
in interfaceLayoutElement
-
getY
public int getY()- Specified by:
getY
in interfaceLayoutElement
-
setY
public void setY(int pY) - Specified by:
setY
in interfaceLayoutElement
-
getRight
public int getRight() -
getBottom
public int getBottom() -
visitWidgets
- Specified by:
visitWidgets
in interfaceLayoutElement
-
setSize
public void setSize(int pWidth, int pHeight) -
getRectangle
- Specified by:
getRectangle
in interfaceGuiEventListener
- Specified by:
getRectangle
in interfaceLayoutElement
-
setRectangle
public void setRectangle(int pWidth, int pHeight, int pX, int pY) -
getTabOrderGroup
public int getTabOrderGroup()- Specified by:
getTabOrderGroup
in interfaceTabOrderedElement
-
setTabOrderGroup
public void setTabOrderGroup(int pTabOrderGroup)
-
IAbstractWidgetExtension.onClick(double, double, int)
instead.