Class AbstractWidget
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
- All Implemented Interfaces:
GuiEventListener,Renderable,TabOrderedElement,LayoutElement,NarratableEntry,NarrationSupplier
- Direct Known Subclasses:
AbstractButton,AbstractScrollArea,AbstractSliderButton,AbstractStringWidget,EditBox,GameModeSwitcherScreen.GameModeSlot,ImageWidget,ItemDisplayWidget,LoadingDotsWidget,OverlayRecipeComponent.OverlayRecipeButton,PlayerSkinWidget,RecipeButton,StateSwitchingButton,TabButton
public abstract class AbstractWidget
extends Object
implements Renderable, GuiEventListener, LayoutElement, NarratableEntry
-
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 int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanareCoordinatesInRectangle(double x, double y) voidprotected MutableComponentprotected voiddefaultButtonNarrationText(NarrationElementOutput narrationElementOutput) intintintintgetRight()intintgetWidth()intgetX()intgetY()booleanisActive()booleanbooleanbooleanbooleanisMouseOver(double mouseX, double mouseY) Checks if the given mouse coordinates are over the GUI element.protected booleanisValidClickButton(MouseButtonInfo buttonInfo) booleanmouseClicked(MouseButtonEvent p_447133_, boolean p_434606_) booleanmouseDragged(MouseButtonEvent p_445646_, double p_93645_, double p_93646_) booleanmouseReleased(MouseButtonEvent p_446092_) nextFocusPath(FocusNavigationEvent p_265640_) Retrieves the next focus path based on the given focus navigation event.voidonClick(MouseButtonEvent event, boolean isDoubleClick) protected voidonDrag(MouseButtonEvent event, double mouseX, double mouseY) voidonRelease(MouseButtonEvent event) static voidplayButtonClickSound(SoundManager soundManager) voidplayDownSound(SoundManager handler) final voidrender(GuiGraphics p_282421_, int p_93658_, int p_93659_, float p_93660_) Renders the graphical user interface (GUI) element.protected voidrenderScrollingString(GuiGraphics guiGraphics, Font font, int padding, int color) static voidrenderScrollingString(GuiGraphics guiGraphics, Font font, Component text, int minX, int minY, int maxX, int maxY, int color) static voidrenderScrollingString(GuiGraphics guiGraphics, Font font, Component text, int centerX, int minX, int minY, int maxX, int maxY, int color) protected abstract voidrenderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) voidsetAlpha(float alpha) voidsetFGColor(int color) voidsetFocused(boolean focused) Sets the focus state of the GUI element.voidsetHeight(int height) voidsetMessage(Component message) voidsetRectangle(int width, int height, int x, int y) voidsetSize(int width, int height) voidsetTabOrderGroup(int tabOrderGroup) voidsetTooltip(Tooltip tooltip) voidsetTooltipDelay(Duration tooltipDelay) voidsetWidth(int width) voidsetX(int x) voidsetY(int y) final voidupdateNarration(NarrationElementOutput p_259921_) Updates the narration output with the current narration information.protected abstract voidupdateWidgetNarration(NarrationElementOutput narrationElementOutput) voidvisitWidgets(Consumer<AbstractWidget> p_265566_) static MutableComponentwrapDefaultNarrationMessage(Component message) 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, mouseScrolled, shouldTakeFocusAfterInteractionMethods 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
-
setTooltipDelay
-
createNarrationMessage
-
wrapDefaultNarrationMessage
-
renderWidget
protected abstract void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) -
renderScrollingString
public static void renderScrollingString(GuiGraphics guiGraphics, Font font, Component text, int minX, int minY, int maxX, int maxY, int color) -
renderScrollingString
public static void renderScrollingString(GuiGraphics guiGraphics, Font font, Component text, int centerX, int minX, int minY, int maxX, int maxY, int color) -
renderScrollingString
-
onClick
-
onRelease
-
onDrag
-
mouseClicked
- Specified by:
mouseClickedin interfaceGuiEventListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceGuiEventListener
-
isValidClickButton
-
mouseDragged
- Specified by:
mouseDraggedin interfaceGuiEventListener
-
isMouseOver
public boolean isMouseOver(double mouseX, double mouseY) Description copied from interface:GuiEventListenerChecks if the given mouse coordinates are over the GUI element.- Specified by:
isMouseOverin interfaceGuiEventListener- Parameters:
mouseX- the X coordinate of the mouse.mouseY- 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 width) -
setHeight
public void setHeight(int height) -
setAlpha
public void setAlpha(float alpha) -
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 focused) Description copied from interface:GuiEventListenerSets the focus state of the GUI element.- Specified by:
setFocusedin interfaceGuiEventListener- Parameters:
focused-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 x) - Specified by:
setXin interfaceLayoutElement
-
getY
public int getY()- Specified by:
getYin interfaceLayoutElement
-
setY
public void setY(int y) - Specified by:
setYin interfaceLayoutElement
-
getRight
public int getRight() -
getBottom
public int getBottom() -
visitWidgets
- Specified by:
visitWidgetsin interfaceLayoutElement
-
setSize
public void setSize(int width, int height) -
getRectangle
- Specified by:
getRectanglein interfaceGuiEventListener- Specified by:
getRectanglein interfaceLayoutElement
-
areCoordinatesInRectangle
private boolean areCoordinatesInRectangle(double x, double y) -
setRectangle
public void setRectangle(int width, int height, int x, int y) -
getTabOrderGroup
public int getTabOrderGroup()- Specified by:
getTabOrderGroupin interfaceTabOrderedElement
-
setTabOrderGroup
public void setTabOrderGroup(int tabOrderGroup)
-