Basically I want the player who shot the arrow to get a ding sound if it hits a player. I've seen another thread but it wasn't really answered. If possible, can I get code with explanations? PHP: public function ding(EntityDamageEvent $e){ if($e instanceof EntityDamageByEntityEvent && $e->getDamager() === Arrow){ //I have no idea what I'm doing }}
you play a sound to the player using which just plays a sound on the player's level to the player only $player->getLevel()->addSound(new AnvilFallSound($player), [$player]); i am not very certain about this but damager might be the one who shoot the arrow as for how to ensure it's an arrow i am not certain either
You can play sounds by using: PHP: /** * @var Player $player * @param Sound $sound * @param Player $player */$player->getLevel()->addSound(new ClickSound($player), $player); You can find a list of sounds here. Also, change the === in $e->getDamager() === Arrow with instanceof. Now your code should play ClickSound when you get hit by an arrow.