Interface IGuiAnimatedStat
- All Superinterfaces:
net.minecraft.client.gui.components.events.GuiEventListener,ITickableWidget
- All Known Implementing Classes:
WidgetAnimatedStat
public interface IGuiAnimatedStat
extends ITickableWidget, net.minecraft.client.gui.components.events.GuiEventListener
This interface doesn't have to be implemented. In PneumaticCraft there already is a widget which implements this
interface used in many places: GUI side tabs, Pneumatic Helmet 2D and 3D stats. You can get an instance of this
class via the various
IClientRegistry getAnimatedStat() methods.-
Field Summary
Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
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.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.booleanCheck if the stat is currently toggled open (but not necessarily fully-open - seeisDoneExpanding())voidopenStat()Forces the stat to open.voidrenderStat(com.mojang.blaze3d.vertex.PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) Render the stat in 2D (gui) context.voidrenderStat(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource buffer, float partialTicks) Render the stat in 3D (in-world) context.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 (seesetParentStat(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.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 spacing) Set the line spacing, in pixelsvoidsetMinimumContractedDimensions(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.Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
changeFocus, charTyped, isMouseOver, keyPressed, keyReleased, mouseClicked, mouseDragged, mouseMoved, mouseReleased, mouseScrolledMethods inherited from interface me.desht.pneumaticcraft.api.client.ITickableWidget
tickWidget
-
Method Details
-
isLeftSided
boolean isLeftSided()Check which direction this expands to when opened.- 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
void setLeftSided(boolean leftSided) Set the direction this stat will expand in when opened.- Parameters:
leftSided- true if the stat should expand to the left, false if the stat should expand to the right
-
isDoneExpanding
boolean isDoneExpanding()Check if this stat is fully opened.- Returns:
- true if the stat is done with expanding (when text and subwidgets will be displayed)
-
setText
Sets 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.- Parameters:
text- a list of text components- Returns:
- this, so you can chain calls.
-
setText
Sets 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.- Parameters:
text- a text component- Returns:
- this, so you can chain calls.
-
appendText
Appends some more text to the existing text in this stat. This method will split overlong lines, same assetText(Component)- Parameters:
text- a list of text components
-
setMinimumContractedDimensions
void setMinimumContractedDimensions(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. Stats which should disappear completely when closed (e.g. the Pneumatic Armor HUD stats) should be given a minimum size of 0x0.- Parameters:
minWidth- the minimum widthminHeight- the minimum height
-
setMinimumExpandedDimensions
void setMinimumExpandedDimensions(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. 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.
- Parameters:
minWidth- the desired width, may be 0minHeight- the desired height, may be 0
-
setParentStat
When 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.- Parameters:
stat- the parent stat
-
setBackgroundColor
void setBackgroundColor(int backgroundColor) Set the background color of this stat.- Parameters:
backgroundColor- color, in ARGB format
-
setForegroundColor
void setForegroundColor(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. The default foreground color is 0xFFFFFFFF, or white.- Parameters:
foregroundColor- the foreground color, in ARGB format
-
setTitleColor
void setTitleColor(int titleColor) Set 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.- Parameters:
titleColor- the title color, in ARGB format
-
getBackgroundColor
int getBackgroundColor()Get the background color of this stat.- Returns:
- the background color
-
setBeveled
void setBeveled(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. The color of the plain edge is a darkened version of the stat's background color.- Parameters:
bevel- true if a beveled edge should be drawn, false otherwise
-
setBaseX
void setBaseX(int x) Sets the x position of this stat.- Parameters:
x- the X position
-
setBaseY
void setBaseY(int y) Sets the base Y position of this stat (seesetParentStat(IGuiAnimatedStat).- Parameters:
y- the Y position
-
getEffectiveY
int getEffectiveY()Get 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 insetParentStat(IGuiAnimatedStat). This is the position used to render the stat, and to define the area where keyboard and mouse input is checked for.- Returns:
- the effective Y position
-
getBaseX
int getBaseX() -
getBaseY
int getBaseY() -
getStatHeight
int getStatHeight()Returns the Y size of this stat.- Returns:
- the stat's height
-
getStatWidth
int getStatWidth()Returns the X size of this stat.- Returns:
- the stat's width
-
getBounds
net.minecraft.client.renderer.Rect2i getBounds()Get a bounding box for this stat.- Returns:
- a bounding box
-
renderStat
void renderStat(com.mojang.blaze3d.vertex.PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) Render the stat in 2D (gui) context.- Parameters:
matrixStack- the matrix stackmouseX- the mouse X positionmouseY- the mouse Y positionpartialTicks- partial ticks since last client tick
-
renderStat
void renderStat(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource buffer, float partialTicks) Render the stat in 3D (in-world) context.- Parameters:
matrixStack- the matrix stackbuffer- the render bufferpartialTicks- partial ticks since last client tick
-
closeStat
void closeStat()Forces the stat to close. -
openStat
void openStat()Forces the stat to open. -
isStatOpen
boolean isStatOpen()Check if the stat is currently toggled open (but not necessarily fully-open - seeisDoneExpanding())- Returns:
- true if the stat is open
-
setAutoLineWrap
void setAutoLineWrap(boolean wrap) Enable/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.- Parameters:
wrap- enablement of wrapping
-
getTitle
net.minecraft.network.chat.Component getTitle()Get this stat's title line.- Returns:
- the title
-
setTitle
void setTitle(net.minecraft.network.chat.Component title) Set 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.- Parameters:
title- the title string
-
setReservedLines
void setReservedLines(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. Useful if you want to have a static area for widget display.- Parameters:
reservedLines- number of text lines to reserve
-
setTexture
void setTexture(net.minecraft.resources.ResourceLocation texture) Set the texture to use for the stat's icon- Parameters:
texture- resource location of a texture image, which should be 16x16 exactly
-
setTexture
void setTexture(net.minecraft.world.item.ItemStack itemStack) Set the texture to use for the stat's icon- Parameters:
itemStack- an item to use for the texture
-
setLineSpacing
void setLineSpacing(int spacing) Set the line spacing, in pixels- Parameters:
spacing- the line spacing
-
addSubWidget
void addSubWidget(net.minecraft.client.gui.components.AbstractWidget widget) Add a subwidget to the panel. Subwidgets are automatically rendered by the panel itself, and don't need to be added to your GUI separately.- Parameters:
widget- the subwidget
-
setSubwidgetRenderOffsets
void setSubwidgetRenderOffsets(int left, int right) Define X offsets for subwidget rendering. You should not normally need to call this method.- Parameters:
left- X offset when widget opens to the leftright- X offset when widget opens to the right
-