TransWikia.com

How to /execute a command at an entity's death location? (java 1.13+)

Arqade Asked by Face Remover on May 11, 2021

I have been creating a minigame in Minecraft for a while now and I wanted to create custom death effects for some mobs. For example, if a zombie dies, It should immediately /summon TNT at its death position. I haven’t found any information on how to do this in the newer versions (1.13+).

One Answer

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.

Correct answer by Semlan Bakelsen on May 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP