1

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?

3
  • Welcome to the Arqade! There are a few things that may strengthen your question, and may in turn help you get a better answer. What have you tried, so far? what is happening when you try it, and how is this different to what you expect to happen? What research efforts have you made?
    – user228576
    Jun 21, 2021 at 5:14
  • What version are you in? 1.17+ or 1.13+
    – ginkgo
    Jun 21, 2021 at 10:38
  • @ginkgo if its not stated you can safely assume the latest release
    – Penguin
    Jun 21, 2021 at 15:40

1 Answer 1

1

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.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .