[SOLVED] dynamically give items tags / components like death_protection

Started by Tronche2Cake on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[SOLVED] dynamically give items tags / components like death_protection
Mon, 04/13/2026 - 11:22 (edited)

I'm trying to do something where you can take a totem's "death_protection" component and give it to any held item.

My best guess is that I'd take a look at the item and replace it with an exact copy of itself with the addition of the minecraft:death_protection={cooldown:0} tag.
 

After some research, the easiest solution seems to be the '' execute command /["_"] in the name of [_] '' block.

the command I used is:

/item modify entity @s weapon.mainhand {function:"minecraft:set_components",components:{"minecraft:death_protection":{}}}

Edited by Tronche2Cake on Mon, 04/13/2026 - 11:22