Mastering Minecraft’s Tellraw Command: A Comprehensive Guide
Minecraft’s `tellraw` command is an incredibly powerful tool for creating dynamic and interactive chat messages. It allows you to format text, insert clickable links, display item names, and even execute commands directly from chat. This guide provides a comprehensive walkthrough of the `tellraw` command, covering its syntax, various components, and practical examples to help you master its capabilities.
## What is the `tellraw` Command?
The `tellraw` command in Minecraft allows you to send JSON-formatted text messages to players. Unlike the standard `say` command, `tellraw` gives you complete control over the appearance and functionality of the text. You can change colors, styles (bold, italic, underlined, strikethrough, obfuscated), insert clickable actions, display tooltips, and much more. This makes it ideal for creating custom welcome messages, interactive tutorials, adventure maps, and server announcements.
## Syntax of the `tellraw` Command
The basic syntax of the `tellraw` command is as follows:
/tellraw
* `
* `
## Understanding the JSON Message Format
The JSON message is structured using key-value pairs. The main keys you’ll use are:
* `text`: Displays plain text.
* `translate`: Displays text using a translation key, allowing for language localization.
* `score`: Displays a player’s score from a specific objective.
* `selector`: Displays the names of entities matching a target selector.
* `keybind`: Displays the name of a keybind.
* `nbt`: Displays NBT data from an entity, block entity, or storage.
Each of these keys can have associated formatting options, such as `color`, `bold`, `italic`, `underlined`, `strikethrough`, and `obfuscated`. They can also include `clickEvent` and `hoverEvent` to add interactivity.
### Basic Text
The simplest form of the `tellraw` command is to display plain text. Here’s an example:
/tellraw @a {“text”:”Hello, Minecraft!”}
This command will send the message “Hello, Minecraft!” to all players on the server. Notice that the text is enclosed in double quotes and escaped with backslashes within the JSON object.
### Formatting Text
You can format the text by adding additional properties to the JSON object. For example, to make the text bold and blue:
/tellraw @a {“text”:”Hello, Minecraft!”, “color”:”blue”, “bold”:true}
Here’s a breakdown of the available formatting options:
* `color`: Specifies the color of the text. Valid values include `black`, `dark_blue`, `dark_green`, `dark_aqua`, `dark_red`, `dark_purple`, `gold`, `gray`, `dark_gray`, `blue`, `green`, `aqua`, `red`, `light_purple`, `yellow`, and `white`.
* `bold`: Set to `true` to make the text bold.
* `italic`: Set to `true` to make the text italic.
* `underlined`: Set to `true` to underline the text.
* `strikethrough`: Set to `true` to draw a line through the text.
* `obfuscated`: Set to `true` to make the text randomly change characters.
### Combining Multiple Text Elements
You can combine multiple text elements in a single `tellraw` command by using a JSON array. Each element in the array represents a separate piece of text with its own formatting.
/tellraw @a [{“text”:”This is “, “color”:”white”}, {“text”:”bold “, “bold”:true, “color”:”red”}, {“text”:”and this is “, “color”:”white”}, {“text”:”italic.”, “italic”:true, “color”:”green”}]
This command will display the message “This is **bold** and this is *italic*.” with different colors and styles applied to each part.
## Advanced Features of `tellraw`
The `tellraw` command offers several advanced features that allow you to create dynamic and interactive messages.
### Click Events
Click events allow you to define an action that occurs when a player clicks on a specific piece of text. The `clickEvent` property has two sub-properties:
* `action`: Specifies the type of action to perform. Possible values include `open_url`, `run_command`, `suggest_command`, `copy_to_clipboard`, and `change_page` (for books).
* `value`: Specifies the value associated with the action.
#### Opening a URL
To create a clickable link that opens a URL, use the `open_url` action.
/tellraw @a {“text”:”Click here to visit Google!”, “color”:”blue”, “underlined”:true, “clickEvent”:{“action”:”open_url”, “value”:”https://www.google.com”}}
This command will display the text “Click here to visit Google!” in blue and underlined. When a player clicks on the text, their web browser will open the Google website.
#### Running a Command
To execute a command when a player clicks on the text, use the `run_command` action. This is useful for creating interactive menus or triggering events in your world.
/tellraw @a {“text”:”Click here to get a diamond!”, “color”:”green”, “clickEvent”:{“action”:”run_command”, “value”:”/give @p diamond”}}
This command will display the text “Click here to get a diamond!” in green. When a player clicks on the text, they will receive a diamond. Note that the command is executed as the player clicking the text. Therefore, commands like `/tp` will work relative to the player. Also, the player needs to have sufficient permissions to run the command. For example, if the player is not an operator, they cannot run commands that require operator privileges.
#### Suggesting a Command
To suggest a command in the player’s chat box, use the `suggest_command` action. This is useful for providing hints or helping players learn commands.
/tellraw @a {“text”:”Click here to suggest the /help command!”, “color”:”yellow”, “clickEvent”:{“action”:”suggest_command”, “value”:”/help”}}
This command will display the text “Click here to suggest the /help command!” in yellow. When a player clicks on the text, the `/help` command will be inserted into their chat box, ready to be sent.
#### Copying to Clipboard
To copy text to the player’s clipboard, use the `copy_to_clipboard` action. This is useful for sharing codes or links.
/tellraw @a {“text”:”Click here to copy this text!”, “color”:”aqua”, “clickEvent”:{“action”:”copy_to_clipboard”, “value”:”This is the text that will be copied.”}}
This command will display the text “Click here to copy this text!” in aqua. When a player clicks on the text, the string “This is the text that will be copied.” will be copied to their clipboard.
### Hover Events
Hover events allow you to display additional information when a player hovers their mouse over a specific piece of text. The `hoverEvent` property has two sub-properties:
* `action`: Specifies the type of information to display. Possible values include `show_text`, `show_item`, `show_entity`, and `show_achievement` (deprecated).
* `contents`: Specifies the content to display when the player hovers over the text.
#### Showing Text
To display plain text when a player hovers over the text, use the `show_text` action.
/tellraw @a {“text”:”Hover over me!”, “color”:”light_purple”, “hoverEvent”:{“action”:”show_text”, “contents”:”This is the hover text!”}}
This command will display the text “Hover over me!” in light purple. When a player hovers their mouse over the text, the message “This is the hover text!” will be displayed in a tooltip.
The `contents` field can also contain a JSON object or array to format the hover text:
/tellraw @a {“text”:”Hover over me!”, “color”:”light_purple”, “hoverEvent”:{“action”:”show_text”, “contents”:[{“text”:”This is “, “color”:”white”}, {“text”:”formatted “, “bold”:true}, {“text”:”hover text!”, “color”:”green”}]}}
#### Showing an Item
To display information about an item when a player hovers over the text, use the `show_item` action. The `contents` property should be a JSON object containing the `id` and `count` of the item.
/tellraw @a {“text”:”Hover over me to see a Diamond!”, “color”:”gold”, “hoverEvent”:{“action”:”show_item”, “contents”:{“id”:”minecraft:diamond”, “count”:1}}}
This command will display the text “Hover over me to see a Diamond!” in gold. When a player hovers their mouse over the text, a tooltip will display information about a diamond item. You can also specify NBT data for the item using the `tag` field.
/tellraw @a {“text”:”Hover over me to see a named Diamond!”, “color”:”gold”, “hoverEvent”:{“action”:”show_item”, “contents”:{“id”:”minecraft:diamond”, “count”:1, “tag”:{“display”:{“Name”:”{\”text\”:\”Shiny Diamond\”}”}}}}}}
#### Showing an Entity
To display information about an entity when a player hovers over the text, use the `show_entity` action. The `contents` property should be a JSON object containing the `type` and `id` of the entity. The `id` is the UUID of the entity.
/tellraw @a {“text”:”Hover over me to see a pig!”, “color”:”pink”, “hoverEvent”:{“action”:”show_entity”, “contents”:{“type”:”minecraft:pig”, “id”:”00000000-0000-0000-0000-000000000000″, “name”:”Piggy”}}}
**Important:** The UUID (`id`) used in the above example is a placeholder. To display information about a *specific* entity, you need to obtain its actual UUID. Since you can’t get a UUID before the entity exists, this is best used with summoned entities that you can track.
Since the name is optional in the `show_entity` action, you might consider using the `selector` element instead.
### Translate
The `translate` component is used to display text based on Minecraft’s translation keys. This allows your messages to automatically adapt to the player’s selected language.
/tellraw @a {“translate”:”chat.type.emote”, “with”: [“Steve”, “is happy”]}
This command will display a message similar to “* Steve is happy” using the `chat.type.emote` translation key. The `with` array provides arguments to be inserted into the translated text.
### Score
The `score` component displays a player’s score from a specific objective. This is useful for creating scoreboards or displaying player statistics in chat.
Before using the `score` component, you need to create an objective:
/scoreboard objectives add Deaths deathCount Deaths
Then, you can use the `score` component in a `tellraw` command:
/tellraw @a [{“text”:”Steve has died “}, {“score”:{“name”:”Steve”, “objective”:”Deaths”}}, {“text”:” times.”}]
This command will display a message showing Steve’s current death count.
### Selector
The `selector` component displays the names of entities that match a given target selector. This is useful for listing online players or displaying information about nearby entities.
/tellraw @a [{“text”:”Players online: “}, {“selector”:”@a”}]
This command will display a message listing all players currently online.
### Keybind
The `keybind` component displays the name of a keybind as defined in the player’s options. This is useful for providing instructions that involve specific keys.
/tellraw @a [{“text”:”Press “}, {“keybind”:”key.forward”}, {“text”:” to move forward.”}]
This command will display a message instructing the player to press their forward key.
### NBT
The `nbt` component allows you to display NBT (Named Binary Tag) data from an entity, block entity, or storage. This is an advanced feature that requires a good understanding of NBT data structures.
To display the name of an item in a player’s inventory, you can use the following command:
/tellraw @a {“nbt”:”SelectedItem.tag.display.Name”, “entity”:”@p”}
This command will display the name of the item the nearest player is currently holding. It assumes the item has a custom name stored in its NBT data. You can also display NBT data from a block entity or a storage.
## Practical Examples of `tellraw`
Here are some practical examples of how you can use the `tellraw` command in your Minecraft worlds:
### Welcome Message
Create a custom welcome message for new players joining your server:
/tellraw @a [{“text”:”Welcome to the server, “, “color”:”green”}, {“selector”:”@p”, “color”:”yellow”}, {“text”:”! Type /help for a list of commands.”, “color”:”green”}]
This command will greet the player by name and provide a helpful tip.
### Interactive Tutorial
Create an interactive tutorial that guides players through a specific task:
/tellraw @a [{“text”:”Step 1: Find some wood. “, “color”:”aqua”}, {“text”:”Click here for a hint!”, “color”:”blue”, “underlined”:true, “clickEvent”:{“action”:”suggest_command”, “value”:”Look for trees!”}}]
This command will provide a step-by-step instruction and offer a hint if the player needs help.
### Server Announcement
Announce important events or updates to all players on the server:
/tellraw @a [{“text”:”Attention! “, “color”:”red”, “bold”:true}, {“text”:”The server will restart in 5 minutes. Please save your progress.”, “color”:”white”}]
This command will display a clear and concise announcement to all players.
### Item Display
Display information about a specific item in chat:
/tellraw @a [{“text”:”This is a “, “color”:”white”}, {“text”:”Diamond Sword”, “color”:”aqua”, “hoverEvent”:{“action”:”show_item”, “contents”:{“id”:”minecraft:diamond_sword”, “count”:1}}}]
This command will display the name of the item and show its tooltip when the player hovers over it.
## Tips and Best Practices
* **Use a JSON validator:** Before using a `tellraw` command in your world, validate your JSON code using an online validator to ensure it is properly formatted.
* **Escape special characters:** Remember to escape special characters like double quotes (`”`) and backslashes (`\`) in your JSON code.
* **Keep it concise:** While `tellraw` is powerful, try to keep your messages concise and easy to read.
* **Use color sparingly:** Avoid using too many colors, as it can make the text difficult to read. Stick to a consistent color scheme.
* **Test thoroughly:** Always test your `tellraw` commands in a test environment before using them in your main world.
* **Use functions:** For complex messages, consider using Minecraft functions to store and reuse your `tellraw` commands.
* **Be mindful of character limits:** There are character limits to chat messages, though these are quite high. Extremely long messages may be truncated or cause issues.
## Common Errors and Troubleshooting
* **Invalid JSON:** This is the most common error. Double-check your JSON syntax, making sure all brackets, braces, and quotes are properly matched and escaped.
* **Invalid color name:** Make sure you are using valid color names (e.g., `red`, `blue`, `green`).
* **Invalid item ID:** Double-check the item ID in your `show_item` hover events.
* **Target selector errors:** Ensure your target selectors are correctly formatted and selecting the intended entities.
* **Permissions issues:** If a player is unable to run a command triggered by a `clickEvent`, make sure they have the necessary permissions.
## Conclusion
The `tellraw` command is a versatile and powerful tool that can significantly enhance the interactivity and presentation of your Minecraft worlds. By mastering its syntax and features, you can create engaging welcome messages, interactive tutorials, custom GUIs, and much more. This comprehensive guide has provided you with the knowledge and examples you need to start using the `tellraw` command effectively. Experiment with different combinations of text, formatting, click events, and hover events to create unique and captivating experiences for your players. Happy crafting!