Class WidgetAnimatedStat
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
me.desht.pneumaticcraft.client.gui.widget.WidgetAnimatedStat
- All Implemented Interfaces:
IGuiAnimatedStat,ITickableWidget,net.minecraft.client.gui.components.events.GuiEventListener,net.minecraft.client.gui.components.Renderable,net.minecraft.client.gui.components.TabOrderedElement,net.minecraft.client.gui.layouts.LayoutElement,net.minecraft.client.gui.narration.NarratableEntry,net.minecraft.client.gui.narration.NarrationSupplier,net.minecraftforge.client.extensions.IAbstractWidgetExtension
public class WidgetAnimatedStat
extends net.minecraft.client.gui.components.AbstractWidget
implements IGuiAnimatedStat
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry
net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority -
Field Summary
Fields inherited from class net.minecraft.client.gui.components.AbstractWidget
ACCESSIBILITY_TEXTURE, active, alpha, height, isHovered, packedFGColor, UNSET_FG_COLOR, visible, WIDGETS_LOCATION, widthFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
Constructor Summary
ConstructorsConstructorDescriptionWidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, int backgroundColor) WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, int backgroundColor, net.minecraft.resources.ResourceLocation texture) WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, int backgroundColor, net.minecraft.world.item.ItemStack icon) WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, net.minecraft.network.chat.Component title, int xPos, int yPos, int backGroundColor, IGuiAnimatedStat statAbove, boolean leftSided) WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, net.minecraft.network.chat.Component title, WidgetAnimatedStat.StatIcon icon, int xPos, int yPos, int backGroundColor, IGuiAnimatedStat statAbove, boolean leftSided) WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, net.minecraft.network.chat.Component title, WidgetAnimatedStat.StatIcon icon, int backGroundColor, IGuiAnimatedStat statAbove, StatPanelLayout layout) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSubWidget(net.minecraft.client.gui.components.AbstractWidget widget) Add a subwidget to the panel.voidappendText(List<net.minecraft.network.chat.Component> text) Appends some more text to the existing text in this stat.booleancharTyped(char codePoint, int modifiers) protected booleanclicked(double mouseX, double mouseY) voidForces the stat to close.intGet the background color of this stat.intgetBaseX()intgetBaseY()net.minecraft.client.renderer.Rect2iGet a bounding box for this stat.intGet the effective Y position of this stat.intReturns the Y size of this stat.intReturns the X size of this stat.net.minecraft.network.chat.ComponentgetTitle()Get this stat's title line.booleanCheck if this stat is fully opened.booleanCheck which direction this expands to when opened.booleanisMouseOver(double mouseX, double mouseY) booleanCheck if the stat is currently toggled open (but not necessarily fully-open - seeIGuiAnimatedStat.isDoneExpanding())booleankeyPressed(int keyCode, int scanCode, int modifiers) booleanmouseClicked(double mouseX, double mouseY, int button) booleanmouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) booleanmouseReleased(double mouseX, double mouseY, int button) booleanmouseScrolled(double x, double y, double dir) voidopenStat()Forces the stat to open.voidremoveSubWidget(net.minecraft.client.gui.components.AbstractWidget widget) voidrenderStat(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource buffer, float partialTicks) Render the stat in 3D (in-world) context.voidrenderStat(net.minecraft.client.gui.GuiGraphics graphics, int x, int y, float partialTicks) Render the stat in 2D (gui) context.voidrenderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) voidsetAutoLineWrap(boolean wrap) Enable/disable auto-line-wrapping functionality of the widget.voidsetBackgroundColor(int backgroundColor) Set the background color of this stat.voidsetBaseX(int x) Sets the x position of this stat.voidsetBaseY(int y) Sets the base Y position of this stat (seeIGuiAnimatedStat.setParentStat(IGuiAnimatedStat).voidsetBeveled(boolean bevel) Should this stat be drawn with a beveled edge, or a plain edge? Default behaviour is a beveled edge for GUI side tabs, plain edge for HUD stats.voidsetExtraTooltipText(List<net.minecraft.network.chat.Component> extraTooltipText) voidsetForegroundColor(int foregroundColor) Set the foreground color of this stat, which is the color used to render any text which doesn't have explicit formatting styles.voidsetLeftSided(boolean leftSided) Set the direction this stat will expand in when opened.voidsetLineSpacing(int lineSpacing) Set the line spacing, in pixelsvoidsetMessage(net.minecraft.network.chat.Component message) voidsetMinimumContractedDimensions(int minWidth, int minHeight) Defines what dimensions the stat should have when it is not expanded (default 17x17, sufficient to display the stat's icon) and resets the stat to these dimensions.voidsetMinimumExpandedDimensions(int minWidth, int minHeight) Set the minimum width that this stat should expand to, even if the stat's text isn't that wide or tall.voidWhen this stat gets a parent stat assigned, the effective Y position of this stat should be auto-adjusted to be directly beneath the parent stat.voidsetReservedLines(int reservedLines) This can be used to reserve one or more lines at the top of the stat; text will only drawn below the reserved area.voidsetSubwidgetRenderOffsets(int left, int right) Define X offsets for subwidget rendering.Sets the main text of this stat.setText(net.minecraft.network.chat.Component text) Sets the main text of this stat.voidsetTexture(net.minecraft.resources.ResourceLocation texture) Set the texture to use for the stat's iconvoidsetTexture(net.minecraft.world.item.ItemStack itemStack) Set the texture to use for the stat's iconvoidsetTitle(net.minecraft.network.chat.Component title) Set the title line for this stat; the text drawn on the top line.voidsetTitleColor(int titleColor) Set the title color of this stat, which is the color used to render the top title line of the stat.voidCalled each tick by theScreen.tick()method.voidupdateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput pNarrationElementOutput) Methods inherited from class net.minecraft.client.gui.components.AbstractWidget
clearFGColor, createNarrationMessage, createTooltipPositioner, defaultButtonNarrationText, getFGColor, getHeight, getMessage, getRectangle, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isValidClickButton, narrationPriority, nextFocusPath, onClick, onDrag, onRelease, playDownSound, render, renderScrollingString, renderScrollingString, renderTexture, setAlpha, setFGColor, setFocused, setHeight, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessageMethods 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
getCurrentFocusPath, getRectangle, isFocused, keyReleased, mouseMoved, nextFocusPath, setFocusedMethods inherited from interface net.minecraftforge.client.extensions.IAbstractWidgetExtension
onClickMethods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPositionMethods inherited from interface net.minecraft.client.gui.components.TabOrderedElement
getTabOrderGroup
-
Constructor Details
-
WidgetAnimatedStat
public WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, net.minecraft.network.chat.Component title, int xPos, int yPos, int backGroundColor, IGuiAnimatedStat statAbove, boolean leftSided) -
WidgetAnimatedStat
public WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, int backgroundColor) -
WidgetAnimatedStat
public WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, int backgroundColor, net.minecraft.world.item.ItemStack icon) -
WidgetAnimatedStat
public WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, int backgroundColor, net.minecraft.resources.ResourceLocation texture) -
WidgetAnimatedStat
public WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, net.minecraft.network.chat.Component title, WidgetAnimatedStat.StatIcon icon, int xPos, int yPos, int backGroundColor, IGuiAnimatedStat statAbove, boolean leftSided) -
WidgetAnimatedStat
public WidgetAnimatedStat(net.minecraft.client.gui.screens.Screen gui, net.minecraft.network.chat.Component title, WidgetAnimatedStat.StatIcon icon, int backGroundColor, IGuiAnimatedStat statAbove, StatPanelLayout layout)
-
-
Method Details
-
setMessage
public void setMessage(net.minecraft.network.chat.Component message) - Overrides:
setMessagein classnet.minecraft.client.gui.components.AbstractWidget
-
setParentStat
Description copied from interface:IGuiAnimatedStatWhen this stat gets a parent stat assigned, the effective Y position of this stat should be auto-adjusted to be directly beneath the parent stat. This will cause this stat to move up and down when the parent stat expands/moves.- Specified by:
setParentStatin interfaceIGuiAnimatedStat- Parameters:
stat- the parent stat
-
addSubWidget
public void addSubWidget(net.minecraft.client.gui.components.AbstractWidget widget) Description copied from interface:IGuiAnimatedStatAdd a subwidget to the panel. Subwidgets are automatically rendered by the panel itself, and don't need to be added to your GUI separately.- Specified by:
addSubWidgetin interfaceIGuiAnimatedStat- Parameters:
widget- the subwidget
-
removeSubWidget
public void removeSubWidget(net.minecraft.client.gui.components.AbstractWidget widget) -
setSubwidgetRenderOffsets
public void setSubwidgetRenderOffsets(int left, int right) Description copied from interface:IGuiAnimatedStatDefine X offsets for subwidget rendering. You should not normally need to call this method.- Specified by:
setSubwidgetRenderOffsetsin interfaceIGuiAnimatedStat- Parameters:
left- X offset when widget opens to the leftright- X offset when widget opens to the right
-
isLeftSided
public boolean isLeftSided()Description copied from interface:IGuiAnimatedStatCheck which direction this expands to when opened.- Specified by:
isLeftSidedin interfaceIGuiAnimatedStat- Returns:
- true if the stat expands to the left (the right edge of the state is anchored to the X position), false if the stat expands to the right
-
setLeftSided
public void setLeftSided(boolean leftSided) Description copied from interface:IGuiAnimatedStatSet the direction this stat will expand in when opened.- Specified by:
setLeftSidedin interfaceIGuiAnimatedStat- Parameters:
leftSided- true if the stat should expand to the left, false if the stat should expand to the right
-
setAutoLineWrap
public void setAutoLineWrap(boolean wrap) Description copied from interface:IGuiAnimatedStatEnable/disable auto-line-wrapping functionality of the widget. This is enabled by default. When disabled, the widget will make no effort to keep all text on screen; unwrapped text could extend off the right-hand edge of the screen.- Specified by:
setAutoLineWrapin interfaceIGuiAnimatedStat- Parameters:
wrap- enablement of wrapping
-
getTitle
public net.minecraft.network.chat.Component getTitle()Description copied from interface:IGuiAnimatedStatGet this stat's title line.- Specified by:
getTitlein interfaceIGuiAnimatedStat- Returns:
- the title
-
setTitle
public void setTitle(net.minecraft.network.chat.Component title) Description copied from interface:IGuiAnimatedStatSet the title line for this stat; the text drawn on the top line. This text is never wrapped, so be mindful of the length of this line.- Specified by:
setTitlein interfaceIGuiAnimatedStat- Parameters:
title- the title string
-
setText
Description copied from interface:IGuiAnimatedStatSets the main text of this stat. Every line should be stored in a separate list element, but lines do not need to be split manually; overlong lines will be automatically by wrapped to fit horizontally (if auto-wrap is enabled), and a scrollbar will be added if necessary.- Specified by:
setTextin interfaceIGuiAnimatedStat- Parameters:
text- a list of text components- Returns:
- this, so you can chain calls.
-
setText
Description copied from interface:IGuiAnimatedStatSets the main text of this stat. Every line should be stored in a separate list element, but lines do not need to be split manually; overlong lines will be automatically by wrapped to fit horizontally (if auto-wrap is enabled), and a scrollbar will be added if necessary.- Specified by:
setTextin interfaceIGuiAnimatedStat- Parameters:
text- a text component- Returns:
- this, so you can chain calls.
-
appendText
Description copied from interface:IGuiAnimatedStatAppends some more text to the existing text in this stat. This method will split overlong lines, same asIGuiAnimatedStat.setText(Component)- Specified by:
appendTextin interfaceIGuiAnimatedStat- Parameters:
text- a list of text components
-
setBackgroundColor
public void setBackgroundColor(int backgroundColor) Description copied from interface:IGuiAnimatedStatSet the background color of this stat.- Specified by:
setBackgroundColorin interfaceIGuiAnimatedStat- Parameters:
backgroundColor- color, in ARGB format
-
setForegroundColor
public void setForegroundColor(int foregroundColor) Description copied from interface:IGuiAnimatedStatSet the foreground color of this stat, which is the color used to render any text which doesn't have explicit formatting styles. The default foreground color is 0xFFFFFFFF, or white.- Specified by:
setForegroundColorin interfaceIGuiAnimatedStat- Parameters:
foregroundColor- the foreground color, in ARGB format
-
setTitleColor
public void setTitleColor(int titleColor) Description copied from interface:IGuiAnimatedStatSet the title color of this stat, which is the color used to render the top title line of the stat. The default title color is 0xFFFFFF00, or yellow.- Specified by:
setTitleColorin interfaceIGuiAnimatedStat- Parameters:
titleColor- the title color, in ARGB format
-
getBackgroundColor
public int getBackgroundColor()Description copied from interface:IGuiAnimatedStatGet the background color of this stat.- Specified by:
getBackgroundColorin interfaceIGuiAnimatedStat- Returns:
- the background color
-
setBeveled
public void setBeveled(boolean bevel) Description copied from interface:IGuiAnimatedStatShould this stat be drawn with a beveled edge, or a plain edge? Default behaviour is a beveled edge for GUI side tabs, plain edge for HUD stats. The color of the plain edge is a darkened version of the stat's background color.- Specified by:
setBeveledin interfaceIGuiAnimatedStat- Parameters:
bevel- true if a beveled edge should be drawn, false otherwise
-
setReservedLines
public void setReservedLines(int reservedLines) Description copied from interface:IGuiAnimatedStatThis can be used to reserve one or more lines at the top of the stat; text will only drawn below the reserved area. Useful if you want to have a static area for widget display.- Specified by:
setReservedLinesin interfaceIGuiAnimatedStat- Parameters:
reservedLines- number of text lines to reserve
-
setMinimumContractedDimensions
public void setMinimumContractedDimensions(int minWidth, int minHeight) Description copied from interface:IGuiAnimatedStatDefines what dimensions the stat should have when it is not expanded (default 17x17, sufficient to display the stat's icon) and resets the stat to these dimensions. Stats which should disappear completely when closed (e.g. the Pneumatic Armor HUD stats) should be given a minimum size of 0x0.- Specified by:
setMinimumContractedDimensionsin interfaceIGuiAnimatedStat- Parameters:
minWidth- the minimum widthminHeight- the minimum height
-
setMinimumExpandedDimensions
public void setMinimumExpandedDimensions(int minWidth, int minHeight) Description copied from interface:IGuiAnimatedStatSet the minimum width that this stat should expand to, even if the stat's text isn't that wide or tall. Use this if you need to ensure sufficient space for subwidgets. You don't need to call this if you're not adding any subwidgets, since the stat's expanded size will be automatically calculated from its text in that case.Requesting a width wider than is available (given current screen resolution), or taller than 12 lines of text, will be silently ignored, and clamped to those dimensions. The requested width does not include a 20-pixel margin for drawing a possible scrollbar, and the requested height does not include a 20 pixel margin for drawing the stat's title at the top.
- Specified by:
setMinimumExpandedDimensionsin interfaceIGuiAnimatedStat- Parameters:
minWidth- the desired width, may be 0minHeight- the desired height, may be 0
-
tickWidget
public void tickWidget()Description copied from interface:ITickableWidgetCalled each tick by theScreen.tick()method.- Specified by:
tickWidgetin interfaceITickableWidget
-
renderStat
public void renderStat(net.minecraft.client.gui.GuiGraphics graphics, int x, int y, float partialTicks) Description copied from interface:IGuiAnimatedStatRender the stat in 2D (gui) context.- Specified by:
renderStatin interfaceIGuiAnimatedStat- Parameters:
graphics- the gui graphics contextx- the mouse X positiony- the mouse Y positionpartialTicks- partial ticks since last client tick
-
clicked
protected boolean clicked(double mouseX, double mouseY) - Overrides:
clickedin classnet.minecraft.client.gui.components.AbstractWidget
-
renderWidget
public void renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) - Specified by:
renderWidgetin classnet.minecraft.client.gui.components.AbstractWidget
-
renderStat
public void renderStat(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource buffer, float partialTicks) Description copied from interface:IGuiAnimatedStatRender the stat in 3D (in-world) context.- Specified by:
renderStatin interfaceIGuiAnimatedStat- Parameters:
matrixStack- the matrix stackbuffer- the render bufferpartialTicks- partial ticks since last client tick
-
isMouseOver
public boolean isMouseOver(double mouseX, double mouseY) - Specified by:
isMouseOverin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
isMouseOverin classnet.minecraft.client.gui.components.AbstractWidget
-
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int button) - Specified by:
mouseClickedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
mouseClickedin classnet.minecraft.client.gui.components.AbstractWidget
-
mouseReleased
public boolean mouseReleased(double mouseX, double mouseY, int button) - Specified by:
mouseReleasedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
mouseReleasedin classnet.minecraft.client.gui.components.AbstractWidget
-
mouseDragged
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) - Specified by:
mouseDraggedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
mouseDraggedin classnet.minecraft.client.gui.components.AbstractWidget
-
mouseScrolled
public boolean mouseScrolled(double x, double y, double dir) - Specified by:
mouseScrolledin interfacenet.minecraft.client.gui.components.events.GuiEventListener
-
keyPressed
public boolean keyPressed(int keyCode, int scanCode, int modifiers) - Specified by:
keyPressedin interfacenet.minecraft.client.gui.components.events.GuiEventListener
-
charTyped
public boolean charTyped(char codePoint, int modifiers) - Specified by:
charTypedin interfacenet.minecraft.client.gui.components.events.GuiEventListener
-
closeStat
public void closeStat()Description copied from interface:IGuiAnimatedStatForces the stat to close.- Specified by:
closeStatin interfaceIGuiAnimatedStat
-
openStat
public void openStat()Description copied from interface:IGuiAnimatedStatForces the stat to open.- Specified by:
openStatin interfaceIGuiAnimatedStat
-
isStatOpen
public boolean isStatOpen()Description copied from interface:IGuiAnimatedStatCheck if the stat is currently toggled open (but not necessarily fully-open - seeIGuiAnimatedStat.isDoneExpanding())- Specified by:
isStatOpenin interfaceIGuiAnimatedStat- Returns:
- true if the stat is open
-
getEffectiveY
public int getEffectiveY()Description copied from interface:IGuiAnimatedStatGet the effective Y position of this stat. This is the same as getBaseY when there is no parent stat, but if there is one, this method returns the value described inIGuiAnimatedStat.setParentStat(IGuiAnimatedStat). This is the position used to render the stat, and to define the area where keyboard and mouse input is checked for.- Specified by:
getEffectiveYin interfaceIGuiAnimatedStat- Returns:
- the effective Y position
-
getBaseX
public int getBaseX()- Specified by:
getBaseXin interfaceIGuiAnimatedStat
-
getBaseY
public int getBaseY()- Specified by:
getBaseYin interfaceIGuiAnimatedStat
-
getStatHeight
public int getStatHeight()Description copied from interface:IGuiAnimatedStatReturns the Y size of this stat.- Specified by:
getStatHeightin interfaceIGuiAnimatedStat- Returns:
- the stat's height
-
getStatWidth
public int getStatWidth()Description copied from interface:IGuiAnimatedStatReturns the X size of this stat.- Specified by:
getStatWidthin interfaceIGuiAnimatedStat- Returns:
- the stat's width
-
setBaseY
public void setBaseY(int y) Description copied from interface:IGuiAnimatedStatSets the base Y position of this stat (seeIGuiAnimatedStat.setParentStat(IGuiAnimatedStat).- Specified by:
setBaseYin interfaceIGuiAnimatedStat- Parameters:
y- the Y position
-
setBaseX
public void setBaseX(int x) Description copied from interface:IGuiAnimatedStatSets the x position of this stat.- Specified by:
setBaseXin interfaceIGuiAnimatedStat- Parameters:
x- the X position
-
isDoneExpanding
public boolean isDoneExpanding()Description copied from interface:IGuiAnimatedStatCheck if this stat is fully opened.- Specified by:
isDoneExpandingin interfaceIGuiAnimatedStat- Returns:
- true if the stat is done with expanding (when text and subwidgets will be displayed)
-
getBounds
public net.minecraft.client.renderer.Rect2i getBounds()Description copied from interface:IGuiAnimatedStatGet a bounding box for this stat.- Specified by:
getBoundsin interfaceIGuiAnimatedStat- Returns:
- a bounding box
-
setExtraTooltipText
-
setLineSpacing
public void setLineSpacing(int lineSpacing) Description copied from interface:IGuiAnimatedStatSet the line spacing, in pixels- Specified by:
setLineSpacingin interfaceIGuiAnimatedStat- Parameters:
lineSpacing- the line spacing
-
setTexture
public void setTexture(net.minecraft.resources.ResourceLocation texture) Description copied from interface:IGuiAnimatedStatSet the texture to use for the stat's icon- Specified by:
setTexturein interfaceIGuiAnimatedStat- Parameters:
texture- resource location of a texture image, which should be 16x16 exactly
-
setTexture
public void setTexture(net.minecraft.world.item.ItemStack itemStack) Description copied from interface:IGuiAnimatedStatSet the texture to use for the stat's icon- Specified by:
setTexturein interfaceIGuiAnimatedStat- Parameters:
itemStack- an item to use for the texture
-
updateWidgetNarration
public void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput pNarrationElementOutput) - Specified by:
updateWidgetNarrationin classnet.minecraft.client.gui.components.AbstractWidget
-