Trying to make a sign give me diamonds if i press it with 64 stone [duplicate]
Solution 1:
Look at this particular part, which is causing the first error:
Text1:"{"text
- Minecraft reads
Text:
, and is expecting a string (surrounded with quotation marks) to follow - Minecraft reads
"
, so starts reading the string to go with Text1 (the key) - Minecraft reads
{
as the string - Minecraft reads
"
, so stops reading the string, and is now expecting a comma to start the next key-value pair, e.g:Text1:"Hello",Text2:"World"
- Minecraft finds
t
instead, so throws the unexpected token error
To fix this, you need to escape (put a backslash before) quotation marks that are part of the JSON. \"
tells Minecraft to read "
just as another character in the string, rather than stopping reading the string, as the "
is part of the JSON rather than the top-level NBTData.
Even more confusing is when you have a tellraw command, requiring JSON, within the sign's text JSON. You now need to escape the backslash itself (\\
) before the quotation mark (\"
) so that it's not read as NBTData, nor as the sign's text JSON, but as part of a string within the sign's text JSON.
Fully fixed command:
/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"[MF2]\",\"color\":\"gold\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"tellraw @a [{\\\"text\\\":\\\"[MF2] \\\",\\\"color\\\":\\\"gold\\\"},{\\\"selector\\\":\\\"@p\\\",\\\"color\\\":\\\"dark_aqua\\\"},{\\\"text\\\":\\\" is now an admin of the server!\\\",\\\"color\\\":\\\"white\\\"}]\"}}",Text3:"{\"text\":\"Click to join Admin\",\"color\":\"dark_aqua\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"scoreboard teams join admin @p\"}}"},display:{Name:"Custom Sign"}}
In the future, use a generator, or use a trigger
/scoreboard
command to set off the tellraw
command, as this can get pretty confusing and annoying to find errors in.