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,AbstractScrollArea,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 TypeFieldDescriptionbooleanprotected floatprivate booleanprotected intprotected booleanprivate Componentprivate static final doubleprotected intprivate static final doubleprivate intprivate final WidgetTooltipHolderstatic final intbooleanprotected intprivate intprivate intFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected MutableComponentprotected voiddefaultButtonNarrationText(NarrationElementOutput pNarrationElementOutput) intintintintgetRight()intintgetWidth()intgetX()intgetY()booleanisActive()booleanbooleanbooleanbooleanisMouseOver(double pMouseX, double pMouseY) Checks if the given mouse coordinates are over the GUI element.protected booleanisValidClickButton(int pButton) booleanmouseClicked(double pMouseX, double pMouseY, int pButton) Called when a mouse button is clicked within the GUI element.booleanmouseDragged(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY) Called when the mouse is dragged within the GUI element.booleanmouseReleased(double pMouseX, double pMouseY, int pButton) Called when a mouse button is released within the GUI element.nextFocusPath(FocusNavigationEvent p_265640_) Retrieves the next focus path based on the given focus navigation event.voidonClick(double pMouseX, double pMouseY) Deprecated.protected voidonDrag(double pMouseX, double pMouseY, double pDragX, double pDragY) voidonRelease(double pMouseX, double pMouseY) static voidplayButtonClickSound(SoundManager pSoundManager) voidplayDownSound(SoundManager pHandler) final voidrender(GuiGraphics p_282421_, int p_93658_, int p_93659_, float p_93660_) Renders the graphical user interface (GUI) element.protected voidrenderScrollingString(GuiGraphics pGuiGraphics, Font pFont, int pWidth, int pColor) static voidrenderScrollingString(GuiGraphics pGuiGraphics, Font pFont, Component pText, int pMinX, int pMinY, int pMaxX, int pMaxY, int pColor) static voidrenderScrollingString(GuiGraphics pGuiGraphics, Font pFont, Component pText, int pCenterX, int pMinX, int pMinY, int pMaxX, int pMaxY, int pColor) protected abstract voidrenderWidget(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) voidsetAlpha(float pAlpha) voidsetFGColor(int color) voidsetFocused(boolean pFocused) Sets the focus state of the GUI element.voidsetHeight(int pHeight) voidsetMessage(Component pMessage) voidsetRectangle(int pWidth, int pHeight, int pX, int pY) voidsetSize(int pWidth, int pHeight) voidsetTabOrderGroup(int pTabOrderGroup) voidsetTooltip(Tooltip pTooltip) voidsetTooltipDelay(Duration pTooltipDelay) voidsetWidth(int pWidth) voidsetX(int pX) voidsetY(int pY) final voidupdateNarration(NarrationElementOutput p_259921_) Updates the narration output with the current narration information.protected abstract voidupdateWidgetNarration(NarrationElementOutput pNarrationElementOutput) voidvisitWidgets(Consumer<AbstractWidget> p_265566_) static MutableComponentwrapDefaultNarrationMessage(Component pMessage) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
charTyped, getBorderForArrowNavigation, getCurrentFocusPath, keyPressed, keyReleased, mouseMoved, mouseScrolledMethods inherited from interface net.neoforged.neoforge.client.extensions.IAbstractWidgetExtension
onClickMethods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPositionMethods inherited from interface net.minecraft.client.gui.narration.NarratableEntry
getNarratables
-
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:
getHeightin interfaceLayoutElement
-
render
Description copied from interface:RenderableRenders the graphical user interface (GUI) element.- Specified by:
renderin interfaceRenderable- Parameters:
p_282421_- the GuiGraphics object used for rendering.p_93658_- the x-coordinate of the mouse cursor.p_93659_- the y-coordinate of the mouse cursor.p_93660_- 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) Description copied from interface:GuiEventListenerCalled when a mouse button is clicked within the GUI element.- Specified by:
mouseClickedin interfaceGuiEventListener- Parameters:
pMouseX- the X coordinate of the mouse.pMouseY- the Y coordinate of the mouse.pButton- the button that was clicked.- Returns:
trueif the event is consumed,falseotherwise.
-
mouseReleased
public boolean mouseReleased(double pMouseX, double pMouseY, int pButton) Description copied from interface:GuiEventListenerCalled when a mouse button is released within the GUI element.- Specified by:
mouseReleasedin interfaceGuiEventListener- Parameters:
pMouseX- the X coordinate of the mouse.pMouseY- the Y coordinate of the mouse.pButton- the button that was released.- Returns:
trueif the event is consumed,falseotherwise.
-
isValidClickButton
protected boolean isValidClickButton(int pButton) -
mouseDragged
public boolean mouseDragged(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY) Description copied from interface:GuiEventListenerCalled when the mouse is dragged within the GUI element.- Specified by:
mouseDraggedin 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:
trueif the event is consumed,falseotherwise.
-
isMouseOver
public boolean isMouseOver(double pMouseX, double pMouseY) Description copied from interface:GuiEventListenerChecks if the given mouse coordinates are over the GUI element.- Specified by:
isMouseOverin interfaceGuiEventListener- Parameters:
pMouseX- the X coordinate of the mouse.pMouseY- the Y coordinate of the mouse.- Returns:
trueif the mouse is over the GUI element,falseotherwise.
-
playDownSound
-
playButtonClickSound
-
getWidth
public int getWidth()- Specified by:
getWidthin 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:
isFocusedin interfaceGuiEventListener
-
isHovered
public boolean isHovered() -
isHoveredOrFocused
public boolean isHoveredOrFocused() -
isActive
public boolean isActive()- Specified by:
isActivein interfaceNarratableEntry
-
setFocused
public void setFocused(boolean pFocused) Description copied from interface:GuiEventListenerSets the focus state of the GUI element.- Specified by:
setFocusedin interfaceGuiEventListener- Parameters:
pFocused-trueto apply focus,falseto remove focus
-
getFGColor
public int getFGColor() -
setFGColor
public void setFGColor(int color) -
clearFGColor
public void clearFGColor() -
narrationPriority
- Specified by:
narrationPriorityin interfaceNarratableEntry
-
updateNarration
Description copied from interface:NarrationSupplierUpdates the narration output with the current narration information.- Specified by:
updateNarrationin interfaceNarrationSupplier- Parameters:
p_259921_- the output to update with narration information.
-
updateWidgetNarration
-
defaultButtonNarrationText
-
getX
public int getX()- Specified by:
getXin interfaceLayoutElement
-
setX
public void setX(int pX) - Specified by:
setXin interfaceLayoutElement
-
getY
public int getY()- Specified by:
getYin interfaceLayoutElement
-
setY
public void setY(int pY) - Specified by:
setYin interfaceLayoutElement
-
getRight
public int getRight() -
getBottom
public int getBottom() -
visitWidgets
- Specified by:
visitWidgetsin interfaceLayoutElement
-
setSize
public void setSize(int pWidth, int pHeight) -
getRectangle
- Specified by:
getRectanglein interfaceGuiEventListener- Specified by:
getRectanglein interfaceLayoutElement
-
setRectangle
public void setRectangle(int pWidth, int pHeight, int pX, int pY) -
getTabOrderGroup
public int getTabOrderGroup()- Specified by:
getTabOrderGroupin interfaceTabOrderedElement
-
setTabOrderGroup
public void setTabOrderGroup(int pTabOrderGroup)
-
IAbstractWidgetExtension.onClick(double, double, int)instead.