DrawHelper
Talks about DrawHelper class
DrawHelper
This class extends the DrawContext
class and provides methods for drawing various shapes and text on the screen.
Constructors
DrawHelper(MinecraftClient client, VertexConsumerProvider.Immediate vertexConsumers)
DrawHelper(MinecraftClient client, VertexConsumerProvider.Immediate vertexConsumers)
Creates a new instance of the DrawHelper
class.
client
The Minecraft client instance
vertexConsumers
The vertex consumer provider
Methods
drawBox(DrawContext drawContext, int x, int y, int width, int height, int color)
drawBox(DrawContext drawContext, int x, int y, int width, int height, int color)
Fills a box on the screen with a specified color.
drawContext
The drawContext used for rendering
x
The x position of the rectangle
y
The y position of the rectangle
width
The width of the rectangle
height
The height of the rectangle
color
The color to fill the rectangle with
fill(DrawContext drawContext, int x1, int y1, int x2, int y2, int color)
fill(DrawContext drawContext, int x1, int y1, int x2, int y2, int color)
Fills a rectangle on the screen with a specified color.
drawContext
The drawContext used for rendering
x1
The x position of the top left corner of the rectangle
y1
The y position of the top left corner of the rectangle
x2
The x position of the bottom right corner of the rectangle
y2
The y position of the bottom right corner of the rectangle
color
The color to fill the rectangle with
drawText(DrawContext drawContext, TextRenderer textRenderer, String text, int x, int y, int color, boolean shadow)
drawText(DrawContext drawContext, TextRenderer textRenderer, String text, int x, int y, int color, boolean shadow)
Draws text on screen.
drawContext
The drawContext used for rendering
textRenderer
The TextRenderer instance used for rendering.
text
The text to be drawn.
x
The x position to draw at.
y
The y position to draw at.
color
The color to draw with.
fillRoundedRect(Matrix4f matrix4f, int x1, int y1, int x2, int y2, int cornerRadius, int color)
fillRoundedRect(Matrix4f matrix4f, int x1, int y1, int x2, int y2, int cornerRadius, int color)
Fills a rounded rectangle on screen with specified color.
Note: This method causes a lot of problems and for some reason does not work for ArmorWidget when used for contextMenu.
matrix4f
Matrix4f used for rendering.
x1
X position of top left corner of rectangle.
y1
Y position of top left corner of rectangle.
x2
X position of bottom right corner of rectangle.
y2
Y position of bottom right corner of rectangle.
cornerRadius
Radius of rounded corners.
fillRoundedRect(DrawContext drawContext, int left, int top, int right, int bottom, int color)
fillRoundedRect(DrawContext drawContext, int left, int top, int right, int bottom, int color)
Fills a rounded rectangle on screen with specified color.
drawContext
The drawContext used for rendering
left
The x position of the top left corner of the rectangle
top
The y position of the top left corner of the rectangle
right
The x position of the bottom right corner of the rectangle
bottom
The y position of the bottom right corner of the rectangle
color
The color to fill the rectangle with
fillGradient(Matrix4f matrix4f, int x1, int y1, int x2, int y2, int topColor, int bottomColor)
fillGradient(Matrix4f matrix4f, int x1, int y1, int x2, int y2, int topColor, int bottomColor)
Fills a gradient on screen with specified colors.
matrix4f
Matrix4f used for rendering.
x1
The x position of the top left corner of the gradient
y1
The y position of the top left corner of the gradient
x2
The x position of the bottom right corner of the gradient
y2
The y position of the bottom right corner of the gradient
topColor
The color at the top of the gradient
bottomColor
The color at the bottom of the gradient
drawOutlinedBox(DrawContext drawContext, int x1, int y1, int x2, int y2, int color)
drawOutlinedBox(DrawContext drawContext, int x1, int y1, int x2, int y2, int color)
Draws an outlined box on screen.
drawContext
The drawContext used for rendering
x1
The x position of the top left corner of the box
y1
The y position of the top left corner of the box
x2
The x position of the bottom right corner of the box
y2
The y position of the bottom right corner of the box
color
The color to draw the box with