Class TextComponent


public final class TextComponent extends GuiComponent<TextComponent>
Component-rendering component with optional background and text effects.
  • Constructor Details

    • TextComponent

      public TextComponent()
  • Method Details

    • text

      public TextComponent text(String text)
      Sets literal text content.
      Parameters:
      text - literal text to render
      Returns:
      this component
    • text

      public net.minecraft.network.chat.Component text()
      Returns the current component text.
      Returns:
      current text
    • text

      public TextComponent text(net.minecraft.network.chat.Component text)
      Sets rich text content.
      Parameters:
      text - component to render
      Returns:
      this component
    • text

      public TextComponent text(GuiRichText text)
      Sets typed per-span browser-grade text.
    • textStyle

      public TextComponent textStyle(GuiTextStyle style)
      Sets the immutable browser-grade base style. Component spans are adapted over this style when no explicit GuiRichText is present.
    • font

      public TextComponent font(GuiFont font)
      Sets the font used to render the text.
      Parameters:
      font - font configuration
      Returns:
      this component
    • textAlignment

      public TextComponent textAlignment(GuiTextAlignment alignment)
      Sets horizontal text alignment within this component's content bounds.
      Parameters:
      alignment - horizontal text alignment
      Returns:
      this component
    • centerText

      public TextComponent centerText()
    • rightAlignText

      public TextComponent rightAlignText()
    • verticalTextAlignment

      public TextComponent verticalTextAlignment(GuiTextVerticalAlignment alignment)
    • centerTextVertically

      public TextComponent centerTextVertically()
    • centered

      public TextComponent centered()
      Overrides:
      centered in class GuiComponent<TextComponent>
    • textScalePixels

      public TextComponent textScalePixels(float pixels)
      Sets the text size in design-space pixels.
      Parameters:
      pixels - text size
      Returns:
      this component
    • letterSpacing

      public TextComponent letterSpacing(float pixels)
    • lineHeight

      public TextComponent lineHeight(float multiplier)
    • highlights

      public GuiHighlightRegistry highlights()
      Returns the retained named-highlight registry for this text.
      Returns:
      highlight registry
    • highlight

      public TextComponent highlight(String name, int startUtf16, int endUtf16)
      Adds one named UTF-16 highlight range.
      Parameters:
      name - highlight name matched by HIGHLIGHT(name)
      startUtf16 - inclusive start
      endUtf16 - exclusive end
      Returns:
      this component
    • textPaint

      public TextComponent textPaint(GuiTextPaint paint)
    • shadow

      public TextComponent shadow(boolean shadow)
      Enables or disables the standard text shadow.
      Parameters:
      shadow - true to render the vanilla-style text shadow
      Returns:
      this component
    • shadow

      public TextComponent shadow(GuiShadow shadow)
      Sets a custom shadow effect for the text glyphs.
      Overrides:
      shadow in class GuiComponent<TextComponent>
      Parameters:
      shadow - text shadow configuration, or null to clear it
      Returns:
      this component
    • textShadow

      public TextComponent textShadow(GuiShadow shadow)
      Sets a custom shadow effect for the text glyphs.
      Parameters:
      shadow - text shadow configuration, or null to clear it
      Returns:
      this component
    • glow

      public TextComponent glow(GuiGlow glow)
      Sets a glow effect for the text glyphs.
      Overrides:
      glow in class GuiComponent<TextComponent>
      Parameters:
      glow - text glow configuration, or null to clear it
      Returns:
      this component
    • textGlow

      public TextComponent textGlow(GuiGlow glow)
      Sets a glow effect for the text glyphs.
      Parameters:
      glow - text glow configuration, or null to clear it
      Returns:
      this component
    • preferredWidth

      protected float preferredWidth(com.render.api.gui.GuiRenderContext context)
      Overrides:
      preferredWidth in class GuiComponent<TextComponent>
    • preferredHeight

      protected float preferredHeight(com.render.api.gui.GuiRenderContext context)
      Overrides:
      preferredHeight in class GuiComponent<TextComponent>
    • preferredHeightForWidth

      protected float preferredHeightForWidth(com.render.api.gui.GuiRenderContext context, float resolvedWidth)
      Overrides:
      preferredHeightForWidth in class GuiComponent<TextComponent>
    • renderSelf

      protected void renderSelf(com.render.api.gui.GuiRenderContext context)
      Overrides:
      renderSelf in class GuiComponent<TextComponent>