Interface StringRenderable

All Known Subinterfaces:
MutableText, Text
All Known Implementing Classes:
BaseText, KeybindText, LiteralText, NbtText, NbtText.BlockNbtText, NbtText.EntityNbtText, NbtText.StorageNbtText, ScoreText, SelectorText, TextHandler.StyledString, TranslatableText

public interface StringRenderable
An object that can supply strings to a visitor, with or without a style context, for rendering the strings.
  • Field Details

  • Method Details

    • visit

      <T> Optional<T> visit​(StringRenderable.Visitor<T> visitor)
      Supplies this renderable's literal content to the visitor.
      Parameters:
      visitor - the visitor
      Returns:
      Optional.empty() if the visit finished, or a terminating result from the visitor
    • visit

      @Environment(CLIENT) <T> Optional<T> visit​(StringRenderable.StyledVisitor<T> styledVisitor, Style style)
      Supplies this renderable's literal content and contextual style to the visitor.
      Parameters:
      styledVisitor - the visitor
      style - the contextual style
      Returns:
      Optional.empty() if the visit finished, or a terminating result from the visitor
    • plain

      static StringRenderable plain​(String string)
      Creates a renderable from a plain string.
      Parameters:
      string - the plain string
    • styled

      @Environment(CLIENT) static StringRenderable styled​(String string, Style style)
      Creates a visitable from a plain string and a root style.
      Parameters:
      string - the plain string
      style - the root style
    • concat

      @Environment(CLIENT) static StringRenderable concat​(StringRenderable[] visitables)
      Concats multiple string renderables by the order they appear in the array.
      Parameters:
      visitables - an array or varargs of visitables
    • concat

      @Environment(CLIENT) static StringRenderable concat​(List<StringRenderable> visitables)
      Concats multiple string renderables by the order they appear in the list.
      Parameters:
      visitables - a list of visitables
    • getString

      default String getString()