Interface IGuiAnimatedStat

All Superinterfaces:
net.minecraft.client.gui.components.events.GuiEventListener, ITickableWidget, net.minecraft.client.gui.components.TabOrderedElement
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 Type
    Method
    Description
    void
    addSubWidget(net.minecraft.client.gui.components.AbstractWidget widget)
    Add a subwidget to the panel.
    void
    appendText(List<net.minecraft.network.chat.Component> text)
    Appends some more text to the existing text in this stat.
    void
    Forces the stat to close.
    int
    Get the background color of this stat.
    int
     
    int
     
    net.minecraft.client.renderer.Rect2i
    Get a bounding box for this stat.
    int
    Get the effective Y position of this stat.
    int
    Returns the Y size of this stat.
    int
    Returns the X size of this stat.
    net.minecraft.network.chat.Component
    Get this stat's title line.
    boolean
    Check if this stat is fully opened.
    boolean
    Check which direction this expands to when opened.
    boolean
    Check if the stat is currently toggled open (but not necessarily fully-open - see isDoneExpanding())
    void
    Forces the stat to open.
    void
    renderStat(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource buffer, float partialTicks)
    Render the stat in 3D (in-world) context.
    void
    renderStat(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks)
    Render the stat in 2D (gui) context.
    void
    setAutoLineWrap(boolean wrap)
    Enable/disable auto-line-wrapping functionality of the widget.
    void
    setBackgroundColor(int backgroundColor)
    Set the background color of this stat.
    void
    setBaseX(int x)
    Sets the x position of this stat.
    void
    setBaseY(int y)
    Sets the base Y position of this stat (see setParentStat(IGuiAnimatedStat).
    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.
    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.
    void
    setLeftSided(boolean leftSided)
    Set the direction this stat will expand in when opened.
    void
    setLineSpacing(int spacing)
    Set the line spacing, in pixels
    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.
    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.
    void
    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.
    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.
    void
    setSubwidgetRenderOffsets(int left, int right)
    Define X offsets for subwidget rendering.
    setText(List<net.minecraft.network.chat.Component> text)
    Sets the main text of this stat.
    setText(net.minecraft.network.chat.Component text)
    Sets the main text of this stat.
    void
    setTexture(net.minecraft.resources.ResourceLocation texture)
    Set the texture to use for the stat's icon
    void
    setTexture(net.minecraft.world.item.ItemStack itemStack)
    Set the texture to use for the stat's icon
    void
    setTitle(net.minecraft.network.chat.Component title)
    Set the title line for this stat; the text drawn on the top line.
    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.

    Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener

    charTyped, getCurrentFocusPath, getRectangle, isFocused, isMouseOver, keyPressed, keyReleased, mouseClicked, mouseDragged, mouseMoved, mouseReleased, mouseScrolled, nextFocusPath, setFocused

    Methods inherited from interface me.desht.pneumaticcraft.api.client.ITickableWidget

    tickWidget

    Methods inherited from interface net.minecraft.client.gui.components.TabOrderedElement

    getTabOrderGroup
  • 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

      IGuiAnimatedStat setText(List<net.minecraft.network.chat.Component> text)
      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

      IGuiAnimatedStat setText(net.minecraft.network.chat.Component text)
      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

      void appendText(List<net.minecraft.network.chat.Component> text)
      Appends some more text to the existing text in this stat. This method will split overlong lines, same as setText(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 width
      minHeight - 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 0
      minHeight - the desired height, may be 0
    • setParentStat

      void setParentStat(IGuiAnimatedStat stat)
      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 (see setParentStat(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 in setParentStat(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(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks)
      Render the stat in 2D (gui) context.
      Parameters:
      graphics - the gui graphics context
      mouseX - the mouse X position
      mouseY - the mouse Y position
      partialTicks - 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 stack
      buffer - the render buffer
      partialTicks - 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 - see isDoneExpanding())
      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 left
      right - X offset when widget opens to the right