Minecraft Blogs / Article

[Discontinued] [C|T #4] JSON - /tellraw, /title, books and signs!

  • 1,286 views, 1 today
  • 8
  • 4
  • 1
Bertiecrafter's Avatar Bertiecrafter
Retired Moderator
Level 70 : Legendary Engineer
775

This series is discontinued. Have a look at my new series about data packs (1.13+).


Before we start, I would recommend you taking a look at [C|BT #3] Data tags to get a basic understanding of keys and values.
Also knowing how to use commands is required, I recommend to take a look at [C|T #1] The basics first.

During this blog, keys will be used that you can find on this page:
http://minecraft.gamepedia.com/Commands#Raw_JSON_Text

Books, signs, /tellraw and /title have data tag keys that allow you to define their text, using JSON. This makes it possible to make coloured text in books and on signs as well as on the screen.
Examples will be made with the command: /tellraw @a {}
The Difference

Up to 1.8, /tellraw used non-strict JSON. This means that you don't have to quote keys or one word values:
/tellraw @a {text:hey,color:green} or /tellraw @a {text:"Hello there!",color:red}

From 1.9 and up, /tellraw uses the strict JSON format. This means that you do have to use quotes everywhere:
/tellraw @a {"text":"hey","color":"green"} or /tellraw @a {"text":"Hello there!","color":"red"}

In any version, data tags (the ones that define properties of entities) don't need to be quoted anywhere.

In any version, when you combine json and data tags, the json is usually a compound formatted as string. This happens with giving yourself signs and books, but also placing a sign. In this case, you need to "escape" all quotes inside with a \. This way mc knows that the first quote is the beginning of the JSON and the last quote is the end of the JSON.
The JSON inside is non-strict, you don't have to quote keys or one word values.

/setblock ~ ~ ~ standing_sign 0 {Text1:"{text:hey,color:green}",Text2:"{text:\"Hello there!\",color:red}"}

You probably know the text and the color keys by now, let's talk about the others.
Extra

The extra key is a list of compounds, that allow you to change format in one JSON command:
/tellraw @a {"text":"Hello ","color":"green","extra":[{"text":"world","color":"gold"},{"text":"!","color":"red"}]}
clickEvent

This key has a compound as value. The compound consists of an action and a value key. Those keys use strings for their values.
/tellraw @a {"text":"Click here!","clickEvent":{"action":"run_command","value":"/kill"}}

Possible actions:
open_url, twitch_user_info, run_command, change_page, suggest_command
The url has to have the preceding http(s)://www. and the run or suggest_command actions need the /.
Unlike the insertion key that will activate when a text is shift clicked, the suggest_command key inside clickEvent will replace the text that's already in the chatbar.
A command used as value for the run_command key will only execute if the player has the right permissions. Some commands require the player to be an operator (/op player).
hoverEvent

This works the same as the clickEvent one, but these ones trigger when you hover on top of a button.
Possible actions (all quotes inside values need to be escaped with a \ and the entire tag needs to be quoted):
show_text - Just like /tellraw, JSON text
show_item - Contains a compound of the following keys: id, Damage, tag
show_achievement - The value is "achievement." with the statistic name of that achievement added to it, click here!
show_entity - Contains a compound of the following keys: type, name, id
score

You can also display a scoreboards objective with the "score" key.
This key takes a compound as value, with the keys name and objective. Those keys take strings as values.
name is the selector (@a, @p etc. or names) or use * to select the person that gets the text (with /tellraw).
objective is the name of the scoreboard objective.

E.g: /tellraw @a {"score":{"name":"*","objective":"Health"}}

Those weren't the only keys, look for all the keys on the wikipage (look above for a link).
Thanks for reading!

[Discontinued] [C|T #4] JSON - /tellraw, /title, books and signs!
[Discontinued] [C|T #4] JSON - /tellraw, /title, books and signs!
My Server: GIBI
[Discontinued] [C|T #4] JSON - /tellraw, /title, books and signs!
Click the banner for more info!
Tags

2 Update Logs

Update #2 : by Bertiecrafter 02/01/2017 10:34:17 amFeb 1st, 2017

Made things clearer, removed mistakes and made this blog part of the CBT series
LOAD MORE LOGS

Create an account or sign in to comment.

1
02/01/2017 10:45 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Thank you pettyGamingHD, camo_scout, techboy04, catmelonhat, Jennpay and Draver10 for the diamonds! :D
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome