I need a command to kill every armor stand that has air in his head.

I tried using /kill @e[type=minecraft:armor_stand,nbt={ArmorItems:[{},{},{},{}]}] and also tried /kill @e[type=minecraft:armor_stand,nbt={ArmorItems:[{},{},{},{id:"minecraft:air"}]}]

I have armor stands with heads you can right click to pick up, but I want them to die after someone click their head.


Based on the title, here is the answer. Kill any armor stand that doesn't have a player head.

/execute as @e[type=minecraft:armor_stand] unless entity @s[type=minecraft:armor_stand,nbt={ArmorItems:[{id:"minecraft:player_head"}]}] run kill @s

But OP meant "Kill every armor stand that has an empty helmet slot" and here is the solution:

Create a scoreboard:

/scoreboard objectives add ArmorSlots dummy

In command blocks, we will do:

  • Store the armor stand's helmet slot key lenght into a scoreboard
  • Test for 0 length

By doing:

/execute as @e[type=minecraft:armor_stand] store result score @s ArmorSlots run data get entity @e[limit=1,type=minecraft:armor_stand] ArmorItems[3]
/execute as @e[type=minecraft:armor_stand] if score @s ArmorSlots matches 0 run kill @s

Where ArmorItems[x] stands for:

  • x = 0, boots
  • x = 1, legs
  • x = 2, chestplate
  • x = 3, helmet
  • That's not exactly what I want. I said air because I am summoning armor stands with blocks in their heads. An example: summon minecraft:armor_stand ~ ~ ~ {Small:1b,ArmorItems:[{},{},{},{id:"minecraft:stone",Count:1b}]}
    – Aruser_
    Nov 8 at 20:50
  • On your question it says "I have armor stands with heads you can right click to pick up" but you mean it can have anything on it, right? I'll look more into it. It is a bit of an annoying problem.
    – BunnyMerz
    Nov 8 at 21:03
  • Edited answer with right solution, @Aruser_ . Would be nice if you edited the title and question to fit your actual problem. A nice title would be: "How to kill every armor stand with an empty head slot"
    – BunnyMerz
    Nov 9 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.