Your dreams aren't crushed quite yet. Although it may be true that NBT is inaccessible from commands, there is still a workaround for what you want to do!
Here's a handy workaround that lets you give items with custom names and enchantments.
My plan is:
- Place the item you want to give in a chest.
- On command, clone the chest to the player's location.
destroy mode to destroy the chest, causing it to drop all its items on the player.
So to do this, you're going to need to place a chest in a template location, manually prepare your item, and place it into the chest. Here is a list of all available and unavailable properties to customize your item:
Properties you can set/change
The following properties can be changed within the game:
- Custom name: Take your item to an anvil. Use the anvil’s rename form to change the item name. Instead of using raw JSON text, use formatting codes to stylize the item name.
- Some enchantments: Get an enchanted book and combine it with your item in an anvil. You may also use
/enchant while holding the item in your main hand. You may not exceed the maximum enchantment level, and you may not enchant items that don't make sense with that enchantment (so no enchanting a fish with Knockback X), but you can use an NBT editor—see below.
- Default potion effects: Potions can be given as one of the default potions available in the Creative Inventory using data values, and do not require this workaround to be given. See these instructions for what to do.
However, if you need to use this in conjunction with more of these properties, follow the instructions in the linked post, then come back here.
- CanPlaceOn and CanDestroy: If you want to give an item with these properties alone, you can simply use
/give with the JSON components
can_destroy, without going through all this extra work. But if you want to combine this with some of these other customization methods, follow the instructions in the linked post, then come back here.
- Filled maps: To give a filled map with custom scale/regions/ to a player, get an empty map yourself, bring it to the region, and activate it. Then place the filled map in the chest. This method is also required to give an empty locator map, because the locator/non-locator data is stored in NBT.
Properties that require one-time use of an NBT editor to be set/changed
The following properties can be changed through one-time use of an NBT editor. Follow these instructions to modify any of the below listed properties, and place the item in the chest. The below commands will then work to give an exact copy of the item, even with some properties changed, without requiring use of an NBT editor ever again.
- Enchantments applied to items that cannot normally receive that enchantment
- Enchantments that exceed the maximum enchantment level
Properties you cannot set/change
These are item tags that exist in Java Edition, but the matching NBT tag in Bedrock Edition has not been discovered, or is nonexistent. Feel free to tinker with the NBT tags in an editor, and if you can find any new NBT tags, please ping me in the Minecraft chatroom so I can add to this post!
- Custom potion effects
Now let's create the command chain we'll be using. Place an impulse command chain of 4 blocks.
Choose the command chain that best suits you.
To give item to a player
Tell the player to clone the chest to their position.
execute @p[name=THE_PLAYER_TO_TARGET] ~ ~ ~ clone Tx Ty Tz Tx Ty Tz ~ ~ ~
Tz with the template location in both coordinate specifications.
Tell the player to set the block to air and destroy the chest.
execute @p[name=THE_PLAYER_TO_TARGET] ~ ~ ~ setblock ~ ~ ~ air destroy
Kill the chest.
To summon item on the ground:
Clone the chest.
clone Tx Ty Tz Tx Ty Tz Rx Ry Rz
T: Template location.
R: Target location.
Set the chest to air and destroy it.
setblock Rx Ry Rz air destroy
Kill the chest.
kill @e[type=item, name=chest]
While this trick is handy, sadly, I cannot claim ownership of it. I discovered it in a map in Minecraft: Education Edition, from the We Are the Rangers library. I saw it as part of a task in the map, and while looking in the commands, it was too good to not post here. Thank you to the Minecraft Education Edition team at Microsoft for creating such awesome maps!