java.lang.Object
net.minecraft.client.gui.DrawContext
io.github.thecsdev.tcdcommons.api.client.gui.util.TDrawContext

public final class TDrawContext extends net.minecraft.client.gui.DrawContext
TCDCommons's implementation of DrawContext.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final net.minecraft.client.MinecraftClient
     
    protected final ColorStack
     
    protected @Nullable TParentElement
    Represents the TParentElement that is currently being rendered by a TScreen.
    Can be null.
    static final int
     
    static final int
     
    static final int
     
    final float
     
    final int
     
    final int
     
    protected float
     
    protected final TextScaleStack
     
    static final net.minecraft.util.Identifier
     
    static final net.minecraft.util.Identifier
     

    Fields inherited from class net.minecraft.client.gui.DrawContext

    field_44931, field_44932
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    TDrawContext(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float deltaTime)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
     
    final void
     
    final void
    drawTBorder(int color)
    Draws an inner outline around the currentTarget.
    final void
    drawTButton(boolean enabled, boolean focused)
    Draws a GUI button on top of the currentTarget.
    final void
    drawTCheckbox(int x, int y, boolean highlighted, boolean checked)
     
    final void
    drawTCheckbox(int x, int y, int width, int height, boolean highlighted, boolean checked)
     
    final void
    drawTElementTextTH(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment)
    Draws a display Text for the currentTarget.
    final void
    drawTElementTextTHC(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int color)
    Draws a display Text for the currentTarget.
    final void
    drawTElementTextTHSC(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int sideOffset, int color)
    Draws a display Text for the currentTarget.
    final void
    drawTElementTextTHSCS(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int sideOffset, int color, float textScale)
     
    final void
    drawTElementTextTHSS(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int sideOffset, float textScale)
     
    final void
    drawTEntity(net.minecraft.entity.Entity entity, int size, boolean followCursor)
     
    final void
    drawTEntity(net.minecraft.entity.Entity entity, int x, int y, int width, int height, int size, boolean followCursor)
     
    final void
    drawTFill(int color)
    Draws a DrawContext.fill(int, int, int, int, int) over the currentTarget.
    final void
    drawTNineSlicedTexture(net.minecraft.util.Identifier textureId, int u, int v, int regionWidth, int regionHeight, int slicedBorderSize)
    Draws a nine-sliced texture on top of the currentTarget.
    Uses 256x256 as the texture image width and height.
    final void
    drawTNineSlicedTexture(net.minecraft.util.Identifier textureId, int u, int v, int uvW, int uvH, int tW, int tH, int s)
    Draws a nine-sliced texture on top of the currentTarget.
    final void
    drawTNineSlicedTexture(net.minecraft.util.Identifier textureId, int x, int y, int w, int h, int u, int v, int uvW, int uvH, int tW, int tH, int s)
    Draws a nine-sliced texture.
    final void
    drawTRepeatingTexture(net.minecraft.util.Identifier textureId, int x, int y, int width, int height, int u, int v, int uvRegionWidth, int uvRegionHeight, int textureWidth, int textureHeight)
    Draws a repeating texture.
    final void
    fill(net.minecraft.client.render.RenderLayer layer, int x1, int x2, int y1, int y2, int z, int color)
    Fills a given area on the screen with a given color.
    of(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float deltaTime)
    Creates a new TDrawContext instance and returns it.
    final void
     
    final void
     
    final void
    pushTShaderColor(float red, float green, float blue, float alpha)
    Pushes a color to the shader colorStack.
    final void
    pushTShaderColor(float red, float green, float blue, float alpha, ColorStack.BlendMethod blendMethod)
    final void
    pushTTextScale(float scale)
     
    final void
    setShaderColor(float red, float green, float blue, float alpha)
    Sets the shader color to a color of choice, bypassing the colorStack.
    final void
    Updates the current drawing context info and the currentTarget.
    Calling this indicates that you plan on rendering another GUI element.

    Methods inherited from class net.minecraft.client.gui.DrawContext

    disableScissor, draw, draw, drawBorder, drawCenteredTextWithShadow, drawCenteredTextWithShadow, drawCenteredTextWithShadow, drawGuiTexture, drawGuiTexture, drawGuiTexture, drawGuiTexture, drawHorizontalLine, drawHorizontalLine, drawHoverEvent, drawItem, drawItem, drawItem, drawItem, drawItemInSlot, drawItemInSlot, drawItemTooltip, drawItemWithoutEntity, drawItemWithoutEntity, drawOrderedTooltip, drawSprite, drawSprite, drawText, drawText, drawText, drawTexture, drawTexture, drawTexture, drawTexture, drawTextWithBackground, drawTextWithShadow, drawTextWithShadow, drawTextWithShadow, drawTextWrapped, drawTooltip, drawTooltip, drawTooltip, drawTooltip, drawVerticalLine, drawVerticalLine, enableScissor, fill, fill, fill, fillGradient, fillGradient, fillGradient, fillWithLayer, getMatrices, getScaledWindowHeight, getScaledWindowWidth, getVertexConsumers, scissorContains

    Methods inherited from class java.lang.Object

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

    • DEFAULT_TEXT_SIDE_OFFSET

      @Beta public static final int DEFAULT_TEXT_SIDE_OFFSET
      See Also:
    • DEFAULT_TEXT_COLOR

      @Beta public static final int DEFAULT_TEXT_COLOR
      See Also:
    • DEFAULT_ERROR_COLOR

      @Beta public static final int DEFAULT_ERROR_COLOR
    • TEXTURE_FILL

      @Beta public static final net.minecraft.util.Identifier TEXTURE_FILL
    • TEXTURE_ICONS

      @Beta public static final net.minecraft.util.Identifier TEXTURE_ICONS
    • colorStack

      protected final ColorStack colorStack
    • textScaleStack

      protected final TextScaleStack textScaleStack
    • client

      protected final net.minecraft.client.MinecraftClient client
    • currentTarget

      @Nullable protected @Nullable TParentElement currentTarget
      Represents the TParentElement that is currently being rendered by a TScreen.
      Can be null. Read only, do not modify.
    • mouseX

      public final int mouseX
    • mouseY

      public final int mouseY
    • deltaTime

      public final float deltaTime
    • textScale

      protected float textScale
  • Constructor Details

    • TDrawContext

      protected TDrawContext(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float deltaTime)
  • Method Details

    • of

      public static TDrawContext of(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float deltaTime)
      Creates a new TDrawContext instance and returns it.
      Parameters:
      drawContext - The "parent" draw context.
      mouseX - The current mouse cursor X position.
      mouseY - The current mouse cursor Y position.
      deltaTime - Time elapsed between the current frame and the last frame.
    • updateContext

      public final void updateContext(TParentElement target)
      Updates the current drawing context info and the currentTarget.
      Calling this indicates that you plan on rendering another GUI element.
      Parameters:
      target - The TParentElement that is about to be rendered next.
    • fill

      public final void fill(net.minecraft.client.render.RenderLayer layer, int x1, int x2, int y1, int y2, int z, int color)
      Fills a given area on the screen with a given color.

      Overridden to add support for the colorStack.

      Overrides:
      fill in class net.minecraft.client.gui.DrawContext
    • pushTShaderColor

      public final void pushTShaderColor(float red, float green, float blue, float alpha)
      Pushes a color to the shader colorStack.

      After you're done, don't forget to popTShaderColor()

      Parameters:
      red - The R color channel (0 to 1).
      green - The G color channel (0 to 1).
      blue - The B color channel (0 to 1).
      alpha - The A color channel (0 to 1).
      See Also:
    • pushTShaderColor

      public final void pushTShaderColor(float red, float green, float blue, float alpha, ColorStack.BlendMethod blendMethod)
      Same as pushTShaderColor(float, float, float, float), but you also get to choose the ColorStack.BlendMethod.

      After you're done, don't forget to popTShaderColor()

      Parameters:
      red - The R color channel (0 to 1).
      green - The G color channel (0 to 1).
      blue - The B color channel (0 to 1).
      alpha - The A color channel (0 to 1).
      See Also:
    • popTShaderColor

      public final void popTShaderColor()
    • applyTShaderColor

      public final void applyTShaderColor()
    • setShaderColor

      public final void setShaderColor(float red, float green, float blue, float alpha)
      Sets the shader color to a color of choice, bypassing the colorStack.

      It is recommended to use pushTShaderColor(float, float, float, float) instead.
      When pushing to colorStack, don't forget to popTShaderColor().

      If you end up using this, and you want to re-apply the colorStack, use applyTShaderColor().

      Overrides:
      setShaderColor in class net.minecraft.client.gui.DrawContext
      Parameters:
      red - The R color channel (0 to 1).
      green - The G color channel (0 to 1).
      blue - The B color channel (0 to 1).
      alpha - The A color channel (0 to 1).
      See Also:
    • pushTTextScale

      public final void pushTTextScale(float scale)
    • popTTextScale

      public final void popTTextScale()
    • applyTTextScale

      public final void applyTTextScale()
    • drawTElementTextTH

      public final void drawTElementTextTH(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment)
      Draws a display Text for the currentTarget.
      Parameters:
      text - The Text to draw.
      horizontalAlgnment - The HorizontalAlignment in which to draw the Text.
    • drawTElementTextTHC

      public final void drawTElementTextTHC(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int color)
      Draws a display Text for the currentTarget.
      Parameters:
      text - The Text to draw.
      horizontalAlgnment - The HorizontalAlignment in which to draw the Text.
      color - The Text color.
    • drawTElementTextTHSC

      public final void drawTElementTextTHSC(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int sideOffset, int color)
      Draws a display Text for the currentTarget.
      Parameters:
      text - The Text to draw.
      horizontalAlgnment - The HorizontalAlignment in which to draw the Text.
      sideOffset - If drawing left or right, the offset in pixels towards the center that will be applied.
      color - The Text color.
    • drawTElementTextTHSS

      public final void drawTElementTextTHSS(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int sideOffset, float textScale)
    • drawTElementTextTHSCS

      public final void drawTElementTextTHSCS(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int sideOffset, int color, float textScale)
    • drawTBorder

      public final void drawTBorder(int color)
      Draws an inner outline around the currentTarget.
      Parameters:
      color - The border color.
    • drawTFill

      public final void drawTFill(int color)
      Draws a DrawContext.fill(int, int, int, int, int) over the currentTarget.
      Parameters:
      color - The fill color.
    • drawTNineSlicedTexture

      public final void drawTNineSlicedTexture(net.minecraft.util.Identifier textureId, int u, int v, int regionWidth, int regionHeight, int slicedBorderSize)
      Draws a nine-sliced texture on top of the currentTarget.
      Uses 256x256 as the texture image width and height.
      Parameters:
      textureId - The texture Identifier.
      u - The horizontal position of the texture's UV coordinate, measured in pixels.
      v - The vertical position of the texture's UV coordinate, measured in pixels.
      regionWidth - The width of the texture's UV region, measured in pixels.
      regionHeight - The height of the texture's UV region, measured in pixels.
      slicedBorderSize - The size of the sliced pieces around the center piece.
    • drawTNineSlicedTexture

      public final void drawTNineSlicedTexture(net.minecraft.util.Identifier textureId, int u, int v, int uvW, int uvH, int tW, int tH, int s)
      Draws a nine-sliced texture on top of the currentTarget.
      Parameters:
      textureId - The texture Identifier.
      u - The horizontal position of the texture's UV coordinate, measured in pixels.
      v - The vertical position of the texture's UV coordinate, measured in pixels.
      uvW - The width of the texture's UV region, measured in pixels.
      uvH - The height of the texture's UV region, measured in pixels.
      tW - The width of the texture image, measured in pixels.
      tH - The height of the texture image, measured in pixels.
      s - The size of the sliced pieces around the center piece.
    • drawTNineSlicedTexture

      public final void drawTNineSlicedTexture(net.minecraft.util.Identifier textureId, int x, int y, int w, int h, int u, int v, int uvW, int uvH, int tW, int tH, int s)
      Draws a nine-sliced texture.
      Parameters:
      textureId - The texture Identifier.
      x - The starting X position on the screen.
      y - The starting Y position on the screen.
      w - The width size of the sliced texture on the screen.
      h - The height size of the sliced texture on the screen.
      u - The horizontal position of the texture's UV coordinate, measured in pixels.
      v - The vertical position of the texture's UV coordinate, measured in pixels.
      uvW - The width of the texture's UV region, measured in pixels.
      uvH - The height of the texture's UV region, measured in pixels.
      tW - The width of the texture image, measured in pixels.
      tH - The height of the texture image, measured in pixels.
      s - The size of the sliced pieces around the center piece.
    • drawTRepeatingTexture

      public final void drawTRepeatingTexture(net.minecraft.util.Identifier textureId, int x, int y, int width, int height, int u, int v, int uvRegionWidth, int uvRegionHeight, int textureWidth, int textureHeight)
      Draws a repeating texture.
      Parameters:
      x - The starting X position on the screen.
      y - The starting Y position on the screen.
      width - The width size of the repeating texture on the screen.
      height - The height size of the repeating texture on the screen.
      u - The horizontal position of the texture's UV coordinate, measured in pixels.
      v - The vertical position of the texture's UV coordinate, measured in pixels.
      uvRegionWidth - The width of the texture's UV region, measured in pixels.
      uvRegionHeight - The height of the texture's UV region, measured in pixels.
      textureWidth - The width of the texture image, measured in pixels.
      textureHeight - The height of the texture image, measured in pixels.
    • drawTButton

      public final void drawTButton(boolean enabled, boolean focused)
      Draws a GUI button on top of the currentTarget.
    • drawTCheckbox

      public final void drawTCheckbox(int x, int y, boolean highlighted, boolean checked)
    • drawTCheckbox

      public final void drawTCheckbox(int x, int y, int width, int height, boolean highlighted, boolean checked)
    • drawTEntity

      @Experimental public final void drawTEntity(net.minecraft.entity.Entity entity, int size, boolean followCursor) throws NullPointerException
      Throws:
      NullPointerException
    • drawTEntity

      @Experimental public final void drawTEntity(net.minecraft.entity.Entity entity, int x, int y, int width, int height, int size, boolean followCursor)