Package dev.boze.api.render
Class TextDrawer
java.lang.Object
dev.boze.api.render.TextDrawer
Text rendering API for drawing text in different contexts
Provides methods for rendering text in GUI, HUD, and world contexts
All rendering operations must be wrapped between
start(TextType, double) and draw(DrawContext) calls-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddraw()Renders the current text session to the default draw contextstatic voiddraw(net.minecraft.client.gui.DrawContext context) Renders the current text session to the specified draw contextstatic doubleGets the height of text without shadowstatic doublegetHeight(boolean shadow) Gets the height of text with shadow optionstatic doubleGets the width of text without shadowstatic doubleGets the width of text with shadow optionstatic doublerender(String text, double x, double y, ColorOption.Value colorOption) Renders text at the specified position using ColorOption.Value without shadowstatic doublerender(String text, double x, double y, ColorOption.Value colorOption, boolean shadow) Renders text at the specified position using ColorOption.Valuestatic doublerender(String text, double x, double y, ClientColor color, float opacity) Renders text at the specified position without shadowstatic doublerender(String text, double x, double y, ClientColor color, float opacity, boolean shadow) Renders text at the specified positionstatic voidStarts a new text rendering sessionstatic voidStarts a new text rendering session with measure mode option
-
Constructor Details
-
TextDrawer
public TextDrawer()
-
-
Method Details
-
start
Starts a new text rendering session Must be called before any text operations. Throws RuntimeException if already started- Parameters:
type- The text type (GUI/HUD/WORLD)scale- The text scale
-
start
Starts a new text rendering session with measure mode option Measure mode disables buffer building for width/height calculations only Must be called before any text operations. Throws RuntimeException if already started- Parameters:
type- The text type (GUI/HUD/WORLD)scale- The text scalemeasureMode- Whether to enable measure-only mode
-
draw
public static void draw(net.minecraft.client.gui.DrawContext context) Renders the current text session to the specified draw context Throws RuntimeException if start() was not called first- Parameters:
context- The draw context to render to
-
draw
public static void draw()Renders the current text session to the default draw context Throws RuntimeException if start() was not called first -
render
public static double render(String text, double x, double y, ClientColor color, float opacity, boolean shadow) Renders text at the specified position Throws RuntimeException if start() was not called first- Parameters:
text- The text to renderx- X coordinatey- Y coordinatecolor- The color to useopacity- The opacity valueshadow- Whether to render with shadow- Returns:
- The width of the rendered text
-
render
Renders text at the specified position without shadow Throws RuntimeException if start() was not called first- Parameters:
text- The text to renderx- X coordinatey- Y coordinatecolor- The color to useopacity- The opacity value- Returns:
- The width of the rendered text
-
render
public static double render(String text, double x, double y, ColorOption.Value colorOption, boolean shadow) Renders text at the specified position using ColorOption.Value Throws RuntimeException if start() was not called first- Parameters:
text- The text to renderx- X coordinatey- Y coordinatecolorOption- The color option value containing color settingsshadow- Whether to render with shadow- Returns:
- The width of the rendered text
-
render
Renders text at the specified position using ColorOption.Value without shadow Throws RuntimeException if start() was not called first- Parameters:
text- The text to renderx- X coordinatey- Y coordinatecolorOption- The color option value containing color settings- Returns:
- The width of the rendered text
-
getWidth
Gets the width of text with shadow option Can be called anytime, does not require start()- Parameters:
text- The text to measureshadow- Whether shadow is enabled- Returns:
- The width of the text
-
getWidth
Gets the width of text without shadow Can be called anytime, does not require start()- Parameters:
text- The text to measure- Returns:
- The width of the text
-
getHeight
public static double getHeight(boolean shadow) Gets the height of text with shadow option Can be called anytime, does not require start()- Parameters:
shadow- Whether shadow is enabled- Returns:
- The height of the text
-
getHeight
public static double getHeight()Gets the height of text without shadow Can be called anytime, does not require start()- Returns:
- The height of the text
-