pocketmine\level\Level::addSound PHP Method

addSound() public method

public addSound ( Sound $sound, array $players = null )
$sound pocketmine\level\sound\Sound
$players array
    public function addSound(Sound $sound, array $players = null)
    {
        $pk = $sound->encode();
        if ($players === null) {
            if ($pk !== null) {
                if (!is_array($pk)) {
                    $this->addChunkPacket($sound->x >> 4, $sound->z >> 4, $pk);
                } else {
                    foreach ($pk as $e) {
                        $this->addChunkPacket($sound->x >> 4, $sound->z >> 4, $e);
                    }
                }
            }
        } else {
            if ($pk !== null) {
                if (!is_array($pk)) {
                    Server::broadcastPacket($players, $pk);
                } else {
                    $this->server->batchPackets($players, $pk, false);
                }
            }
        }
    }

Usage Example

コード例 #1
0
ファイル: Arena.php プロジェクト: ChiefArtz/SurvivalGames
 public function startGame()
 {
     $this->game = 2;
     $msg = Messages::getMsg("started", ["%NAME", $this->name]);
     $sound = new AnvilUseSound(new Vector3());
     foreach ($this->players as $p) {
         /** @var Player $pl */
         $pl = $p["ins"];
         $pl->sendMessage($msg);
         $sound->setComponents($pl->x, $pl->y, $pl->z);
         $this->level->addSound($sound, [$pl]);
     }
 }
Level