Package net.minecraft.text
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.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceStringRenderable.StyledVisitor<T>A visitor for rendered string content and a contextualStyle.static interfaceStringRenderable.Visitor<T>A visitor for rendered string content. -
Field Summary
Fields Modifier and Type Field Description static StringRenderableEMPTYAn empty renderable that does not call the visitors.static Optional<Unit>TERMINATE_VISITConvenience object indicating the termination of a string visit. -
Method Summary
Modifier and Type Method Description static StringRenderableconcat(List<StringRenderable> visitables)Concats multiple string renderables by the order they appear in the list.static StringRenderableconcat(StringRenderable[] visitables)Concats multiple string renderables by the order they appear in the array.default StringgetString()static StringRenderableplain(String string)Creates a renderable from a plain string.static StringRenderablestyled(String string, Style style)Creates a visitable from a plain string and a root style.<T> Optional<T>visit(StringRenderable.StyledVisitor<T> styledVisitor, Style style)Supplies this renderable's literal content and contextual style to the visitor.<T> Optional<T>visit(StringRenderable.Visitor<T> visitor)Supplies this renderable's literal content to the visitor.
-
Field Details
-
TERMINATE_VISIT
Convenience object indicating the termination of a string visit. -
EMPTY
An empty renderable that does not call the visitors.
-
-
Method Details
-
visit
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 thevisitor
-
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 visitorstyle- the contextual style- Returns:
Optional.empty()if the visit finished, or a terminating result from thevisitor
-
plain
Creates a renderable from a plain string.- Parameters:
string- the plain string
-
styled
Creates a visitable from a plain string and a root style.- Parameters:
string- the plain stringstyle- the root style
-
concat
Concats multiple string renderables by the order they appear in the array.- Parameters:
visitables- an array or varargs of visitables
-
concat
Concats multiple string renderables by the order they appear in the list.- Parameters:
visitables- a list of visitables
-
getString
-