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
Provides methods for rendering text in GUI, HUD, and world contexts
All rendering operations must be wrapped between
start(TextType, double) and draw(GuiGraphicsExtractor) calls-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbloomStart(int bloomPasses, float bloomOpacity) Opens a bloom region.static voidbloomStart(int bloomPasses, float bloomOpacity, BloomMode original) Opens a bloom region with a specificBloomModefor how the original text is shown.static voidCloses the bloom region opened bybloomStart(int, float), blurring and compositing all captured text in one pass.static voiddraw()Renders the current text session to the default draw context
Throws RuntimeException if start() was not called firststatic voiddraw(net.minecraft.client.gui.GuiGraphicsExtractor context) Renders the current text session to the specified draw context
Throws RuntimeException if start() was not called firststatic doubleGets the height of text without shadow
Can be called anytime, does not require start()static doublegetHeight(boolean shadow) Gets the height of text with shadow option
Can be called anytime, does not require start()static doubleGets the width of text without shadow
Can be called anytime, does not require start()static doubleGets the width of text with shadow option
Can be called anytime, does not require start()static doublerender(String text, double x, double y, ColorOption.Value colorOption) Renders text at the specified position using ColorOption.Value without shadow
Throws RuntimeException if start() was not called firststatic doublerender(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 firststatic doublerender(String text, double x, double y, ClientColor color, float opacity) Renders text at the specified position without shadow
Throws RuntimeException if start() was not called firststatic doublerender(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 firststatic voidStarts a new text rendering session
Must be called before any text operations.static voidStarts 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.
-
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
-
bloomStart
public static void bloomStart(int bloomPasses, float bloomOpacity) Opens a bloom region. Every piece of text rendered between this call andbloomStop()- across any number of independentstart(TextType, double)/draw(GuiGraphicsExtractor)sessions - is captured and gets the bloom applied in a single batched pass atbloomStop(). This is independent of the text sessions and of the Hud module's bloom setting.- Parameters:
bloomPasses- Blur passes for the bloom (higher = softer/larger, ~1-6; 0 disables)bloomOpacity- Bloom intensity/opacity (e.g. 0-2, 1.0 = normal)
-
bloomStart
Opens a bloom region with a specificBloomModefor how the original text is shown. SeebloomStart(int, float).- Parameters:
bloomPasses- Blur passes for the bloom (higher = softer/larger, ~1-6; 0 disables)bloomOpacity- Bloom intensity/opacity (e.g. 0-2, 1.0 = normal)original- How to show the original text under the bloom (Off/Keep/Add)
-
bloomStop
public static void bloomStop()Closes the bloom region opened bybloomStart(int, float), blurring and compositing all captured text in one pass. -
draw
public static void draw(net.minecraft.client.gui.GuiGraphicsExtractor 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
-