PHP: public function onDamage(EntityDamageEvent $event) { $victim = $event->getEntity(); $cause = $event->getCause(); if($cause == EntityDamageEvent::PROJECTILE){ if($victim instanceof Player){ $killer = $event->getDamager(); I dont know if Im even close. Am I correct on this? I know I have to check if the player was hit by a projectile get the victim and add a desired debuff to him but can you guys help me? Im stuck dont know if this is close to right
If the cause is EntityDamageEvent::CAUSE_PROJECTILE, you'll need to handle the next step in two divisions. PHP: //if cause = EntityDamageEvent::CAUSE_PROJECTILE$killer = null;if($event instanceof EntityDamageByChildEntityEvent){ $projectile = $event->getChild(); $killer = $event->getDamager();}else{ $projectile = $event->getDamager();}if($projectile instanceof Snowball){//pocketmine\entity\projectile\Snowball //...} Yes, $killer can be null. It's null if the killer launched the projectile and quit the game, and the projectile later hits another entity.