Minecraft:Text component format
More actions
|
For the {{{Description}}} of the same name, see [[{{{Destination}}}]]. |
The text component format, historically also known as raw JSON text, is used by Minecraft to send and display rich-text to players. It can also be sent by players themselves using commands (such as
- REDIRECT Template:Command
Template:Redr and
- REDIRECT Template:Command
Template:Redr) and data packs.
Java Edition
Text components are written in SNBT, for example Template:Cd. They are used for rich-text formatting in written books, Minecraft:signs, custom names and the
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
- REDIRECT Template:Command
Template:Redr and
- REDIRECT Template:Command
Template:Redr commands.
The format 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.
A component can be a Template:Nbt/sprite string, Template:Nbt/sprite list or a Template:Nbt/sprite object. Strings and lists are both shorthand for longer object structures, as described below.
- Template:Nbt/sprite A string containing plain text to display directly. This is the same as an object that only has a Template:Nbt/sprite text tag. For example,
"A"and{text: "A"}are equivalent. - Template:Nbt/sprite A list of components. Same as having all components after the first one appended to the first's Template:Nbt/sprite extra list. For example,
["A", "B", "C"]is equivalent to{text: "A", extra: ["B", "C"]}. Note that because the later components are actually children of the first one, any formatting applied to the first component is inherited by the later ones. For example,[{text: "A", color: "red"}, "B", "C"]will display all three letters with red text. - Template:Nbt/sprite A text component object. All non-content tags are optional.
- Content
- Template:Nbt/sprite type: Optional. Specifies the content type. One of
"text","translatable","score","selector","keybind", or"nbt". - If Template:Nbt/sprite type is not present, has an invalid value, or if the required tags for the specified type are not present, the type is determined automatically by checking the object for the following tags: [[#Plain Text|Template:Nbt/sprite text]], [[#Translated Text|Template:Nbt/sprite translate]], [[#Scoreboard Value|Template:Nbt/sprite score]], [[#Entity Names|Template:Nbt/sprite selector]], [[#Keybind|Template:Nbt/sprite keybind]], and finally [[#NBT Values|Template:Nbt/sprite nbt]]. If multiple are present, whichever one comes first in that list is used.
- Values specific to each content type are described below.
- Template:Nbt/sprite type: Optional. Specifies the content type. One of
- Children
- Template:Nbt/sprite extra: A list of additional components to be displayed after this one.
- A child text component. Child text components inherit all formatting and interactivity from the parent component, unless they explicitly override them.
- Template:Nbt/sprite extra: A list of additional components to be displayed after this one.
- Formatting
- Template:Nbt/sprite color: Optional. Changes the color to render the content in the text component object and its child objects. If not present, the parent color will be used instead. The color is specified as a color code or as a color name.
"#<hex>", where<hex>is a 6-digit hexadecimal color, changes the color to #<hex>"black"changes the color to Template:Color"dark_blue"changes the color to Template:Color"dark_green"changes the color to Template:Color"dark_aqua"changes the color to Template:Color"dark_red"changes the color to Template:Color"dark_purple"changes the color to Template:Color"gold"changes the color to Template:Color"gray"changes the color to Template:Color"dark_gray"changes the color to Template:Color"blue"changes the color to Template:Color"green"changes the color to Template:Color"aqua"changes the color to Template:Color"red"changes the color to Template:Color"light_purple"changes the color to Template:Color"yellow"changes the color to Template:Color"white"changes the color to Template:Color
- Template:Nbt/sprite font: Optional. The resource location of the font for this component in the resource pack within
assets/<namespace>/font. Defaults to"minecraft:default". - Template:Nbt/sprite bold: Optional. Whether to render the content in bold.
- Template:Nbt/sprite italic: Optional. Whether to render the content in italics. Note that text that is italicized by default, such as custom item names, can be unitalicized by setting this to
false. - Template:Nbt/sprite underlined: Optional. Whether to underline the content.
- Template:Nbt/sprite strikethrough: Optional. Whether to strikethrough the content.
- Template:Nbt/sprite obfuscated: Optional. Whether to render the content obfuscated.
- Template:Nbt/sprite shadow_color: The color and opacity of the shadow. If omitted, the shadow is 25% the brightness of the text color and 100% the opacity{{
- Template:Nbt/sprite color: Optional. Changes the color to render the content in the text component object and its child objects. If not present, the parent color will be used instead. The color is specified as a color code or as a color name.
- Content
#vardefine: verifyedition |
}}<verify for {{#var:verifyedition}}></verify for {{#var:verifyedition}}>{{
#vardefine: verifyedition |
}}. Color codes are the ARGB hex code of the color converted to a decimal number, or can be calculated from the opacity, red, green and blue components using this formula:
Alpha<<24 + Red<<16 + Green<<8 + Blue
- Template:Nbt/sprite shadow_color: Another format. A list containing 4 floats corresponding to red, green, blue, and opacity values as a fraction (ranged 0 to 1, inclusive) that is automatically converted to the int format.
- Interactivity
- Template:Nbt/sprite insertion: Optional. When the text is shift-clicked by a player, this string is inserted in their chat input. It does not overwrite any existing text the player was writing. This only works in chat messages.
- Template:Nbt/sprite click_event: Optional. Allows for events to occur when the player clicks on text. See Template:Slink.
- Template:Nbt/sprite hover_event: Optional. Allows for a tooltip to be displayed when the player hovers their mouse over text. See Template:Slink.
Due to the Template:Nbt/sprite extra tag, the above format may be recursively nested to produce complex and functional text strings. However, a text component doesn't have to be complicated at all: virtually all properties are optional and may be left out.
Content types
Text components can display several types of content. These tags should be included directly into the text component object.
Plain Text
Displays plain text.
- Template:Nbt/sprite The text component.
- Template:Nbt/sprite type: Optional. Set to
"text". - Template:Nbt/sprite text: A string containing plain text to display directly.
- Template:Nbt/sprite type: Optional. Set to
Translated 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, the translate key, the fallback key 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).<ref group=note>Selecting the "next" argument ignores slots that specify an index explicitly. So if the translation text "Hello %s, %2$s, and %s." was given the components "John" and "Becky", it would display "Hello John, Becky, and Becky."</ref> For example, the built-in English language file contains the translation "chat.type.advancement.task": "%s has made the advancement %s",.
- Template:Nbt/sprite The text component.
- Template:Nbt/sprite type: Optional. Set to
"translatable". - Template:Nbt/sprite translate: A 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.
- Template:Nbt/sprite fallback: Optional. If no corresponding translation can be found, this is used as the translated text. Ignored if Template:Nbt/sprite translate is not present.
- Template:Nbt/sprite with: Optional. A list of text components to be inserted into slots in the translation text. Ignored if Template:Nbt/sprite translate is not present.
- A text component. If no component is provided for a slot, the slot is displayed as no text.
- Template:Nbt/sprite type: Optional. Set to
Scoreboard Value
Displays a score from the scoreboard.
| Requires component resolution. |
|---|
| This component is resolved into a Template:Nbt/sprite text component containing the scoreboard value. |
- Template:Nbt/sprite The text component.
- Template:Nbt/sprite type: Optional. Set to
"score". - Template:Nbt/sprite score: Displays 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.
- Template:Nbt/sprite name: The name of the score holder whose score should be displayed. This can be a selector like @p or an explicit name. If the text is a selector, the selector must be guaranteed to never select more than one entity, possibly by adding
limit=1. If the text is"*", it shows the reader's own score (for example,/tellraw @a {score: {name: "*", objective: "obj"}}shows every online player their own score in the "obj" objective).<ref group="note">Showing the reader's own score only works in situations where a message has one singular reader. That is chat messages,/titles, and written books. It does not work for bossbar display names or blocks like signs.</ref> - Template:Nbt/sprite objective: The internal name of the objective to display the player's score in.
- Template:Nbt/sprite name: The name of the score holder whose score should be displayed. This can be a selector like @p or an explicit name. If the text is a selector, the selector must be guaranteed to never select more than one entity, possibly by adding
- Template:Nbt/sprite type: Optional. Set to
Entity Names
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 Minecraft: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.
| Requires component resolution. |
|---|
|
- Template:Nbt/sprite The text component.
- Template:Nbt/sprite type: Optional. Set to
"selector". - Template:Nbt/sprite selector: A string containing a selector.
- Template:Nbt/sprite separator: Optional, defaults to
{color: "gray", text: ", "}. A text component. Used as the separator between different names, if the component selects multiple entities.
- Template:Nbt/sprite type: Optional. Set to
Keybind
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.
- Template:Nbt/sprite The text component.
- Template:Nbt/sprite type: Optional. Set to
"keybind". - Template:Nbt/sprite keybind: A 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. As a fallback it displays the translation if it exists.
- Template:Nbt/sprite type: Optional. Set to
NBT Values
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 Template:Nbt/sprite interpret is set to true, the game will instead attempt to parse and display that text as its own text component. That only works on compounds and lists which contain tags with the proper key names. If Template:Nbt/sprite interpret is true and parsing fails, the component is displayed as no text, or if it directs to a string, shows the string itself. If more than one NBT value is found, either by selecting multiple entities or by using a multi-value path, they are displayed in order, with the Template:Nbt/sprite separator value between them.
| Requires component resolution. |
|---|
|
- Template:Nbt/sprite The text component.
- Template:Nbt/sprite type: Optional. Set to
"nbt". - Template:Nbt/sprite source: Optional. Allowed values are
"block","entity", and"storage", corresponding to the source of the NBT data. - Template:Nbt/sprite nbt: The NBT path used for looking up NBT values from an entity, block entity, or storage. Requires one of Template:Nbt/sprite block, Template:Nbt/sprite entity, or Template:Nbt/sprite storage. Having more than one is allowed, but only one is used.<ref group=note>If Template:Nbt/sprite source is left unspecified, NBT sources are checked in the order Template:Nbt/sprite entity, Template:Nbt/sprite block, Template:Nbt/sprite storage. If multiple are present, whichever one comes first in that list is used.</ref>
- Template:Nbt/sprite interpret: Optional, defaults to false. If true, the game attempts to parse the text of each NBT value as a text component. Ignored if Template:Nbt/sprite nbt is not present.
- Template:Nbt/sprite separator: Optional, defaults to
{text: ", "}. A text component. Used as the separator between different tags, if the component selects multiple tags. - Template:Nbt/sprite entity: A string specifying the target selector for the entity or entities from which the NBT value is obtained. Ignored if Template:Nbt/sprite nbt is not present.
- Template:Nbt/sprite block: A string specifying the coordinates of the block entity from which the NBT value is obtained. The coordinates can be absolute, relative, or local. Ignored if Template:Nbt/sprite nbt is not present.
- Template:Nbt/sprite storage: A string specifying the resource location of the command storage from which the NBT value is obtained. Ignored if Template:Nbt/sprite nbt is not present.
- Template:Nbt/sprite type: Optional. Set to
Object
Displays objects as single sprites in component messages. Sprites are rendered as 8x8 pixels squares. This will ignore bold and italic styles!
Atlas Object Type
When specifying Template:Nbt/sprite object as "atlas", it displays a single sprite from a texture atlas as a character.
- Template:Nbt/sprite The text component.
- Template:Nbt/sprite type: Optional. Defaults to
"object"if object-specific keys are detected. - Template:Nbt/sprite object:
"atlas"(Optional as it defaults to"atlas"if not specified) - Template:Nbt/sprite atlas: Optional. The name of texture atlas. Defaults to
"minecraft:blocks". - Template:Nbt/sprite sprite: The sprite name (for example:
"block/emerald_block").
- Template:Nbt/sprite type: Optional. Defaults to
Player Object Type
When specifying Template:Nbt/sprite object as "player" it displays the 2D face sprite of a player profile.
- Template:Nbt/sprite The text component.
- Template:Nbt/sprite type: Optional. Defaults to
"object"if object-specific keys are detected. - Template:Nbt/sprite object:
"player" - Template:Nbt/spriteTemplate:Nbt/sprite player: The textures and/or player profile used to render the face sprite. Provided with the same format as the Template:DCL data component. If specified as a string, it corresponds to Template:Nbt/sprite name.
- Template:Nbt/sprite hat: Whether to display the hat layer. (Defaults to
true)
- Template:Nbt/sprite type: Optional. Defaults to
Component resolution
Text component resolution is the process of converting "advanced" (server-side) text components into "simple" (client-side) text components so that they can be displayed to the user.
Certain text component types, such as
- REDIRECT Template:Code
- REDIRECT Template:Code
- REDIRECT Template:Code
Template:Redr, and
- REDIRECT Template:Code
Template:Redr, can be directly displayed by a player client, as the client does not need any additional information to interpret them. Those are known as "client-side" or "simple" text components.
Other types, such as
- REDIRECT Template:Code
- REDIRECT Template:Code
Template:Redr, and
- REDIRECT Template:Code
Template:Redr, require additional work from the server before they can be displayed by the client. Those are known as "server-side" or "advanced" text components. As the client does not have access to the information that these text components are meant to display, they need to be resolved by the server, which involves retrieving appropriate data from the world and replacing the server-side text components with client-side ones which the client knows how to render.
If the client receives unresolved server-side text components,
- REDIRECT Template:Code
Template:Redr and
- REDIRECT Template:Code
Template:Redr text components display as empty text, but
- REDIRECT Template:Code
Template:Redr text components display the selector itself.
Additionally, text component resolution fixes a single value in place based on the appropriate data at the moment of resolution. Therefore, these content types are not dynamic, and don't update to reflect later changes. For example, {score:{name:"@p",objective:"points"}} may resolve to
- REDIRECT Template:Code
Template:Redr, and will stay that way even if the player's "
- REDIRECT Template:Code
Template:Redr" score increases or decreases.
Text component resolution can be done in many ways:
- Displaying text in chat or title slots with commands such as
- REDIRECT Template:Command
Template:Redr and
- REDIRECT Template:Command
- Writing a text component to any line on a Minecraft:sign.
- Writing a text component to a text display's
- REDIRECT Template:Code
Template:Redr tag.
- Using the set_name and set_lore item modifers, but only if their Template:Nbt/sprite entity field is set and that entity context exists.
- A text component in a written book will be resolved once first opened by an operator or, once placed into a lectern. However, if the resulting text component is too large then it will fail to resolve.
- Setting a boss bar name using
- REDIRECT Template:Command
Template:Redr while the command is executing as an entity.
- Setting a scoreboard objective's display name using
- REDIRECT Template:Command
Template:Redr while the command is executing as an entity.
- Setting a score holder's display name using
- REDIRECT Template:Command
Template:Redr while the command is executing as an entity.
- Setting a score holder or scoreboard objective's number format to a
- REDIRECT Template:Code
Template:Redr text component using
- REDIRECT Template:Command
- REDIRECT Template:Command
Template:Redr while the command is executing as an entity.
There are several places where text components are not automatically resolved, such as:
- Writing directly to data components such as Template:DCL, Template:DCL, Template:DCL, and Template:DCL. The previously mentioned item modifiers can be used to resolve text components when writing to these data components.
- Writing directly to entities'
- REDIRECT Template:Code
Template:Redr tag.
- All text in dialogs.<ref>Template:Bug</ref>
- Most JSON files in data packs, such as advancement names, chat types, painting variant authors/titles, etc.
Click events
Click events control what happens when the player clicks on the text. Can be one of the following: <section begin="click_events" />
open_url
Opens the specified URL in the user's default web browser.
- Template:Nbt
- Template:Nbt:
open_url - Template:Nbt/sprite url: The URL to open.
- Template:Nbt:
<section end="click_events" />
open_file
Opens the specified file on the user's computer. This is used in messages automatically generated by the game (e.g., on taking a screenshot) and cannot be sent by servers for security reasons.
- Template:Nbt
- Template:Nbt:
open_file - Template:Nbt/sprite path: The file to open.
- Template:Nbt:
<section begin="click_events" />
run_command
Runs the specified command. This runs as if the player typed the specified command in chat and pressed enter. However, this can only be used to run commands that do not send chat messages directly (like
- REDIRECT Template:Command
- REDIRECT Template:Command
Template:Redr, and
- REDIRECT Template:Command
Template:Redr). Since they are being run from chat, the player must have the required permissions.
On Minecraft:signs, the command is run by the server at the sign's location, with the player who {{#vardefine: control | right click on mouse or left trigger on gamepad }}used the sign as the command executor (that is, the entity selected by @s). Since they are run by the server, sign commands have the same permission level as a command block instead of using the player's permission level, and are not restricted by chat length limits.
- Template:Nbt
- Template:Nbt:
run_command - Template:Nbt/sprite command: The command to run. Does not need to be prefixed with a
/slash.
- Template:Nbt:
suggest_command
Opens chat and fills in the specified text or command. If a chat message was already being composed, it is overwritten.This does not work in books.<ref>Template:Bug</ref>
- Template:Nbt
- Template:Nbt:
suggest_command - Template:Nbt/sprite command: The command to fill in chat. Also works with normal texts.
- Template:Nbt:
change_page
Can only be used in written books. Changes to the specified page if that page exists.
- Template:Nbt
- Template:Nbt:
change_page - Template:Nbt/sprite page: The page to change to.
- Template:Nbt:
copy_to_clipboard
Copies the specified text to the clipboard.
- Template:Nbt
- Template:Nbt:
copy_to_clipboard - Template:Nbt/sprite value: The text to copy.
- Template:Nbt:
show_dialog
Opens the specified dialog.
- Template:Nbt
- Template:Nbt:
show_dialog - Template:Nbt/spriteTemplate:Nbt/sprite dialog: One dialog (an Template:Nbt ID, or a new Template:Nbt dialog definition) to display.
- Template:Nbt:
custom
Sends a custom event to the server; has no effect on vanilla servers.
- Template:Nbt
- Template:Nbt:
custom - Template:Nbt/sprite id: Any ID to identify the event.
- Template:Nbt/sprite payload: Optional payload of the event.
- Template:Nbt:
<section end="click_events" />
Hover events
Hover events control what happens when the player hovers over the text. Can be one of the following:
show_text
Shows a text component.
- Template:Nbt/sprite hover_event
- Template:Nbt/sprite action:
show_text - Template:Nbt/spriteTemplate:Nbt/spriteTemplate:Nbt/sprite value: Another text component. Can be any valid text component type: string, list, or object. Note that Template:Nbt/sprite click_event and Template:Nbt/sprite hover_event do not function within the tooltip.
- Template:Nbt/sprite action:
show_item
Shows the tooltip of an item as if it was being hovering over it in an inventory.
- Template:Nbt/sprite hover_event
- Template:Nbt/sprite action:
show_item - Template:Nbt/sprite id: The item's resource location. Defaults to
minecraft:airif invalid. - Template:Nbt/sprite count: Optional. Size of the item stack. This typically does not change the content tooltip.
- Template:Nbt/sprite components: Optional. Additional information about the item. See Data component format.
- Template:Nbt/sprite action:
show_entity
Shows an entity's name, type, and UUID. Used by Template:Nbt/sprite selector.
- Template:Nbt/sprite hover_event
- Template:Nbt/sprite action:
show_entity - Template:Nbt/sprite name: Optional. Hidden if not present. A text that is displayed as the name of the entity.
- Template:Nbt/sprite id: A string containing the type of the entity, as a resource location.
- Template:Nbt/spriteTemplate:Nbt/spriteTemplate:Nbt/sprite uuid: The Minecraft:UUID of the entity. Either:
- A string representing the UUID in the hyphenated hexadecimal format. Must be a valid UUID.
- A list of four numbers representing the UUID in int-array or list format. e.g.
[I;1,1,1,1]or[1,1,1,1].
- Template:Nbt/sprite action:
Bedrock Edition
Unlike Java Edition, text components in Bedrock Edition are written in Minecraft:JSON.
- Template:Nbt/sprite The root tag.
- Template:Nbt/sprite rawtext: A list contains all text object.
- Template:Nbt/sprite To be valid, an object must contain one content tag: Template:Nbt/sprite text, Template:Nbt/sprite translate, Template:Nbt/sprite score, or Template:Nbt/sprite selector. Having more than one is allowed, but only one is used.<ref group=note>Content tags are checked in the order Template:Nbt/sprite translate, Template:Nbt/sprite text, Template:Nbt/sprite selector, Template:Nbt/sprite score. If multiple are present, whichever one comes first in that list is used.</ref>
- Content: Plain Text
- Template:Nbt/sprite text: A string containing plain text to display directly.
- Content: Translated Text
- Template:Nbt/sprite translate: A translation identifier, to be 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 translation text. This identifier is the same as the identifiers found in lang files from assets or resource packs.
- Template:Nbt/sprite with: Optional. A list of text component arguments to be inserted into slots in the translation text. Ignored if Template:Nbt/sprite translate is not present.
- Translations can contain slots for text that is not known ahead of time, such as player names. These slots are defined in the translation text itself, not in the text component, and generally take the form
%%1(displays the first argument; replace1with whichever index is desired). If no argument is provided for a slot, the slot is not displayed.
- Translations can contain slots for text that is not known ahead of time, such as player names. These slots are defined in the translation text itself, not in the text component, and generally take the form
- Content: Scoreboard Value (requires resolution)
- Template:Nbt/sprite score: Displays 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.
- Template:Nbt/sprite name: The name of the score holder whose score should be displayed. This can be a selector like @p or an explicit name. If the text is
"*", it shows the reader's own score (for example,/tellraw @a { "rawtext" : [ { "score" : { "name" : "*" , "objective" : "obj"} } ] }shows every online player their own score in the "obj" objective).<ref group="note">Showing the reader's own score only works in situations where a message has one singular reader. That is chat messages,/titleraws, and written books.{{
- Template:Nbt/sprite name: The name of the score holder whose score should be displayed. This can be a selector like @p or an explicit name. If the text is
- Template:Nbt/sprite To be valid, an object must contain one content tag: Template:Nbt/sprite text, Template:Nbt/sprite translate, Template:Nbt/sprite score, or Template:Nbt/sprite selector. Having more than one is allowed, but only one is used.<ref group=note>Content tags are checked in the order Template:Nbt/sprite translate, Template:Nbt/sprite text, Template:Nbt/sprite selector, Template:Nbt/sprite score. If multiple are present, whichever one comes first in that list is used.</ref>
- Template:Nbt/sprite rawtext: A list contains all text object.
#vardefine: verifyedition |
}}<verify for {{#var:verifyedition}}></verify for {{#var:verifyedition}}>{{
#vardefine: verifyedition |
}} It doesn't work for things like signs that can have more than one "reader".{{
#vardefine: verifyedition |
}}<verify for {{#var:verifyedition}}></verify for {{#var:verifyedition}}>{{
#vardefine: verifyedition |
}}</ref>
- Template:Nbt/sprite objective: The internal name of the objective to display the player's score in.
- Content: Entity Names (requires resolution)
- Template:Nbt/sprite selector: A string containing a selector. Displayed as the name of the player or entity found by the selector. If more than one player or entity is found by the selector, their names are displayed in either the form "Name1 and Name2" or the form "Name1, Name2, Name3, and Name4". Hovering over a name shows a tooltip with the name, type, and Minecraft: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.
- Basic raw text example
- Template:Cmd
This sends a message to all players saying "Hello World" in English only. See the Translate action to see how to send localized texts.
Appending
Raw text takes in an array of text objects. Each object in the list is added to the previous object. For example, Template:Cmd outputs the same "Hello World" as the first example. Appending text can be useful to combine 2 different localized texts, or apply different colors to each word etc.
Breaking lines
You can go down a line by using "\n". For example,
Translate
The translate object allows creators to provide localized text to users. If translate is specified along with text, translate overrides the text object. The string to provide to translate is the name of the string in the language files. For example, in Vanilla Minecraft "commands.op.success" is the string that displays when /op is used on a player successfully.
This outputs "Opped %s" to all players. Note that because of text being ignored with translate specified, the following example outputs the same text:
With
In the translate example above, it outputs "Opped %s". To have a name or other text show up instead of %s, "with" needs to be specified as well. Note that "with" only works with "translate" and also requires an array
- REDIRECT Template:Code
Template:Redr instead of curly brackets Template:Cd.
If you want to use a translated text inside the "with" component, instead of an array it needs to be another rawtext component (which consists of an array of text components). The following example outputs "Opped Apple".
%%s
"translate" and "%s" can be used without needing a corresponding string in the localization files. For example:
This outputs "Hello Steve" to all players.
Multiple %s
%%s can be used multiple times. They are filled in, in the order specified
Outputs: "Hello Steve and Alex"
You can again use a rawtext component to replace the plain string array, like so
Outputs: "Hello Steve and Apple"
Ordering with %%#
The order to fill in %%s can be changed by instead specifying it with %%#, replacing # with an actual number. For example, to swap the position of Steve and Alex in the above example, instead run the following:
Outputs: "Hello Alex and Steve"
Formatting
String formatting is still possible, but not using the text component format used in Java Edition. Instead, formatting codes are used to change text color and style.
History
Java Edition
Bedrock Edition
See also
- Minecraft:Commands
- Formatting code
Notes
References
<references group="">
</references>
External links
Template:Navbox Java Edition technical
de:Textkomponenten ja:Raw JSONテキストフォーマット pt:Formato de componente de texto zh:文本组件