Hi, help me please with this code. PHP: public function onDeathEntity(EntityDeathEvent $event){ $entity = $event->getEntity(); $cause = $entity->getLastDamageCause(); switch($cause === null ?EntityDamageEvent::CAUSE_CUSTOM : $cause->getCause()){ case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION: case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION: $this->getLogger()->notice("Explosived entity:".$event->getEntity()->getName()); //didn't work, but killed by explosion break; }}
read commented line. PHP: $this->getLogger()->notice("Explosived entity:".$event->getEntity()->getName()); //didn't work, but killed by explosion
On my skywars server I use an entitydamagebyentity event. It checks if the damage is fatal, and if it's an instance of TNT.
There are two death events: PlayerDeathEvent and EntityDeathEvent. I only see one or the other one being triggered (but never both).