Class GuiUtils

java.lang.Object
net.minecraftforge.fmlclient.gui.GuiUtils

public class GuiUtils extends Object
This class provides several methods and constants used by the Config GUI classes.
Author:
bspkrs
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static ItemStack
     
    static int[]
     
    static int
     
    static int
     
    static int
     
    static String
     
    static String
     
    static String
     
    static String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    drawContinuousTexturedBox​(PoseStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
    Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler.
    static void
    drawContinuousTexturedBox​(PoseStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
    Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler.
    static void
    drawContinuousTexturedBox​(PoseStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
    Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler.
    static void
    drawContinuousTexturedBox​(PoseStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
    Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler.
    static void
    drawGradientRect​(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
     
    static void
    drawHoveringText​(PoseStack mStack, List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    drawHoveringText​(PoseStack mStack, List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    drawHoveringText​(ItemStack stack, PoseStack pStack, List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    drawHoveringText​(ItemStack stack, PoseStack mStack, List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    drawInscribedRect​(PoseStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
     
    static void
    drawInscribedRect​(PoseStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
     
    static void
    drawTexturedModalRect​(PoseStack matrixStack, int x, int y, int u, int v, int width, int height, float zLevel)
     
    static int
    getColorCode​(char c, boolean isLighter)
     
    static void
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    Deprecated, for removal: This API element is subject to removal in a future version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • GuiUtils

      public GuiUtils()
  • Method Details

    • getColorCode

      public static int getColorCode(char c, boolean isLighter)
    • drawContinuousTexturedBox

      public static void drawContinuousTexturedBox(PoseStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
      Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. It is assumed that the desired texture ResourceLocation object has been bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
      Parameters:
      matrixStack - the gui matrix stack
      x - x axis offset
      y - y axis offset
      u - bound resource location image x offset
      v - bound resource location image y offset
      width - the desired box width
      height - the desired box height
      textureWidth - the width of the box texture in the resource location image
      textureHeight - the height of the box texture in the resource location image
      borderSize - the size of the box's borders
      zLevel - the zLevel to draw at
    • drawContinuousTexturedBox

      public static void drawContinuousTexturedBox(PoseStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
      Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. The provided ResourceLocation object will be bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
      Parameters:
      matrixStack - the gui matrix stack
      res - the ResourceLocation object that contains the desired image
      x - x axis offset
      y - y axis offset
      u - bound resource location image x offset
      v - bound resource location image y offset
      width - the desired box width
      height - the desired box height
      textureWidth - the width of the box texture in the resource location image
      textureHeight - the height of the box texture in the resource location image
      borderSize - the size of the box's borders
      zLevel - the zLevel to draw at
    • drawContinuousTexturedBox

      public static void drawContinuousTexturedBox(PoseStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
      Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. The provided ResourceLocation object will be bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
      Parameters:
      matrixStack - the gui matrix stack
      res - the ResourceLocation object that contains the desired image
      x - x axis offset
      y - y axis offset
      u - bound resource location image x offset
      v - bound resource location image y offset
      width - the desired box width
      height - the desired box height
      textureWidth - the width of the box texture in the resource location image
      textureHeight - the height of the box texture in the resource location image
      topBorder - the size of the box's top border
      bottomBorder - the size of the box's bottom border
      leftBorder - the size of the box's left border
      rightBorder - the size of the box's right border
      zLevel - the zLevel to draw at
    • drawContinuousTexturedBox

      public static void drawContinuousTexturedBox(PoseStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
      Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. It is assumed that the desired texture ResourceLocation object has been bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
      Parameters:
      matrixStack - the gui matrix stack
      x - x axis offset
      y - y axis offset
      u - bound resource location image x offset
      v - bound resource location image y offset
      width - the desired box width
      height - the desired box height
      textureWidth - the width of the box texture in the resource location image
      textureHeight - the height of the box texture in the resource location image
      topBorder - the size of the box's top border
      bottomBorder - the size of the box's bottom border
      leftBorder - the size of the box's left border
      rightBorder - the size of the box's right border
      zLevel - the zLevel to draw at
    • drawTexturedModalRect

      public static void drawTexturedModalRect(PoseStack matrixStack, int x, int y, int u, int v, int width, int height, float zLevel)
    • preItemToolTip

      @Deprecated(since="1.18", forRemoval=true) public static void preItemToolTip(@Nonnull ItemStack stack)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Must be called from GuiScreen.renderToolTip before GuiScreen.drawHoveringText is called.
      Parameters:
      stack - The stack for which a tooltip is about to be drawn.
    • postItemToolTip

      @Deprecated(since="1.18", forRemoval=true) public static void postItemToolTip()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Must be called from GuiScreen.renderToolTip after GuiScreen.drawHoveringText is called.
    • drawHoveringText

      @Deprecated(since="1.18", forRemoval=true) public static void drawHoveringText(PoseStack mStack, List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • drawHoveringText

      @Deprecated(since="1.18", forRemoval=true) public static void drawHoveringText(PoseStack mStack, List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Draws a tooltip box on the screen with text in it. Automatically positions the box relative to the mouse to match Mojang's implementation. Automatically wraps text when there is not enough space on the screen to display the text without wrapping. Can have a maximum width set to avoid creating very wide tooltips.
      Parameters:
      textLines - the lines of text to be drawn in a hovering tooltip box.
      mouseX - the mouse X position
      mouseY - the mouse Y position
      screenWidth - the available screen width for the tooltip to drawn in
      screenHeight - the available screen height for the tooltip to drawn in
      maxTextWidth - the maximum width of the text in the tooltip box. Set to a negative number to have no max width.
      backgroundColor - The background color of the box
      borderColorStart - The starting color of the box border
      borderColorEnd - The ending color of the box border. The border color will be smoothly interpolated between the start and end values.
      font - the font for drawing the text in the tooltip box
    • drawHoveringText

      @Deprecated(since="1.18", forRemoval=true) public static void drawHoveringText(@Nonnull ItemStack stack, PoseStack mStack, List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • drawHoveringText

      @Deprecated(since="1.18", forRemoval=true) public static void drawHoveringText(@Nonnull ItemStack stack, PoseStack pStack, List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use this version if calling from somewhere where ItemStack context is available.
      See Also:
      drawHoveringText(PoseStack, List, int, int, int, int, int, int, int, int, Font)
    • drawGradientRect

      public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
    • drawInscribedRect

      public static void drawInscribedRect(PoseStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
    • drawInscribedRect

      public static void drawInscribedRect(PoseStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)