How can I make a command that activates when a certain entity has been destroyed?

How can I make a command that activates when a certain entity has been destroyed? - Dirty throwing wheels in modern workshop

I'm making a map where you go around destroying ender crystals. When you destroy an ender crystal, I want a command block chain to activate. Each individual crystal has a different command block chain.

But I don't want any redstone right next to a crystal. Is there some command I can use to accomplish this?



Best Answer

There are two ways of doing this. One is easy, but has the potential to bug out. The other is a lot more complicated but can be done.

First off, you can use a testfor command to check for the endercrystal, and run a repeater from the command block directly into a NOT-gate. Be aware that redstone isn't always the most stable thing. I've had this setup bug out on me in the spawn chunks of a Spigot server before, so it carries the potential to stop working until the redstone is updated.

The second method involves using a command block to test for the entities, then setting the output to an objective through the /stats command. When the objective reaches zero, you can activate your command blocks.




Pictures about "How can I make a command that activates when a certain entity has been destroyed?"

How can I make a command that activates when a certain entity has been destroyed? - Two People Making fire
How can I make a command that activates when a certain entity has been destroyed? - Crop female in casual clothes sitting on floor and playing with adorable shetland sheepdog while spending time in modern gym
How can I make a command that activates when a certain entity has been destroyed? - From below of ethnic boy in hoodie controlling robot using panel while standing in light room





3 Deadly Command Blocks (Minecraft PE)




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Anete Lusina, Mike, Blue Bird, Vanessa Loring