Class TDrawContext
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
Modifier and TypeFieldDescriptionprotected final net.minecraft.client.MinecraftClient
protected final ColorStack
protected @Nullable TParentElement
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
ModifierConstructorDescriptionprotected
TDrawContext
(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float deltaTime) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
final void
final void
drawTBorder
(int color) Draws an inner outline around thecurrentTarget
.final void
drawTButton
(boolean enabled, boolean focused) Draws a GUI button on top of thecurrentTarget
.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 displayText
for thecurrentTarget
.final void
drawTElementTextTHC
(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int color) Draws a displayText
for thecurrentTarget
.final void
drawTElementTextTHSC
(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int sideOffset, int color) Draws a displayText
for thecurrentTarget
.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 aDrawContext.fill(int, int, int, int, int)
over thecurrentTarget
.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 thecurrentTarget
.
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 thecurrentTarget
.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.static TDrawContext
of
(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float deltaTime) Creates a newTDrawContext
instance and returns it.final void
final void
final void
pushTShaderColor
(float red, float green, float blue, float alpha) Pushes a color to the shadercolorStack
.final void
pushTShaderColor
(float red, float green, float blue, float alpha, ColorStack.BlendMethod blendMethod) Same aspushTShaderColor(float, float, float, float)
, but you also get to choose theColorStack.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 thecolorStack
.final void
updateContext
(TParentElement target) Updates the current drawing context info and thecurrentTarget
.
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, drawTextWithShadow, drawTextWithShadow, drawTextWithShadow, drawTextWrapped, drawTooltip, drawTooltip, drawTooltip, drawTooltip, drawVerticalLine, drawVerticalLine, enableScissor, fill, fill, fill, fillGradient, fillGradient, fillGradient, fillWithLayer, getMatrices, getScaledWindowHeight, getScaledWindowWidth, getVertexConsumers, scissorContains
-
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
-
textScaleStack
-
client
protected final net.minecraft.client.MinecraftClient client -
currentTarget
Represents theTParentElement
that is currently being rendered by aTScreen
.
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 newTDrawContext
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
Updates the current drawing context info and thecurrentTarget
.
Calling this indicates that you plan on rendering another GUI element.- Parameters:
target
- TheTParentElement
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 classnet.minecraft.client.gui.DrawContext
-
pushTShaderColor
public final void pushTShaderColor(float red, float green, float blue, float alpha) Pushes a color to the shadercolorStack
.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 aspushTShaderColor(float, float, float, float)
, but you also get to choose theColorStack.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 thecolorStack
.It is recommended to use
pushTShaderColor(float, float, float, float)
instead.
When pushing tocolorStack
, don't forget topopTShaderColor()
.If you end up using this, and you want to re-apply the
colorStack
, useapplyTShaderColor()
.- Overrides:
setShaderColor
in classnet.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 displayText
for thecurrentTarget
.- Parameters:
text
- TheText
to draw.horizontalAlgnment
- TheHorizontalAlignment
in which to draw theText
.
-
drawTElementTextTHC
public final void drawTElementTextTHC(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int color) Draws a displayText
for thecurrentTarget
.- Parameters:
text
- TheText
to draw.horizontalAlgnment
- TheHorizontalAlignment
in which to draw theText
.color
- TheText
color.
-
drawTElementTextTHSC
public final void drawTElementTextTHSC(net.minecraft.text.Text text, HorizontalAlignment horizontalAlgnment, int sideOffset, int color) Draws a displayText
for thecurrentTarget
.- Parameters:
text
- TheText
to draw.horizontalAlgnment
- TheHorizontalAlignment
in which to draw theText
.sideOffset
- If drawing left or right, the offset in pixels towards the center that will be applied.color
- TheText
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 thecurrentTarget
.- Parameters:
color
- The border color.
-
drawTFill
public final void drawTFill(int color) Draws aDrawContext.fill(int, int, int, int, int)
over thecurrentTarget
.- 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 thecurrentTarget
.
Uses 256x256 as the texture image width and height.- Parameters:
textureId
- The textureIdentifier
.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 thecurrentTarget
.- Parameters:
textureId
- The textureIdentifier
.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 textureIdentifier
.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 thecurrentTarget
. -
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)
-