Im trying to make a plugin for fun where if a Special Zombie named "Life" died the game would kill the player. But there isnt any way i know of to check for a mob dying. How would i do that?
Pre-Death: PHP: public function onDamage(EntityDamageEvent $event){ if(($zombie = $event->getEntity()) instanceof Zombie && $zombie->getNamedTag() === "Life" && $event->getDamage() >= $zombie->getHealth()){ //Pre death. }} Post-death: PHP: public function onDeath(EntityDeathEvent $event){ if(($zombie = $event->getEntity()) instanceof Zombie && $zombie->getNamedTag() === "Life"){ //Post death. }}
Make sure you handle pre-death at the appropriate priority. If you are not cancelling the event or otherwise modifying it, make sure you use the MONITOR priority with @ignoreCancelled.
yes apparently using reflectors https://github.com/pmmp/PocketMine-.../src/pocketmine/plugin/PluginManager.php#L713 https://github.com/pmmp/PocketMine-.../pocketmine/plugin/RegisteredListener.php#L92 https://github.com/pmmp/PocketMine-MP/search?utf8=✓&q=priority+&type=Code