This virion was developed to streamline the boilerplate code required to send sounds by their string names using PlaySoundPacket.
It supports implementations of the Sound interface that can be used with World::addSound(),
and also provides utility methods for sending packets directly.
use pocketmine\math\Vector3;
use pocketmine\world\World;
use kim\present\utils\playsound\PlaySound;
function sendLevelUpSound(World $world, Vector3 $vec) : void{
$world->addSound($vec, new PlaySound("random.levelup"));
}use pocketmine\math\Vector3;
use pocketmine\player\Player;
use kim\present\utils\playsound\PlaySound;
function sendLevelUpSound(Player $player, Vector3 $vec) : void{
$player->getNetworkSession()->sendDataPacket(
PlaySound::createPacket($vec, "random.levelup")
);
}use pocketmine\math\Vector3;
use pocketmine\player\Player;
use kim\present\utils\playsound\PlaySound;
function sendLevelUpSound(Player $player, Vector3 $vec) : void{
PlaySound::sendTo($player, "random.levelup");
}use pocketmine\math\Vector3;
use pocketmine\world\World;
use kim\present\utils\playsound\VanillaPlaySounds;
function sendLevelUpSound(World $world, Vector3 $vec) : void{
$world->addSound($vec, VanillaPlaySounds::LEVELUP());
}See Official Poggit Virion Documentation
Distributed under the MIT. See LICENSE for more information