Package net.minecraft.text
Interface Text
- All Superinterfaces:
com.mojang.brigadier.Message
,StringVisitable
- All Known Subinterfaces:
MutableText
- All Known Implementing Classes:
BaseText
,KeybindText
,LiteralText
,NbtText
,NbtText.BlockNbtText
,NbtText.EntityNbtText
,NbtText.StorageNbtText
,ScoreText
,SelectorText
,TranslatableText
public interface Text extends com.mojang.brigadier.Message, StringVisitable
A text. Can be converted to and from JSON format.
Each text has a tree structure, embodying all its siblings
. To iterate contents in the text and all
its siblings, call visit
methods.
This interface does not expose mutation operations. For mutation,
refer to MutableText
.
- See Also:
MutableText
- Mappings:
Namespace Name official oi
intermediary net/minecraft/class_2561
named net/minecraft/text/Text
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Text.Serializer
A JSON serializer forText
.Nested classes/interfaces inherited from interface net.minecraft.text.StringVisitable
StringVisitable.StyledVisitor<T>, StringVisitable.Visitor<T>
-
Field Summary
Fields inherited from interface net.minecraft.text.StringVisitable
EMPTY, TERMINATE_VISIT
-
Method Summary
Modifier and Type Method Description OrderedText
asOrderedText()
String
asString()
Returns the string representation of this text itself, excluding siblings.default String
asTruncatedString(int length)
Returns the full string representation of this text, truncated beyond the suppliedlength
.MutableText
copy()
Copies the text itself, excluding the styles or siblings.List<Text>
getSiblings()
Returns the siblings of this text.default String
getString()
Style
getStyle()
Returns the style of this text.static Text
of(String string)
Creates a literal text with the given string as content.MutableText
shallowCopy()
Copies the text itself, the style, and the siblings.default <T> Optional<T>
visit(StringVisitable.StyledVisitor<T> styledVisitor, Style style)
Supplies this visitable's literal content and contextual style to the visitor.default <T> Optional<T>
visit(StringVisitable.Visitor<T> visitor)
Supplies this visitable's literal content to the visitor.default <T> Optional<T>
visitSelf(StringVisitable.StyledVisitor<T> visitor, Style style)
Visits the text itself.default <T> Optional<T>
visitSelf(StringVisitable.Visitor<T> visitor)
Visits the text itself.
-
Method Details
-
getStyle
Style getStyle()Returns the style of this text.- Mappings:
Namespace Name Mixin selector official c
Loi;c()Los;
intermediary method_10866
Lnet/minecraft/class_2561;method_10866()Lnet/minecraft/class_2583;
named getStyle
Lnet/minecraft/text/Text;getStyle()Lnet/minecraft/text/Style;
-
asString
String asString()Returns the string representation of this text itself, excluding siblings.- Mappings:
Namespace Name Mixin selector official a
Loi;a()Ljava/lang/String;
intermediary method_10851
Lnet/minecraft/class_2561;method_10851()Ljava/lang/String;
named asString
Lnet/minecraft/text/Text;asString()Ljava/lang/String;
-
getString
- Specified by:
getString
in interfacecom.mojang.brigadier.Message
- Specified by:
getString
in interfaceStringVisitable
- Mappings:
Namespace Name Mixin selector official getString
Lol;getString()Ljava/lang/String;
intermediary getString
Lnet/minecraft/class_5348;getString()Ljava/lang/String;
named getString
Lnet/minecraft/text/StringVisitable;getString()Ljava/lang/String;
-
asTruncatedString
Returns the full string representation of this text, truncated beyond the suppliedlength
.- Parameters:
length
- the max length allowed for the string representation of the text- Mappings:
Namespace Name Mixin selector official a
Loi;a(I)Ljava/lang/String;
intermediary method_10858
Lnet/minecraft/class_2561;method_10858(I)Ljava/lang/String;
named asTruncatedString
Lnet/minecraft/text/Text;asTruncatedString(I)Ljava/lang/String;
-
getSiblings
Returns the siblings of this text.- Mappings:
Namespace Name Mixin selector official b
Loi;b()Ljava/util/List;
intermediary method_10855
Lnet/minecraft/class_2561;method_10855()Ljava/util/List;
named getSiblings
Lnet/minecraft/text/Text;getSiblings()Ljava/util/List;
-
copy
MutableText copy()Copies the text itself, excluding the styles or siblings.- Mappings:
Namespace Name Mixin selector official g
Loi;g()Loo;
intermediary method_27662
Lnet/minecraft/class_2561;method_27662()Lnet/minecraft/class_5250;
named copy
Lnet/minecraft/text/Text;copy()Lnet/minecraft/text/MutableText;
-
shallowCopy
MutableText shallowCopy()Copies the text itself, the style, and the siblings.A shallow copy is made for the siblings.
- Mappings:
Namespace Name Mixin selector official e
Loi;e()Loo;
intermediary method_27661
Lnet/minecraft/class_2561;method_27661()Lnet/minecraft/class_5250;
named shallowCopy
Lnet/minecraft/text/Text;shallowCopy()Lnet/minecraft/text/MutableText;
-
asOrderedText
- Mappings:
Namespace Name Mixin selector official f
Loi;f()Lafs;
intermediary method_30937
Lnet/minecraft/class_2561;method_30937()Lnet/minecraft/class_5481;
named asOrderedText
Lnet/minecraft/text/Text;asOrderedText()Lnet/minecraft/text/OrderedText;
-
visit
@Environment(CLIENT) default <T> Optional<T> visit(StringVisitable.StyledVisitor<T> styledVisitor, Style style)Supplies this visitable's literal content and contextual style to the visitor.- Specified by:
visit
in interfaceStringVisitable
- Parameters:
styledVisitor
- the visitorstyle
- the contextual style- Returns:
Optional.empty()
if the visit finished, or a terminating result from thevisitor
- Mappings:
Namespace Name Mixin selector official a
Lol;a(Lol$b;Los;)Ljava/util/Optional;
intermediary method_27658
Lnet/minecraft/class_5348;method_27658(Lnet/minecraft/class_5348$class_5246;Lnet/minecraft/class_2583;)Ljava/util/Optional;
named visit
Lnet/minecraft/text/StringVisitable;visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;
-
visit
Supplies this visitable's literal content to the visitor.- Specified by:
visit
in interfaceStringVisitable
- Parameters:
visitor
- the visitor- Returns:
Optional.empty()
if the visit finished, or a terminating result from thevisitor
- Mappings:
Namespace Name Mixin selector official a
Lol;a(Lol$a;)Ljava/util/Optional;
intermediary method_27657
Lnet/minecraft/class_5348;method_27657(Lnet/minecraft/class_5348$class_5245;)Ljava/util/Optional;
named visit
Lnet/minecraft/text/StringVisitable;visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;
-
visitSelf
@Environment(CLIENT) default <T> Optional<T> visitSelf(StringVisitable.StyledVisitor<T> visitor, Style style)Visits the text itself.- Parameters:
visitor
- the visitorstyle
- the current style- Returns:
- the visitor's return value
- See Also:
visit(StyledVisitor, Style)
- Mappings:
Namespace Name Mixin selector official b
Loi;b(Lol$b;Los;)Ljava/util/Optional;
intermediary method_27660
Lnet/minecraft/class_2561;method_27660(Lnet/minecraft/class_5348$class_5246;Lnet/minecraft/class_2583;)Ljava/util/Optional;
named visitSelf
Lnet/minecraft/text/Text;visitSelf(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;
-
visitSelf
Visits the text itself.- Parameters:
visitor
- the visitor- Returns:
- the visitor's return value
- See Also:
visit(Visitor)
- Mappings:
Namespace Name Mixin selector official b
Loi;b(Lol$a;)Ljava/util/Optional;
intermediary method_27659
Lnet/minecraft/class_2561;method_27659(Lnet/minecraft/class_5348$class_5245;)Ljava/util/Optional;
named visitSelf
Lnet/minecraft/text/Text;visitSelf(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;
-
of
Creates a literal text with the given string as content.- Mappings:
Namespace Name Mixin selector official a
Loi;a(Ljava/lang/String;)Loi;
intermediary method_30163
Lnet/minecraft/class_2561;method_30163(Ljava/lang/String;)Lnet/minecraft/class_2561;
named of
Lnet/minecraft/text/Text;of(Ljava/lang/String;)Lnet/minecraft/text/Text;
-