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 that can be set/changed without using this method
You can set the following item properties in a direct command without having to use this method:
- Default potion effects: Potions can be given as one of the default potions available in the Creative Inventory using data values.
- CanPlaceOn and CanDestroy: If you want to give an item with these properties alone, you can simply use
/give with the JSON components.
Properties you can set/change with this method
The following properties can be changed within the game using this method:
- 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.
- 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 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.
- Unbreakable (won't display on tooltip but still takes effect)
- Enchantments that an anvil is unable to apply to an item
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 suggest an edit so I can add to this post!
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!