How to /execute a command at an entity's death location? (java 1.13+)
First summon a Zombie with a tag:
summon zombie ~ ~1 ~ {Tags:["zo"]}
Then summon an armor stand that is invisible, has no gravity, and is a marker, that as well has a tag:
summon minecraft:armor_stand ~ ~1 ~ {NoGravity:1,Invisible:1,Marker:1,Tags:["as"]}
In a repeating command block tp the armorstand to the tagged zombie:
tp @e[type=minecraft:armor_stand,tag=as] @e[type=husk,tag=zo,limit=1]
Then for the tnt part.
You need a repeating command block that is powered by a Redstone block next to it with the command:
execute unless entity @e[tag=zo] run setblock ~1 ~ ~ air
After this block there should be a chain block that will summon the tnt, this block should be chain
, conditional
, and always active
:
execute at @e[type=minecraft:armor_stand,tag=as] run summon tnt
The first execute
command executes only if there are no entities with the tag: zo, then removes its source block. The second executes only if the first one succeeds and summons tnt at the location of the armor stand. You can add an additional conditional
command block afterward to remove the armor stand. And when summoning
the two entities you can put that in a command blockchain as well, here you could add the Redstone block that activates the execute command chain.