Interface Text
- All Superinterfaces:
com.mojang.brigadier.Message,StringVisitable
- All Known Implementing Classes:
MutableText
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:
- Mappings:
Namespace Name named net/minecraft/text/Textintermediary net/minecraft/class_2561official xg
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classNested 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 TypeMethodDescriptiondefault StringasTruncatedString(int length) Returns the full string representation of this text, truncated beyond the suppliedlength.default booleanReturns whether the text containstext, without considering styles.default MutableTextcopy()Copies the text's content, the style, and the siblings.default MutableTextCopies the text's content, excluding the styles or siblings.static MutableTextempty()Returns the content of the text.Returns the string of the literal text, ornullif this text is not a literal.Returns the siblings of this text.default StringgetStyle()Returns the style of this text.getWithStyle(Style style) static MutableTextstatic MutableTextstatic MutableTextnbt(String rawPath, boolean interpret, Optional<Text> separator, NbtDataSource dataSource) static Textof(com.mojang.brigadier.Message message) Returns a text withmessage.static TextCreates a literal text with the given string as content.static Textstatic TextReturns a literal text representingdate.static TextReturns a text representinguuid.static Textof(Identifier id) Returns a text representingid.static TextReturns a text representing chunkpos.static MutableTextstatic MutableTextscore(ParsedSelector selector, String objective) static MutableTextselector(ParsedSelector selector, Optional<Text> separator) static MutableTextstringifiedTranslatable(String key, Object[] args) Returns a translatable text with arguments.static MutableTexttranslatable(String key) static MutableTexttranslatable(String key, Object[] args) Returns a translatable text with arguments.static MutableTexttranslatableWithFallback(String key, @Nullable String fallback) static MutableTexttranslatableWithFallback(String key, @Nullable String fallback, Object[] args) 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.
-
Method Details
-
getStyle
Style getStyle()Returns the style of this text.- Mappings:
Namespace Name Mixin selector named getStyleLnet/minecraft/text/Text;getStyle()Lnet/minecraft/text/Style;intermediary method_10866Lnet/minecraft/class_2561;method_10866()Lnet/minecraft/class_2583;official aLxg;a()Lyd;
-
getContent
TextContent getContent()Returns the content of the text.- Returns:
- the content of the text
- Mappings:
Namespace Name Mixin selector named getContentLnet/minecraft/text/Text;getContent()Lnet/minecraft/text/TextContent;intermediary method_10851Lnet/minecraft/class_2561;method_10851()Lnet/minecraft/class_7417;official bLxg;b()Lxh;
-
getString
- Specified by:
getStringin interfacecom.mojang.brigadier.Message- Specified by:
getStringin interfaceStringVisitable
-
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 named asTruncatedStringLnet/minecraft/text/Text;asTruncatedString(I)Ljava/lang/String;intermediary method_10858Lnet/minecraft/class_2561;method_10858(I)Ljava/lang/String;official aLxg;a(I)Ljava/lang/String;
-
getSiblings
Returns the siblings of this text.- Mappings:
Namespace Name Mixin selector named getSiblingsLnet/minecraft/text/Text;getSiblings()Ljava/util/List;intermediary method_10855Lnet/minecraft/class_2561;method_10855()Ljava/util/List;official cLxg;c()Ljava/util/List;
-
getLiteralString
Returns the string of the literal text, ornullif this text is not a literal.A literal text is an unstyled
PlainTextContentwithout any siblings. Such texts are serialized as a string instead of an object.- Returns:
- the string of the literal text, or
nullif this text is not a literal - Mappings:
Namespace Name Mixin selector named getLiteralStringLnet/minecraft/text/Text;getLiteralString()Ljava/lang/String;intermediary method_54160Lnet/minecraft/class_2561;method_54160()Ljava/lang/String;official dLxg;d()Ljava/lang/String;
-
copyContentOnly
Copies the text's content, excluding the styles or siblings.- Mappings:
Namespace Name Mixin selector named copyContentOnlyLnet/minecraft/text/Text;copyContentOnly()Lnet/minecraft/text/MutableText;intermediary method_27662Lnet/minecraft/class_2561;method_27662()Lnet/minecraft/class_5250;official eLxg;e()Lxu;
-
copy
Copies the text's content, the style, and the siblings.A shallow copy is made for the siblings.
- Mappings:
Namespace Name Mixin selector named copyLnet/minecraft/text/Text;copy()Lnet/minecraft/text/MutableText;intermediary method_27661Lnet/minecraft/class_2561;method_27661()Lnet/minecraft/class_5250;official fLxg;f()Lxu;
-
asOrderedText
OrderedText asOrderedText()- Mappings:
Namespace Name Mixin selector named asOrderedTextLnet/minecraft/text/Text;asOrderedText()Lnet/minecraft/text/OrderedText;intermediary method_30937Lnet/minecraft/class_2561;method_30937()Lnet/minecraft/class_5481;official gLxg;g()Lazk;
-
visit
Supplies this visitable's literal content and contextual style to the visitor.- Specified by:
visitin 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 named visitLnet/minecraft/text/StringVisitable;visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;intermediary method_27658Lnet/minecraft/class_5348;method_27658(Lnet/minecraft/class_5348$class_5246;Lnet/minecraft/class_2583;)Ljava/util/Optional;official aLxl;a(Lxl$b;Lyd;)Ljava/util/Optional;
-
visit
Supplies this visitable's literal content to the visitor.- Specified by:
visitin interfaceStringVisitable- Parameters:
visitor- the visitor- Returns:
Optional.empty()if the visit finished, or a terminating result from thevisitor- Mappings:
Namespace Name Mixin selector named visitLnet/minecraft/text/StringVisitable;visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;intermediary method_27657Lnet/minecraft/class_5348;method_27657(Lnet/minecraft/class_5348$class_5245;)Ljava/util/Optional;official aLxl;a(Lxl$a;)Ljava/util/Optional;
-
withoutStyle
- Mappings:
Namespace Name Mixin selector named withoutStyleLnet/minecraft/text/Text;withoutStyle()Ljava/util/List;intermediary method_44746Lnet/minecraft/class_2561;method_44746()Ljava/util/List;official hLxg;h()Ljava/util/List;
-
getWithStyle
- Mappings:
Namespace Name Mixin selector named getWithStyleLnet/minecraft/text/Text;getWithStyle(Lnet/minecraft/text/Style;)Ljava/util/List;intermediary method_36136Lnet/minecraft/class_2561;method_36136(Lnet/minecraft/class_2583;)Ljava/util/List;official aLxg;a(Lyd;)Ljava/util/List;
-
contains
Returns whether the text containstext, without considering styles.- Returns:
- whether the text contains
text, without considering styles - Mappings:
Namespace Name Mixin selector named containsLnet/minecraft/text/Text;contains(Lnet/minecraft/text/Text;)Zintermediary method_44745Lnet/minecraft/class_2561;method_44745(Lnet/minecraft/class_2561;)Zofficial aLxg;a(Lxg;)Z
-
of
Creates a literal text with the given string as content.- Mappings:
Namespace Name Mixin selector named ofLnet/minecraft/text/Text;of(Ljava/lang/String;)Lnet/minecraft/text/Text;intermediary method_30163Lnet/minecraft/class_2561;method_30163(Ljava/lang/String;)Lnet/minecraft/class_2561;official aLxg;a(Ljava/lang/String;)Lxg;
-
literal
- Mappings:
Namespace Name Mixin selector named literalLnet/minecraft/text/Text;literal(Ljava/lang/String;)Lnet/minecraft/text/MutableText;intermediary method_43470Lnet/minecraft/class_2561;method_43470(Ljava/lang/String;)Lnet/minecraft/class_5250;official bLxg;b(Ljava/lang/String;)Lxu;
-
translatable
- Mappings:
Namespace Name Mixin selector named translatableLnet/minecraft/text/Text;translatable(Ljava/lang/String;)Lnet/minecraft/text/MutableText;intermediary method_43471Lnet/minecraft/class_2561;method_43471(Ljava/lang/String;)Lnet/minecraft/class_5250;official cLxg;c(Ljava/lang/String;)Lxu;
-
translatable
Returns a translatable text with arguments.The arguments passed must be either numbers, booleans, strings, or another
Text. UsestringifiedTranslatable(java.lang.String, java.lang.Object[])to construct texts with other objects as arguments. Alternatively, convert them using static methods here likeof(Identifier).- Returns:
- a translatable text with arguments
- Mappings:
Namespace Name Mixin selector named translatableLnet/minecraft/text/Text;translatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/text/MutableText;intermediary method_43469Lnet/minecraft/class_2561;method_43469(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/class_5250;official aLxg;a(Ljava/lang/String;[Ljava/lang/Object;)Lxu;
-
stringifiedTranslatable
Returns a translatable text with arguments.Arguments that are not numbers, booleans, strings, or another
Textare converted to strings usingString.valueOf(Object).- Returns:
- a translatable text with arguments
- Mappings:
Namespace Name Mixin selector named stringifiedTranslatableLnet/minecraft/text/Text;stringifiedTranslatable(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/text/MutableText;intermediary method_54159Lnet/minecraft/class_2561;method_54159(Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/class_5250;official bLxg;b(Ljava/lang/String;[Ljava/lang/Object;)Lxu;
-
translatableWithFallback
- Mappings:
Namespace Name Mixin selector named translatableWithFallbackLnet/minecraft/text/Text;translatableWithFallback(Ljava/lang/String;Ljava/lang/String;)Lnet/minecraft/text/MutableText;intermediary method_48321Lnet/minecraft/class_2561;method_48321(Ljava/lang/String;Ljava/lang/String;)Lnet/minecraft/class_5250;official aLxg;a(Ljava/lang/String;Ljava/lang/String;)Lxu;
-
translatableWithFallback
static MutableText translatableWithFallback(String key, @Nullable @Nullable String fallback, Object[] args) - Mappings:
Namespace Name Mixin selector named translatableWithFallbackLnet/minecraft/text/Text;translatableWithFallback(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/text/MutableText;intermediary method_48322Lnet/minecraft/class_2561;method_48322(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Lnet/minecraft/class_5250;official aLxg;a(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Lxu;
-
empty
- Mappings:
Namespace Name Mixin selector named emptyLnet/minecraft/text/Text;empty()Lnet/minecraft/text/MutableText;intermediary method_43473Lnet/minecraft/class_2561;method_43473()Lnet/minecraft/class_5250;official iLxg;i()Lxu;
-
keybind
- Mappings:
Namespace Name Mixin selector named keybindLnet/minecraft/text/Text;keybind(Ljava/lang/String;)Lnet/minecraft/text/MutableText;intermediary method_43472Lnet/minecraft/class_2561;method_43472(Ljava/lang/String;)Lnet/minecraft/class_5250;official dLxg;d(Ljava/lang/String;)Lxu;
-
nbt
static MutableText nbt(String rawPath, boolean interpret, Optional<Text> separator, NbtDataSource dataSource) - Mappings:
Namespace Name Mixin selector named nbtLnet/minecraft/text/Text;nbt(Ljava/lang/String;ZLjava/util/Optional;Lnet/minecraft/text/NbtDataSource;)Lnet/minecraft/text/MutableText;intermediary method_43468Lnet/minecraft/class_2561;method_43468(Ljava/lang/String;ZLjava/util/Optional;Lnet/minecraft/class_7419;)Lnet/minecraft/class_5250;official aLxg;a(Ljava/lang/String;ZLjava/util/Optional;Lyi;)Lxu;
-
score
- Mappings:
Namespace Name Mixin selector named scoreLnet/minecraft/text/Text;score(Lnet/minecraft/text/ParsedSelector;Ljava/lang/String;)Lnet/minecraft/text/MutableText;intermediary method_62790Lnet/minecraft/class_2561;method_62790(Lnet/minecraft/class_10104;Ljava/lang/String;)Lnet/minecraft/class_5250;official aLxg;a(Lhc;Ljava/lang/String;)Lxu;
-
score
- Mappings:
Namespace Name Mixin selector named scoreLnet/minecraft/text/Text;score(Ljava/lang/String;Ljava/lang/String;)Lnet/minecraft/text/MutableText;intermediary method_43466Lnet/minecraft/class_2561;method_43466(Ljava/lang/String;Ljava/lang/String;)Lnet/minecraft/class_5250;official bLxg;b(Ljava/lang/String;Ljava/lang/String;)Lxu;
-
selector
- Mappings:
Namespace Name Mixin selector named selectorLnet/minecraft/text/Text;selector(Lnet/minecraft/text/ParsedSelector;Ljava/util/Optional;)Lnet/minecraft/text/MutableText;intermediary method_43467Lnet/minecraft/class_2561;method_43467(Lnet/minecraft/class_10104;Ljava/util/Optional;)Lnet/minecraft/class_5250;official aLxg;a(Lhc;Ljava/util/Optional;)Lxu;
-
of
Returns a literal text representingdate.- Returns:
- a literal text representing
date - Implementation Note:
- The date is converted to a string using
Date.toString(). Notably, it does not localize the date format. - Mappings:
Namespace Name Mixin selector named ofLnet/minecraft/text/Text;of(Ljava/util/Date;)Lnet/minecraft/text/Text;intermediary method_54157Lnet/minecraft/class_2561;method_54157(Ljava/util/Date;)Lnet/minecraft/class_2561;official aLxg;a(Ljava/util/Date;)Lxg;
-
of
Returns a text withmessage.If a text instance is passed, this method returns
messageitself; otherwise this creates a new literal text with the message content.- Returns:
- a text with
message - Mappings:
Namespace Name Mixin selector named ofLnet/minecraft/text/Text;of(Lcom/mojang/brigadier/Message;)Lnet/minecraft/text/Text;intermediary method_54155Lnet/minecraft/class_2561;method_54155(Lcom/mojang/brigadier/Message;)Lnet/minecraft/class_2561;official aLxg;a(Lcom/mojang/brigadier/Message;)Lxg;
-
of
Returns a text representinguuid.The UUID is converted to a string like
12345678-90AB-CDEF-1234-567890ABCDEF.- Returns:
- a text representing
uuid - See Also:
- Mappings:
Namespace Name Mixin selector named ofLnet/minecraft/text/Text;of(Ljava/util/UUID;)Lnet/minecraft/text/Text;intermediary method_54158Lnet/minecraft/class_2561;method_54158(Ljava/util/UUID;)Lnet/minecraft/class_2561;official aLxg;a(Ljava/util/UUID;)Lxg;
-
of
Returns a text representingid.The returned text has the format
namespace:path. Namespace is always included.- Returns:
- a text representing
id - Mappings:
Namespace Name Mixin selector named ofLnet/minecraft/text/Text;of(Lnet/minecraft/util/Identifier;)Lnet/minecraft/text/Text;intermediary method_54154Lnet/minecraft/class_2561;method_54154(Lnet/minecraft/class_2960;)Lnet/minecraft/class_2561;official aLxg;a(Lalr;)Lxg;
-
of
Returns a text representing chunkpos.The returned text has the format
[X, Z].- Returns:
- a text representing chunk
pos - Mappings:
Namespace Name Mixin selector named ofLnet/minecraft/text/Text;of(Lnet/minecraft/util/math/ChunkPos;)Lnet/minecraft/text/Text;intermediary method_54156Lnet/minecraft/class_2561;method_54156(Lnet/minecraft/class_1923;)Lnet/minecraft/class_2561;official aLxg;a(Ldjo;)Lxg;
-
of
- Mappings:
Namespace Name Mixin selector named ofLnet/minecraft/text/Text;of(Ljava/net/URI;)Lnet/minecraft/text/Text;intermediary method_61110Lnet/minecraft/class_2561;method_61110(Ljava/net/URI;)Lnet/minecraft/class_2561;official aLxg;a(Ljava/net/URI;)Lxg;
-