Enum minecraft_json::minecraft::text::TextComponent   [−][src]
pub enum TextComponent {
    RawTextLike(StringLike),
    RawTextList(Vec<TextComponent>),
    Text {
        text: StringLike,
        properties: TextComponentTags,
    },
    Translated {
        translate: String,
        with: Vec<TextComponent>,
        properties: TextComponentTags,
    },
    ScoreBoard {
        score: Score,
        properties: TextComponentTags,
    },
    EntityNames {
        selector: String,
        separator: Box<TextComponent>,
        properties: TextComponentTags,
    },
    KeyBind {
        keybind: String,
        properties: TextComponentTags,
    },
    NbtValue {
        nbt: String,
        interpret: bool,
        separator: Box<TextComponent>,
        block: Option<String>,
        entity: Option<String>,
        storage: Option<String>,
        properties: TextComponentTags,
    },
}Expand description
Raw JSON text is made up of text components. There is a single root component, which can have child components, which can have their own children and so on. Components can also have formatting and interactivity added to them, which is inherited by their children.
Variants
RawTextLike(StringLike)Displays plain text.
RawTextList(Vec<TextComponent>)A list of raw JSON text components.
Same as having all components after the first one appended to the first’s extra array.
For example, ["A", "B", "C"] is equivalent to {"text": "A", "extra": ["B", "C"]}.
Displays plain text.
Show fields
Fields of Text
Displays a translated piece of text from the currently selected language. This uses the client’s selected language, so if players with their games set to different languages are logged into the same server, each will see the component in their own language.
Translations are defined in language files in resource packs, including the built-in resource pack.
Translations can contain slots for text that is not known ahead of time, such as player
names. When displaying the translated text, slots will be filled from a provided list of
text components. The slots are defined in the language file, and generally take the form
%s (displays the next component in the list), or %3$s (displays the third component in
the list; replace 3 with whichever index is desired). For example, the built-in English
language file contains the translation
"chat.type.advancement.task": "%s has made the advancement %s",.
Show fields
Fields of Translated
translate: StringA translation identifier, corresponding to the identifiers found in loaded language files. Displayed as the corresponding text in the player’s selected language. If no corresponding translation can be found, the identifier itself is used as the translated text.
with: Vec<TextComponent>Optional. A list of raw JSON text components to be inserted into slots in the translation text.
properties: TextComponentTagsCommon additional properties.
Displays a score from the scoreboard.
Show fields
Fields of ScoreBoard
score: ScoreDisplays a score holder’s current score in an objective. Displays nothing if the given score holder or the given objective do not exist, or if the score holder is not tracked in the objective.
properties: TextComponentTagsCommon additional properties.
Displays the name of one or more entities found by a selector.
If exactly one entity is found, the entity’s name is displayed by itself. If more are
found, their names are displayed in the form "Name1, Name2, Name3", with gray commas.
If none are found, the component is displayed as no text.
Hovering over a name shows a tooltip with the name, type, and UUID of the target. Clicking a player’s name suggests a command to whisper to that player. Shift-clicking a player’s name inserts that name into chat. Shift-clicking a non-player entity’s name inserts its UUID into chat.
Show fields
Fields of EntityNames
selector: StringA string containing a selector.
separator: Box<TextComponent>Optional, defaults to {"color": "gray", "text": ", "}. A raw JSON text component.
Used as the separator between different names, if the component selects multiple entities.
properties: TextComponentTagsCommon additional properties.
Displays the name of the button that is currently bound to a certain configurable control. This uses the client’s own control scheme, so if players with different control schemes are logged into the same server, each will see their own keybind.
Show fields
Fields of KeyBind
keybind: StringA keybind identifier, to be displayed as the name of the button that is currently
bound to that action. For example, {"keybind": "key.inventory"} displays “e” if
the player is using the default control scheme.
properties: TextComponentTagsCommon additional properties.
Displays NBT values from entities, block entities, or command storage.
NBT strings display their contents. Other NBT values are displayed as SNBT, with no
spacing between symbols. If interpret is set to true, the game will instead attempt to
parse and display that text as its own raw JSON text component. That usually only works
on strings, since JSON and SNBT are not compatible. If interpret is true and parsing
fails, the component is displayed as no text. If more than one NBT value is found, either
by selecting multiple entities or by using a multi-value path, they are displayed in the
form "Value1, Value2, Value3, Value4".
Requires component resolution.
- If 
interpretisfalse, the component is resolved into a text component containing the display text.- If multiple values are selected and 
separatoris not present, the entire component is still resolved into a single text component, with the text", "between the display text of each value. - If multiple values are selected and 
separatoris present, each value is resolved into an individual text component, and all values after the first will be added to the first’sextralist, separated by copies of theseparatorcomponent. 
 - If multiple values are selected and 
 - If 
interpretistrue, the component is resolved into the parsed text component. For any non-content tags that are present on both the parsed text component and the component being resolved, the tag on the component being resolved will be used.- If multiple values are selected, all values after the first will be added to the
first’s 
extralist, separated by copies of theseparatorcomponent (or its default, if not present). This means that all values after the first will inherit the first value’s formatting tags, if any. 
 - If multiple values are selected, all values after the first will be added to the
first’s 
 
Show fields
Fields of NbtValue
nbt: StringThe NBT path used for looking up NBT values from an entity, block entity, or storage.
Requires one of block, entity, or storage. Having more than one is allowed, but
only one is used.
interpret: boolOptional, defaults to false. If true, the game attempts to parse the text of each
NBT value as a raw JSON text component. Ignored if nbt is not present.
See also the documentation for TextComponent::NbtValue.
separator: Box<TextComponent>Optional, defaults to {"text": ", "}. A raw JSON text component. Used as the
separator between different tags, if the component selects multiple tags.
block: Option<String>A string specifying the coordinates of the block entity from which the NBT value
is obtained. The coordinates can be absolute or relative. Ignored if nbt is not
present.
entity: Option<String>A string specifying the target selector for the entity or entities from which the
NBT value is obtained. Ignored if nbt is not present.
storage: Option<String>A string specifying the namespaced ID of the command storage from which the NBT
value is obtained. Ignored if nbt is not present.
properties: TextComponentTagsCommon additional properties.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 
[src]Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.