How can I make an armor slot of a player drop onto the ground?

I'm trying to make it so that when a player runs /function datapack:helmet_drop, the helmet item they are wearing drops onto the floor. How can I achieve this?


You could summon a dummy item entity and then modify that item with the data of the helmet the player is wearing, then just remove the helmet from their head slot.

Assuming you are in 1.17+ and this is being ran from a function by the player that wants to drop their helmet. (Function will only work for players with a helmet on):

  • execute at @s[nbt={Inventory:[{Slot:103b}]}] run summon minecraft:item ^ ^1.5 ^2 {Item:{id:"minecraft:leather_helmet",Count:1b},PickupDelay:32767s} (Summons dummy item at player, change the coordinates as you see fit. PickupDelay set to 32767 so players can't somehow pickup the dummy item.)
  • execute at @s[nbt={Inventory:[{Slot:103b}]}] run data modify entity @e[type=minecraft:item,nbt={Item:{id:"minecraft:leather_helmet"},PickupDelay:32767s},sort=nearest,limit=1] Item set from entity @s Inventory.[{Slot:103b}] (Modifies the data of the dummy item with the data from the helmet the player is wearing.)
  • execute at @s[nbt={Inventory:[{Slot:103b}]}] run data merge entity @e[type=minecraft:item,nbt={PickupDelay:32767s},sort=nearest,limit=1] {PickupDelay:30s} (Allows the item to now be able to be picked up.)
  • item replace entity @s[nbt={Inventory:[{Slot:103b}]}] armor.head with minecraft:air (Removes the helmet from the player's head slot.)