I'm not sure I think i need this: ```$level = $this->getServer()->getLevelByName("world"); //test world $player = $this->getServer()->getPlayer(); //get player $sound = "pocketmine\\level\\sound\\"."AnvilSound"; $level->addSound(new $sound($player)); ``` BUT I need to find the class (if its anything wrong tell me how to add sound + class
Adding sound is pretty simple, if you wanted to do it by event, this'll do. If not you can easily take what ive shown you to make your code work. PHP: use pocketmine\level\sound\AnvilUseSound;use pocketmine\math\Vector3;$level = $event->getPlayer()->getLevel();$x = $event->getPlayer()->getX();$y = $event->getPlayer()->getY();$z = $event->getPlayer()->getZ();$pos = new Vector3($x, $y, $z);$level->addSound(new AnvilUseSound($pos));
addsound can send sound but, why don’t you use LevelSoundEventPacket? you can send plenty of sounds. Example code PHP: use pocketmine\math\Vector3;use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;$this->getServer()->getLevelByName(“worldName”)->broadcastLevelSoundEvent(new Vector3(X,Y,Z), LevelSoundEventPacket::SOUND_BOW_HIT);//you can find sound name in LevelSoundEventPacket.php//about 160 sounds are defined
please do not abuse polls polls are for when you want to know something that is better tallied in numbers
Class: PHP: use pocketmine\level\sound\FizzSound;use pocketmine\math\Vector3; Code: PHP: $player->getLevel()->addSound(new FizzSound(new Vector3($player->getX(), $player->getY(), $player->getZ())));
Packets are cumbersome to deal with when specifications are changed, but you can alleviate them by using pmmp functions, classes.