Arqade Asked on August 24, 2021
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.
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
Correct answer by Fabian Röling on August 24, 2021
It's /give @p diamond_sword{display:{Name:""Sword of Power""}}
Answered by 7 Minireenas on August 24, 2021
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"}}
Answered by I don't want name on August 24, 2021
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!
Answered by ExpertCoder14 on August 24, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP