How do I solve 'Data tag parsing failed: Trailing data...' errors in Minecraft commands? [duplicate]

Solution 1:

I see several problems with your command. The biggest one I always see with complicated double commands like this is always special character escapement. I will get to that last as it is the most complicated. If you see three dots ..., this means I omitted data to make the problem easier to see.

  1. You have square brackets around the text line sections for the sign:
    • {Text1:"[{...}]",Text2:"[{...}]"}
    • Should be {Text1:"{...}",Text2:"{...}"}
  2. The give command has several problems:
    • \",text\" there should be no comma
    • The general structure of the give command is wrong:
      • {pages:[{"...":"..."}"}\]",title:...,author:...}
      • Should be {pages:["{"...":"..."}"],title:...,author:...}
      • You are missing a quotation mark before the first curly bracket, you have an extra curly bracket which screws up parsing, a slash before the square bracket, and a quotation mark after the square bracket.
  3. Escapement problems

Escapement

Special characters have to be escaped when inside quotation marks. In your case, you have to escape quotation marks and you have to escape slash marks.

This is very simple when things are only escaped one time: {Text1:"..."}. All special characters which are inside the Text1 quotation marks have to be escaped 1 time: Text1:"{\"text\":\"...\",\"color\":\"...\"}

It gets more complicated when you have quotation marks inside of more quotation marks. This requires double escapement. In the next example, Text2 is the first set of quotes and the click event value quotes are the second set. This requires the pages quotation marks to be double escaped.

Text2:"... \"/give @p written_book 1 0 {pages:[\\\"...\\\"] ... \" ..."

Double escapement means you need to escape once. Then escape the character and all escapement slashes a second time. " => \" => \\\"

Anything inside of the pages quotation marks requires triple escapement. All special characters have to be escaped again, this includes the slashes to escape the characters. \\\" is double escaped, there are 4 characters to escape which adds 4 slashs for a final \\\\\\\".

Finally, within pages the text requires another set of quotation marks which require quadruple escapement for anything inside. In this case the new line (\n) has a slash which needs quadruple escapement.

  • Original: \n
  • Double: \\n
  • Triple: \\\\n
  • Quadruple: \\\\\\\\n

Finally, the command:

/setblock ~ ~1 ~ wall_sign 0 replace {Text1:"{\"text\":\"*right click*\",\"color\":\"blue\"}",Text2:"{\"text\":\"Rule Book\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/give @p written_book 1 0 {pages:[\\\"{\\\\\\\"text\\\\\\\":\\\\\\\"Rule 1:Use RELEASER book to release the seeker. This book is obtained by pressing the Hiders button\\\\\\\\nRule 2:Don't use commands that weren't provided by the map\\\\\\\\nRule 3:Have fun(jk rage I'm evil HAHAHAH)\\\\\\\"}\\\"],title:Rules,author:RebornSquid}\"}}"}

Here is the command but the book is reformatted to look a little better:

/setblock ~ ~1 ~ wall_sign 0 replace {Text1:"{\"text\":\"*Right Click*\",\"color\":\"blue\"}",Text2:"{\"text\":\"Rule Book\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/give @p written_book 1 0 {pages:[\\\"{\\\\\\\"text\\\\\\\":\\\\\\\"Rule 1:Use RELEASER book to release the seeker. This book is obtained by pressing the Hiders button\\\\\\\\n\\\\\\\\nRule 2:Don't use commands that weren't provided by the map\\\\\\\\n\\\\\\\\nRule 3:Have fun\\\\\\\\n(jk rage I'm evil HAHAHAH)\\\\\\\"}\\\"],title:Rules,author:RebornSquid}\"}}"}

Building complex commands

A good point that D-Inventor brought up. When building these commands, start with a small piece of the big picture. Verify it works by testing each change in game. When verified functional, add more.

To fix your command, I completely reworked the entire command. I started by creating a functional give command. If you test your give command, it will not execute properly. Once I had the give command functioning, I created a setblock command which would set a wall sign. Then I made that setblock command add the first line of text, then the second line, then the color, then a command, then the give command. I tested the command at each step. By doing it this way, you know when errors are introduced. Just remember to note the last functioning command so you can back up if needed.

If you don't want to memorize structure, you can use generators. You could use this book editor to produce your give command and then stuff that command into this command sign generator. However, you will most likely have to modify the final command you are given as it will probably have escapement problems. The sign generator even contains a note:

Note: The sign generator is somewhat fragile. If something does not work try adding a preceding \ to your special chars.