Class TextDrawer

java.lang.Object
dev.boze.api.render.TextDrawer

public class TextDrawer extends Object
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(GuiGraphicsExtractor) calls
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    bloomStart(int bloomPasses, float bloomOpacity)
    Opens a bloom region.
    static void
    bloomStart(int bloomPasses, float bloomOpacity, BloomMode original)
    Opens a bloom region with a specific BloomMode for how the original text is shown.
    static void
    Closes the bloom region opened by bloomStart(int, float), blurring and compositing all captured text in one pass.
    static void
    Renders the current text session to the default draw context
    Throws RuntimeException if start() was not called first
    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
    static double
    Gets the height of text without shadow
    Can be called anytime, does not require start()
    static double
    getHeight(boolean shadow)
    Gets the height of text with shadow option
    Can be called anytime, does not require start()
    static double
    Gets the width of text without shadow
    Can be called anytime, does not require start()
    static double
    getWidth(String text, boolean shadow)
    Gets the width of text with shadow option
    Can be called anytime, does not require start()
    static double
    render(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 first
    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
    static double
    render(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 first
    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
    static void
    start(TextType type, double scale)
    Starts a new text rendering session
    Must be called before any text operations.
    static void
    start(TextType type, double scale, boolean measureMode)
    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.

    Methods inherited from class Object

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

    • TextDrawer

      public TextDrawer()
  • Method Details

    • start

      public static void start(TextType type, double scale)
      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

      public static void start(TextType type, double scale, boolean measureMode)
      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 scale
      measureMode - 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 and bloomStop() - across any number of independent start(TextType, double)/draw(GuiGraphicsExtractor) sessions - is captured and gets the bloom applied in a single batched pass at bloomStop(). 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

      public static void bloomStart(int bloomPasses, float bloomOpacity, BloomMode original)
      Opens a bloom region with a specific BloomMode for how the original text is shown. See bloomStart(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 by bloomStart(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 render
      x - X coordinate
      y - Y coordinate
      color - The color to use
      opacity - The opacity value
      shadow - Whether to render with shadow
      Returns:
      The width of the rendered text
    • render

      public static double render(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 first
      Parameters:
      text - The text to render
      x - X coordinate
      y - Y coordinate
      color - The color to use
      opacity - 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 render
      x - X coordinate
      y - Y coordinate
      colorOption - The color option value containing color settings
      shadow - Whether to render with shadow
      Returns:
      The width of the rendered text
    • render

      public static double render(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 first
      Parameters:
      text - The text to render
      x - X coordinate
      y - Y coordinate
      colorOption - The color option value containing color settings
      Returns:
      The width of the rendered text
    • getWidth

      public static double getWidth(String text, boolean shadow)
      Gets the width of text with shadow option
      Can be called anytime, does not require start()
      Parameters:
      text - The text to measure
      shadow - Whether shadow is enabled
      Returns:
      The width of the text
    • getWidth

      public static double getWidth(String text)
      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