8

I am in 1.13 Pre-Release 7 trying to make a one command creation and I need an item with a specific name. The command I use is /give @p diamond_sword{display:{Name:"Sword of Power"}} and it gives my a diamond sword, but it doesn't have the name.

This is me trying the command This is me running the command.

This is the command not working This is the command not working.

2
  • 1
    1.13 has made many things JSON. I'm currently not on my computer, can you try this? /give @p diamond_sword{display:{Name:"\"text\":\"Sword of Power\""}} or maybe this: /give @p diamond_sword{display:{Name:"{\"text\":\"Sword of Power\"}"}} – Fabian Röling Jul 13 '18 at 7:19
  • THANK YOU @FabianRöling! Than means I can change the color of the text! THANK YOU AGAIN! – Unknown Jul 13 '18 at 19:14
12

In 1.13 many things are JSON that were previously just simple strings. So the syntax is now:

give @p diamond_sword{display:{Name:"{\"text\":\"Sword of Power\"}"}}

This also means that you can colour the text, make it underlined, translatable, obfuscated, etc.

With Minecraft 1.14, support for single-quoted strings has now been added. This means that you can shorten JSON strings by surrounding them in single quotes ' instead of double quotes:

give @p diamond_sword{display:{Name:'{"text":"Sword of Power"}'}}

Whenever an NBT check doesn't work like you expected, I always recommend /data get. For example in this case you can hold the item and run:

/data get entity @s SelectedItem
3
2

In 1.14 and above, putting JSON text components into NBT string tags has been made a lot easier. Instead of having to escape every " with a \, surround the entire NBT tag string with single quotes ' instead of double quotes ". This means you can freely include double quotes in your string without having to escape them. This will mean that you will need to escape every single quote though, but there will not be that many single quotes in your JSON text component unless you explicitly need them.

Note that a single-quoted string with the same text as a double quoted string count as aliases and are equivalent to each other. Single quoted strings are now the default for all NBT string tags that involve JSON text elements. This is evident because using /data get will show the Name tag as a single-quoted string, no matter whether it was set using a single or double quoted string.

Here is the 1.14 way to give yourself that sword:

/give @p diamond_sword{display:{Name:'{"text":"Sword of Power"}'}}

Notice the use of single quotes to surround the string in Name instead of using double quotes. This will make creating JSON text in NBT much easier!

1

It's /give @p diamond_sword{display:{Name:"\"Sword of Power\""}}

2
  • 1
    Thank you for your answer, it will make my commanding easier. – Unknown Mar 2 '19 at 4:37
  • Why did you just copy my answer? – Fabian Röling Dec 31 '19 at 8:03
-1

Use:

/give @p diamond_sword{display:{Name:\"text\":\"Sword of Power\"}}

or if you want red color:

/give @p diamond_sword{display:{Name:\"text\":\"Sword of Power\",\"color\":\"red\"}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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