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.