How do I combine the NBT tags from two separate commands? [duplicate]

I'm trying to create an item that can break certain blocks, but also has a colored name in 1.13.2

Here's the command I'm using.

/give iAugust minecraft:shears{display:{Name:"[{\"text\":\"Arcane Shears\",\"color\":\"aqua\",\"italic\":false,\"bold\":false}]CanDestroy:[minecraft:iron_bars]"}}

But it only has a colored name, and it can't break specific blocks.


Solution 1:

You can add multiple tags (or properties) when giving yourself an item. If you are familiar with JSON it is very similar to that.

In this example CanPlaceOn:["minecraft:melon_block"] and display:{Name:"Box"} are tags, you can add multiple tags to an item by separating it with a comma.

Therefore you can spawn the item using the following:

/give @p jukebox 1 0 {CanPlaceOn:["minecraft:melon_block"],display:{Name:"Box"}}

Solution 2:

Assuming the map is in adventure mode, all you need to do is put the minecraft:iron_bars in quotation marks (" ") and it should work.

Solution 3:

Here are the problems with your command:

  • The text for your CanDestroy tag is inside the Name tag string. That's trouble. The Name tag only accepts JSON text, and you are trying to include other NBT, which messes up the JSON text.
  • You need to put iron_bars in "s.

Here is your updated command:

/give iAugust minecraft:shears{display:{Name:"[{\"text\":\"Arcane Shears\",\"color\":\"aqua\",\"italic\":false,\"bold\":false}]"}, CanDestroy:["iron_bars"]}

In Minecraft 1.15 and above, you can simplify the whole process by putting the Name tag in single quotes ' instead of double quotes ".

/give iAugust minecraft:shears{display:{Name:'[{"text":"Arcane Shears","color":"aqua","italic":false,"bold":false}]'}, CanDestroy:["iron_bars"]}