13

I am trying to make clickable text in Minecraft in the chat box. It was used in the adventure map, "UP".

The idea is that you are given an option in the text to click, "Yes", or "No". Each word will give an output of a command.

How is this achieved?

5
  • Is this text in chat or on signs?
    – SirBenet
    Commented Apr 3, 2015 at 16:17
  • I would assume in chat, for that's the only what it is possible. Commented Apr 3, 2015 at 16:24
  • @EliasBenevedes It is also possible on signs, and books.
    – SirBenet
    Commented Apr 3, 2015 at 16:28
  • Today I Learned. Commented Apr 3, 2015 at 16:29
  • I'm sorry. I mean in chat. I have also updated my question.
    – Jake
    Commented Apr 3, 2015 at 16:34

4 Answers 4

15

You can do this using the /tellraw command. The syntax is:

/tellraw <player> <raw json message>

For example, to have a command that activates on click, try running this:

/tellraw @a {"text":"Click this!","clickEvent":{"action":"run_command","value":"/say Hello!"}}

That has a "clickEvent" of type "run_command" with a value of the command to be run. There's a lot of different things you can do with JSON: displaying scoreboard objectives, selectors, items, achievements, entities, different text formatting, etc.

Here's a more complex command with the Yes/No choice and output you wanted:

/tellraw @p ["",{"text":"Yes","color":"green","bold":"true","clickEvent":{"action":"run_command","value":"/tellraw @p {\"text\":\"Confirmed!\",\"color\":\"green\"}"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Confirm","color":"green"}]}}},{"text":"/","color":"dark_gray","bold":"false"},{"text":"No","color":"red","bold":"true","clickEvent":{"action":"run_command","value":"/tellraw @p {\"text\":\"Cancelled\",\"color\":\"red\"}"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Cancel","color":"red"}]}}}]

You may want to learn more about the raw JSON text format, or use a JSON generator.

1

The command you would use for this is:

/tellraw @p {"text":"","extra":[{"text":" Up? ","clickEvent":{"action":"run_command","value":"/tp ~ ~  ~ "}}]} 
1
  • how would the user see if it works if you teleport them to the same location?
    – BRHSM
    Commented May 30, 2017 at 9:25
0

Command to kill all players on click:

/tellraw @a {"text":"Click","clickEvent":{"action":"run_command","value":"/kill @a"}
0

This command will output a text that when clicked on the command /say Hello! will be executed

tellraw @a {"text":"Click this!","clickEvent":{"action":"run_command","value":"/say Hello!"}}
1
  • Hey, it looks like you're new here. I noticed that your answer lacked several of the formatting guidelines that we try to follow here, and could generally use some clarification. For example, what does the image have to do with your answer? Adding some text explaining this would be good. Commented May 29, 2017 at 20:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.