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(DrawContext) calls
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Renders the current text session to the default draw context
    static void
    draw(net.minecraft.client.gui.DrawContext context)
    Renders the current text session to the specified draw context
    static double
    Gets the height of text without shadow
    static double
    getHeight(boolean shadow)
    Gets the height of text with shadow option
    static double
    Gets the width of text without shadow
    static double
    getWidth(String text, boolean shadow)
    Gets the width of text with shadow option
    static double
    render(String text, double x, double y, ColorOption.Value colorOption)
    Renders text at the specified position using ColorOption.Value without shadow
    static double
    render(String text, double x, double y, ColorOption.Value colorOption, boolean shadow)
    Renders text at the specified position using ColorOption.Value
    static double
    render(String text, double x, double y, ClientColor color, float opacity)
    Renders text at the specified position without shadow
    static double
    render(String text, double x, double y, ClientColor color, float opacity, boolean shadow)
    Renders text at the specified position
    static void
    start(TextType type, double scale)
    Starts a new text rendering session
    static void
    start(TextType type, double scale, boolean measureMode)
    Starts a new text rendering session with measure mode option

    Methods inherited from class java.lang.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
    • 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 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