11

How do you add NBT tags to commands? I’ve tried commands that normally work in Java Edition like:

give @s minecraft:planks 30 1 {display:{Lore:["Wooden planks"]}}
give @s potion 1 0 {Potion:"minecraft:night_vision"}
give @s diamond_sword{ench:[{id:16,lvl:5}]}
give @s minecraft:stone{CanPlaceOn:["minecraft:grass","minecraft:dirt"]} 3
give @s chest{BlockEntityTag:{Items:[{id:"diamond",count:10b}]}}
summon creeper ~ ~ ~ {powered:1b,CustomName:"Powered Creeper"}
summon villager ~ ~ ~ {Offers:{Recipes:[{buy:{id:"emerald",count:5b},sell:{id:"diamond_sword"}}]}}
11

Unfortunately, this is not possible in PE or BE (Bedrock Edition) except for the "can_place_on" or "can_destroy" tag:

/give @s stone 1 0 {"can_place_on":{"blocks":["grass","dirt"]}}

This gives yourself 1 stone that can be placed on grass and dirt.

/give @s iron_shovel 1 0 {"can_destroy":{"blocks":["grass","dirt"]}}

This gives yourself 1 iron shovel that can destroy grass and dirt.

Note: The can_place_on and can_destroy tags only have an effect in Adventure Mode (like Java Edition).


1.13 Update

You can now summon entities with a name using this syntax:

summon <entityType: EntityType> [spawnPos: x y z] [spawnEvent: string] [nameTag: string]
summon <entityType: EntityType> <nameTag: string> [spawnPos: x y z]

For example, to summon a chicken named "testing":

summon chicken testing

To summon entities with names including spaces or special characters, or starting with numbers, you'll need to put the name in double quotation marks. To include " escape it: \".

The below command summons a chicken with the name "some name with spaces and "quotation marks"".

summon chicken "some name with spaces and \"quotation marks\""
| improve this answer | |
  • 6
    Hm, nice self-answered question. I usually close these questions as duplicate of some random alike question of that category, now I can use this. Thanks! – Fabian Röling Jun 22 '18 at 22:10
  • Someone said (if I understand it right) that this answer does not work anymore in the latest versions. Can you please check that and update the answer, if necessary? – Fabian Röling Feb 9 at 23:19
  • @FabianRöling I tested the above commands in 1.14.2, the latest version, and they still worked. I haven't heard of any new JSON components and I can't find anything other than that comment about them. – cherryblossom Feb 10 at 5:57
  • According to the wiki, it's "1.14.20" for some reason. And this will get pretty confusing sometimes now that the MCJava and MCBE version numbers are so similar. – Fabian Röling Feb 10 at 14:05
  • @FabianRöling I meant 1.14.20, sorry. Thanks for pointing that out. – cherryblossom Feb 10 at 20:02
5

This is only possible for the potion, the stone, and the {powered:1} section of the creeper, although the syntax is slightly different. Based on other answers here, we know that it is impossible to add NBT tags in Bedrock Edition. However, there are loopholes for the items above.

For the potion, we'll use the data integer of 5, meaning Night Vision for 3 minutes. Link here: https://www.digminecraft.com/generators/give_potion_pe.php

/give @p potion 1 5

For the stone, we can use JSON components for the abilities to place on certain items. This only works in adventure mode.

/give @s minecraft:stone 1 0 {"minecraft:can_place_on":{"blocks":["minecraft:grass","minecraft:dirt"]}}

Finally, for the powered creeper, we can utilize spawn events to make this possible in Bedrock Edition.

/summon creeper ~ ~ ~ minecraft:become_charged

I hope this helps!

| improve this answer | |

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