Skip to main content
Made the answer up to snuff for the high traffic it may receive if a recent duplicate is made to point to this.
Source Link
In2itivity
  • 13.2k
  • 9
  • 55
  • 99

1Solution for versions 1.16−14–1.16

An interesting workaround to change NBT of a custom item is to copy it to a chest, modify it in the chest (where it can be modified) and then use /loot in replace mode to replace the item slot.

Note: Once 1.17 fully comes out, you can replace this method with the /item command.

Outside preparation

You'll need a special loot table to make this happen. Click this link to access a data pack with the loot table that you'll need.

This loot table will cause a yellow shulker box to drop its contents instead of itself when broken with a tool with the custom tag {drop_contents:1b}.

Minecraft preparation

You'll need to first place down a yellow shulker box, and place a temporary item (like a piece of dirt) in slot 0 (upper-left corner).

Important: Ensure the shulker box is otherwise empty, and always write to it with the NBT path Items[0].

The standard location for this shulker box is (-30000000, 0, 1602).

Commands

The first step is to copy the item to the shulker box:

data modify block (x) (y) (z) Items[0] merge from entity (selector) SelectedItem

(Note, if your copy source includes the Slot tag, you'll need to use three separate commands to copy ID, Count, and tag separately.)

The second step is to modify that item, use whatever commands you want here to reference the shulker box. Here are some sample commands. Try these ones out for your first try. These commands will set the Sharpness enchantment level to the scoreboard value you specify.

data modify block (x) (y) (z) Items[0] merge value {tag:{Enchantments:[{id:"minecraft:sharpness", lvl:1s}]}}
execute store result block (x) (y) (z) Items[0].tag.Enchantments[0].lvl short 1.0 run scoreboard players get FakePlayer myObjective

Once the modification is complete, here's the magic: use /loot to replace the item in the specified slot.

loot replace entity (selector) weapon.mainhand 1 mine block (x) (y) (z) minecraft:air{drop_contents:1b}

1.16−

An interesting workaround to change NBT of a custom item is to copy it to a chest, modify it in the chest (where it can be modified) and then use /loot in replace mode to replace the item slot.

Note: Once 1.17 fully comes out, you can replace this method with the /item command.

Outside preparation

You'll need a special loot table to make this happen. Click this link to access a data pack with the loot table that you'll need.

This loot table will cause a yellow shulker box to drop its contents instead of itself when broken with a tool with the custom tag {drop_contents:1b}.

Minecraft preparation

You'll need to first place down a yellow shulker box, and place a temporary item (like a piece of dirt) in slot 0 (upper-left corner).

Important: Ensure the shulker box is otherwise empty, and always write to it with the NBT path Items[0].

The standard location for this shulker box is (-30000000, 0, 1602).

Commands

The first step is to copy the item to the shulker box:

data modify block (x) (y) (z) Items[0] merge from entity (selector) SelectedItem

(Note, if your copy source includes the Slot tag, you'll need to use three separate commands to copy ID, Count, and tag separately.)

The second step is to modify that item, use whatever commands you want here to reference the shulker box. Here are some sample commands. Try these ones out for your first try. These commands will set the Sharpness enchantment level to the scoreboard value you specify.

data modify block (x) (y) (z) Items[0] merge value {tag:{Enchantments:[{id:"minecraft:sharpness", lvl:1s}]}}
execute store result block (x) (y) (z) Items[0].tag.Enchantments[0].lvl short 1.0 run scoreboard players get FakePlayer myObjective

Once the modification is complete, here's the magic: use /loot to replace the item in the specified slot.

loot replace entity (selector) weapon.mainhand 1 mine block (x) (y) (z) minecraft:air{drop_contents:1b}

Solution for versions 1.14–1.16

An interesting workaround to change NBT of a custom item is to copy it to a chest, modify it in the chest (where it can be modified) and then use /loot in replace mode to replace the item slot.

Outside preparation

You'll need a special loot table to make this happen. Click this link to access the loot table that you'll need.

This loot table will cause a yellow shulker box to drop its contents instead of itself when broken with a tool with the custom tag {drop_contents:1b}.

Minecraft preparation

You'll need to first place down a yellow shulker box, and place a temporary item (like a piece of dirt) in slot 0 (upper-left corner).

Important: Ensure the shulker box is otherwise empty, and always write to it with the NBT path Items[0].

The standard location for this shulker box is (-30000000, 0, 1602).

Commands

The first step is to copy the item to the shulker box:

data modify block (x) (y) (z) Items[0] merge from entity (selector) SelectedItem

(Note, if your copy source includes the Slot tag, you'll need to use three separate commands to copy ID, Count, and tag separately.)

The second step is to modify that item, use whatever commands you want here to reference the shulker box. Here are some sample commands. Try these ones out for your first try. These commands will set the Sharpness enchantment level to the scoreboard value you specify.

data modify block (x) (y) (z) Items[0] merge value {tag:{Enchantments:[{id:"minecraft:sharpness", lvl:1s}]}}
execute store result block (x) (y) (z) Items[0].tag.Enchantments[0].lvl short 1.0 run scoreboard players get FakePlayer myObjective

Once the modification is complete, here's the magic: use /loot to replace the item in the specified slot.

loot replace entity (selector) weapon.mainhand 1 mine block (x) (y) (z) minecraft:air{drop_contents:1b}
added 20 characters in body
Source Link
In2itivity
  • 13.2k
  • 9
  • 55
  • 99

1.16−

An interesting workaround to change NBT of a custom item is to copy it to a chest, modify it in the chest (where it can be modified) and then use /loot in replace mode to replace the item slot.

Note: Once 1.17 fully comes out, you can replace this method with the /item command.

Outside preparation

Outside preparation

You'll need a special loot table to make this happen. Click this link to access a data pack with the loot table that you'll need.

This loot table will cause a yellow shulker box to drop its contents instead of itself when broken with a tool with the custom tag {drop_contents:1b}.

Minecraft preparation

Minecraft preparation

You'll need to first place down a yellow shulker box, and place a temporary item (like a piece of dirt) in slot 0 (upper-left corner).

Important: Ensure the shulker box is otherwise empty, and always write to it with the NBT path Items[0].

The standard location for this shulker box is (-30000000, 0, 1602).

Commands

Commands

The first step is to copy the item to the shulker box:

data modify block (x) (y) (z) Items[0] merge from entity (selector) SelectedItem

(Note, if your copy source includes the Slot tag, you'll need to use three separate commands to copy ID, Count, and tag separately.)

The second step is to modify that item, use whatever commands you want here to reference the shulker box. Here are some sample commands. Try these ones out for your first try. These commands will set the Sharpness enchantment level to the scoreboard value you specify.

data modify block (x) (y) (z) Items[0] merge value {tag:{Enchantments:[{id:"minecraft:sharpness", lvl:1s}]}}
execute store result block (x) (y) (z) Items[0].tag.Enchantments[0].lvl short 1.0 run scoreboard players get FakePlayer myObjective

Once the modification is complete, here's the magic: use /loot to replace the item in the specified slot.

/loot replace entity (selector) weapon.mainhand 1 mine block (x) (y) (z) minecraft:air{drop_contents:1b}

An interesting workaround to change NBT of a custom item is to copy it to a chest, modify it in the chest (where it can be modified) and then use /loot in replace mode to replace the item slot.

Note: Once 1.17 fully comes out, you can replace this method with the /item command.

Outside preparation

You'll need a special loot table to make this happen. Click this link to access a data pack with the loot table that you'll need.

This loot table will cause a yellow shulker box to drop its contents instead of itself when broken with a tool with the custom tag {drop_contents:1b}.

Minecraft preparation

You'll need to first place down a yellow shulker box, and place a temporary item (like a piece of dirt) in slot 0 (upper-left corner).

Important: Ensure the shulker box is otherwise empty, and always write to it with the NBT path Items[0].

The standard location for this shulker box is (-30000000, 0, 1602).

Commands

The first step is to copy the item to the shulker box:

data modify block (x) (y) (z) Items[0] merge from entity (selector) SelectedItem

(Note, if your copy source includes the Slot tag, you'll need to use three separate commands to copy ID, Count, and tag separately.)

The second step is to modify that item, use whatever commands you want here to reference the shulker box. Here are some sample commands. Try these ones out for your first try. These commands will set the Sharpness enchantment level to the scoreboard value you specify.

data modify block (x) (y) (z) Items[0] merge value {tag:{Enchantments:[{id:"minecraft:sharpness", lvl:1s}]}}
execute store result block (x) (y) (z) Items[0].tag.Enchantments[0].lvl short 1.0 run scoreboard players get FakePlayer myObjective

Once the modification is complete, here's the magic: use /loot to replace the item in the specified slot.

/loot replace entity (selector) weapon.mainhand 1 mine block (x) (y) (z) minecraft:air{drop_contents:1b}

1.16−

An interesting workaround to change NBT of a custom item is to copy it to a chest, modify it in the chest (where it can be modified) and then use /loot in replace mode to replace the item slot.

Note: Once 1.17 fully comes out, you can replace this method with the /item command.

Outside preparation

You'll need a special loot table to make this happen. Click this link to access a data pack with the loot table that you'll need.

This loot table will cause a yellow shulker box to drop its contents instead of itself when broken with a tool with the custom tag {drop_contents:1b}.

Minecraft preparation

You'll need to first place down a yellow shulker box, and place a temporary item (like a piece of dirt) in slot 0 (upper-left corner).

Important: Ensure the shulker box is otherwise empty, and always write to it with the NBT path Items[0].

The standard location for this shulker box is (-30000000, 0, 1602).

Commands

The first step is to copy the item to the shulker box:

data modify block (x) (y) (z) Items[0] merge from entity (selector) SelectedItem

(Note, if your copy source includes the Slot tag, you'll need to use three separate commands to copy ID, Count, and tag separately.)

The second step is to modify that item, use whatever commands you want here to reference the shulker box. Here are some sample commands. Try these ones out for your first try. These commands will set the Sharpness enchantment level to the scoreboard value you specify.

data modify block (x) (y) (z) Items[0] merge value {tag:{Enchantments:[{id:"minecraft:sharpness", lvl:1s}]}}
execute store result block (x) (y) (z) Items[0].tag.Enchantments[0].lvl short 1.0 run scoreboard players get FakePlayer myObjective

Once the modification is complete, here's the magic: use /loot to replace the item in the specified slot.

loot replace entity (selector) weapon.mainhand 1 mine block (x) (y) (z) minecraft:air{drop_contents:1b}
Fixed command, the loot table is different now that I updated it to the standard
Source Link
In2itivity
  • 13.2k
  • 9
  • 55
  • 99

An interesting workaround to change NBT of a custom item is to copy it to a chest, modify it in the chest (where it can be modified) and then use /loot in replace mode to replace the item slot.

Note: Once 1.17 fully comes out, you can replace this method with the /item command.

Outside preparation

You'll need a special loot table to make this happen. Click this link to access a data pack with the loot table that you'll need.

This loot table will cause a yellow shulker box to drop its contents instead of itself when broken with a tool with the custom tag {drop_contents:1b}.

Minecraft preparation

You'll need to first place down a yellow shulker box, and place a temporary item (like a piece of dirt) in slot 0 (upper-left corner).

Important: Ensure the shulker box is otherwise empty, and always write to it with the NBT path Items[0].

The standard location for this shulker box is (-30000000, 0, 1602).

Commands

The first step is to copy the item to the shulker box:

data modify block (x) (y) (z) Items[0] merge from entity (selector) SelectedItem

(Note, if your copy source includes the Slot tag, you'll need to use three separate commands to copy ID, Count, and tag separately.)

The second step is to modify that item, use whatever commands you want here to reference the shulker box. Here are some sample commands. Try these ones out for your first try. These commands will set the Sharpness enchantment level to the scoreboard value you specify.

data modify block (x) (y) (z) Items[0] merge value {tag:{Enchantments:[{id:"minecraft:sharpness", lvl:1s}]}}
execute store result block (x) (y) (z) Items[0].tag.Enchantments[0].lvl short 1.0 run scoreboard players get FakePlayer myObjective

Once the modification is complete, here's the magic: use /loot to replace the item in the specified slot.

/loot replace entity (selector) weapon.mainhand 1 mine block (x) (y) (z) stickminecraft:air{dropContentsdrop_contents:1b}

An interesting workaround to change NBT of a custom item is to copy it to a chest, modify it in the chest (where it can be modified) and then use /loot in replace mode to replace the item slot.

Note: Once 1.17 fully comes out, you can replace this method with the /item command.

Outside preparation

You'll need a special loot table to make this happen. Click this link to access a data pack with the loot table that you'll need.

This loot table will cause a yellow shulker box to drop its contents instead of itself when broken with a tool with the custom tag {drop_contents:1b}.

Minecraft preparation

You'll need to first place down a yellow shulker box, and place a temporary item (like a piece of dirt) in slot 0 (upper-left corner).

Important: Ensure the shulker box is otherwise empty, and always write to it with the NBT path Items[0].

The standard location for this shulker box is (-30000000, 0, 1602).

Commands

The first step is to copy the item to the shulker box:

data modify block (x) (y) (z) Items[0] merge from entity (selector) SelectedItem

(Note, if your copy source includes the Slot tag, you'll need to use three separate commands to copy ID, Count, and tag separately.)

The second step is to modify that item, use whatever commands you want here to reference the shulker box. Here are some sample commands. Try these ones out for your first try. These commands will set the Sharpness enchantment level to the scoreboard value you specify.

data modify block (x) (y) (z) Items[0] merge value {tag:{Enchantments:[{id:"minecraft:sharpness", lvl:1s}]}}
execute store result block (x) (y) (z) Items[0].tag.Enchantments[0].lvl short 1.0 run scoreboard players get FakePlayer myObjective

Once the modification is complete, here's the magic: use /loot to replace the item in the specified slot.

/loot replace entity (selector) weapon.mainhand 1 mine block (x) (y) (z) stick{dropContents:1b}

An interesting workaround to change NBT of a custom item is to copy it to a chest, modify it in the chest (where it can be modified) and then use /loot in replace mode to replace the item slot.

Note: Once 1.17 fully comes out, you can replace this method with the /item command.

Outside preparation

You'll need a special loot table to make this happen. Click this link to access a data pack with the loot table that you'll need.

This loot table will cause a yellow shulker box to drop its contents instead of itself when broken with a tool with the custom tag {drop_contents:1b}.

Minecraft preparation

You'll need to first place down a yellow shulker box, and place a temporary item (like a piece of dirt) in slot 0 (upper-left corner).

Important: Ensure the shulker box is otherwise empty, and always write to it with the NBT path Items[0].

The standard location for this shulker box is (-30000000, 0, 1602).

Commands

The first step is to copy the item to the shulker box:

data modify block (x) (y) (z) Items[0] merge from entity (selector) SelectedItem

(Note, if your copy source includes the Slot tag, you'll need to use three separate commands to copy ID, Count, and tag separately.)

The second step is to modify that item, use whatever commands you want here to reference the shulker box. Here are some sample commands. Try these ones out for your first try. These commands will set the Sharpness enchantment level to the scoreboard value you specify.

data modify block (x) (y) (z) Items[0] merge value {tag:{Enchantments:[{id:"minecraft:sharpness", lvl:1s}]}}
execute store result block (x) (y) (z) Items[0].tag.Enchantments[0].lvl short 1.0 run scoreboard players get FakePlayer myObjective

Once the modification is complete, here's the magic: use /loot to replace the item in the specified slot.

/loot replace entity (selector) weapon.mainhand 1 mine block (x) (y) (z) minecraft:air{drop_contents:1b}
added 71 characters in body
Source Link
In2itivity
  • 13.2k
  • 9
  • 55
  • 99
Loading
Replaced link with the officially recognized standard file for player inventory modification
Source Link
In2itivity
  • 13.2k
  • 9
  • 55
  • 99
Loading
added 2 characters in body
Source Link
In2itivity
  • 13.2k
  • 9
  • 55
  • 99
Loading
added 146 characters in body
Source Link
In2itivity
  • 13.2k
  • 9
  • 55
  • 99
Loading
Added a notice for a later version of Minecraft
Source Link
randomuser922
  • 1.1k
  • 1
  • 8
  • 20
Loading
Clarification
Source Link
In2itivity
  • 13.2k
  • 9
  • 55
  • 99
Loading
Major changes.
Source Link
In2itivity
  • 13.2k
  • 9
  • 55
  • 99
Loading
Added to answer
Source Link
randomuser922
  • 1.1k
  • 1
  • 8
  • 20
Loading
Made a tutorial on how to do it
Source Link
randomuser922
  • 1.1k
  • 1
  • 8
  • 20
Loading
Source Link
randomuser922
  • 1.1k
  • 1
  • 8
  • 20
Loading