Hello, I need to know if there is a way to specify the type of projectile in the ProjectileHitEvent, how to specify that the projectile is an arrow, and that when specifying the arrow, maybe with: "if(){", only when hitting the player with the arrow thrown you an effect for example regeneration.
okay so the most "non hacky" way would to be first: register an projectile class with a different name add a variable which determine it's effect second: on the projectile hit event you can check the class of the projectile that just hit the player you do this by if $projectile instanceof CustomArrow and switch ($customArrow->effectID) (or even better the ID is also the ID of the potion effect) and then applying it to player
Thank you for your help, but when you throw the arrow to the player and when you hit it does not give the effect. I did it well? PHP: public function onProjectileHit(ProjectileHitEvent $event, Projectile $projectile){ $customarrow = $event->getEntity("ARROW"); $player = $event->getPlayer(); $arroweffect = Effect::getEffect(10); if($projectile instanceof CustomArrow) { $customarrow->addEffect(new EffectInstance($arroweffect, 999, 999)); } }
because your event isnt fired events are only fired when: the function access is public argument must only be one class that is an instance of event your function failed that check so no matter what you do nothing will happen you need to CHECK whatever that hits a player is a custom arrow, if it is apply an effect