so I've been attempting to build a system wherein a custom zombie spawns, the player kills it, and a command block detects that death and opens an iron door by spawning a redstone block below it.

The way I've attempted to do it is the following: Hopper clock attached to the following command, which adds the tag 'trigger' to an armour stand riding a zombie:

tag @e[type=armor_stand,name=deathdetect] add trigger

Into a chain of command blocks, the first removing the trigger if the zombie is still around:

execute as @e[type=zombie,nbt={Passengers:[{id:"minecraft:armor_stand",CustomName:"\"deathdetect\""}]}] at @s anchored eyes if entity @e[type=armor_stand,name=deathdetect,distance=..20] run tag @e[type=armor_stand,name=deathdetect,distance=..20,limit=1] remove trigger

What it's then supposed to do is detect that the zombie isn't around anymore by checking if it's still got the trigger tag, before setting the block below the iron door to be a redstone block:

execute as @e[type=armor_stand,name=deathdetect,tag=trigger] at @s run setblock -111 32 43 redstone_block

and concluded with killing the armour stand with

kill @e[type=armor_stand,tag=trigger]

The issue I'm running into is when I spawn the zombie, the trigger tag is never removed from the armour stand, effectively skipping the first command block in the chain. I've constructed it so that the system is hopper clock into impulse command block into three chain blocks, but clearly I've messed something up.

For reference, this is the zombie I'm trying to spawn:

/summon zombie -110 33 40 {OnGround:0b,NoGravity:0b,Glowing:1b,CustomNameVisible:1b,PersistenceRequired:1b,NoAI:0b,Rotation:[-180F,0F],Passengers:[{id:"minecraft:armor_stand",NoGravity:1b,Invulnerable:1b,Marker:1b,Invisible:1b,NoBasePlate:1b,PersistenceRequired:1b,Tags:["is alive"],CustomName:"{\"text\":\"deathdetect\"}"}],CustomName:"{\"text\":\"Red Darknut\",\"color\":\"red\",\"bold\":true,\"underlined\":true}",HandItems:[{id:"minecraft:iron_sword",Count:1b,tag:{Unbreakable:1b}},{id:"minecraft:shield",Count:1b,tag:{Unbreakable:1b,BlockEntityTag:{Base:15,Patterns:[{Pattern:mc,Color:11},{Pattern:gru,Color:5},{Pattern:gru,Color:0},{Pattern:flo,Color:5},{Pattern:flo,Color:0},{Pattern:cbo,Color:5},{Pattern:cbo,Color:0}]}}}],HandDropChances:[0.0F,0.0F],ArmorItems:[{id:"minecraft:chainmail_boots",Count:1b,tag:{Unbreakable:1b}},{id:"minecraft:chainmail_leggings",Count:1b,tag:{Unbreakable:1b}},{id:"minecraft:chainmail_chestplate",Count:1b,tag:{Unbreakable:1b}},{id:"minecraft:chainmail_helmet",Count:1b,tag:{Unbreakable:1b}}],ArmorDropChances:[0.0F,0.0F,0.0F,0.0F]}

Any clues as to where I've gone wrong? I know for certain it's in the removal of the trigger tag, but I can't figure out exactly how to fix it.

  • Why don't you just try to make it more simple instead? Do something like giving the zombie a custom name, and just test if a zombie with that name is around. Wouldn't that be easier? – Quijibo Jun 3 '19 at 7:03
  • Which version are you in? Redstone clocks were needed for command blocks in 1.6 and before, but since then there are better solutions, like repeating command blocks or functions. – Fabian Röling Jun 3 '19 at 11:58

You could just tag the zombie instead.

/tag @e[type=zombie,distance=..10] add alive

You can use a different target selector, but make sure that only the mobs that need to be killed get that tag. This will work with multiple entities as well, where you will have to kill all of them.

And then have a command block check if a mob with the tag alive exists

/execute unless entity @e[tag=alive] run setblock <your coordinats> minecraft:redstone_block
| improve this answer | |

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.