当前位置: 首页>>代码示例>>PHP>>正文


PHP Player::getViewers方法代码示例

本文整理汇总了PHP中pocketmine\Player::getViewers方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getViewers方法的具体用法?PHP Player::getViewers怎么用?PHP Player::getViewers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\Player的用法示例。


在下文中一共展示了Player::getViewers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: launch

 public function launch(Player $player)
 {
     $dir = $player->getDirectionVector();
     $frontPos = $player->add($dir->multiply(1.1));
     $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $frontPos->x), new Double("", $frontPos->y + $player->getEyeHeight()), new Double("", $frontPos->z)]), "Motion" => new Enum("Motion", [new Double("", $dir->x), new Double("", $dir->y), new Double("", $dir->z)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]);
     $f = $this->f;
     $launched = Entity::createEntity($this->getEntityName(), $player->chunk, $nbt);
     $launched->setMotion($launched->getMotion()->multiply($f));
     if ($launched instanceof Projectile) {
         $player->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($launched));
         if ($projectileEv->isCancelled()) {
             $launched->kill();
         } else {
             $launched->spawnToAll();
             $player->level->addSound(new LaunchSound($player), $player->getViewers());
         }
     } else {
         $launched->spawnToAll();
     }
 }
开发者ID:kiyoshi-kurosaki,项目名称:ClearSky,代码行数:20,代码来源:Launchable.php

示例2: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     //fix for usage in Level->addSound, possible memory leak
     if ($player instanceof Player) {
         $players = $player->getViewers();
     } else {
         $players = null;
     }
     //fix for possible memory leak, limited addSound call
     if ($this->soundAdded == true) {
         return true;
     }
     switch ($this->downSideId) {
         case self::GLASS:
         case self::GLOWSTONE:
             $this->getLevel()->addSound(new NoteblockSound($this, NoteblockSound::INSTRUMENT_CLICK, $this->getStrength()), $players);
             $this->soundAdded = true;
             break;
         case self::SAND:
         case self::GRAVEL:
             $this->getLevel()->addSound(new NoteblockSound($this, NoteblockSound::INSTRUMENT_TABOUR, $this->getStrength()), $players);
             $this->soundAdded = true;
             break;
         case self::WOOD:
             $this->getLevel()->addSound(new NoteblockSound($this, NoteblockSound::INSTRUMENT_BASS, $this->getStrength()), $players);
             $this->soundAdded = true;
             break;
         case self::STONE:
             $this->getLevel()->addSound(new NoteblockSound($this, NoteblockSound::INSTRUMENT_BASS_DRUM, $this->getStrength()), $players);
             $this->soundAdded = true;
             break;
         default:
             $this->getLevel()->addSound(new NoteblockSound($this, NoteblockSound::INSTRUMENT_PIANO, $this->getStrength()), $players);
             $this->soundAdded = true;
             break;
     }
     return true;
 }
开发者ID:ecoron,项目名称:MinionsLandPE,代码行数:38,代码来源:Noteblock.php

示例3: removePlayerIventory

 public function removePlayerIventory(Player $bp)
 {
     if ($bp != null) {
         $bp->getInventory()->setBoots(new Item(0));
         $bp->getInventory()->setChestplate(new Item(0));
         $bp->getInventory()->setHelmet(new Item(0));
         $bp->getInventory()->setLeggings(new Item(0));
         $bp->getInventory()->sendArmorContents($bp->getViewers());
         $bp->getInventory()->sendContents($bp);
         $bp->getInventory()->clearAll();
     }
 }
开发者ID:JiangsNetworkAlpha,项目名称:CaptureTheFlag,代码行数:12,代码来源:CTFGameKit.php

示例4: setGamemode

 public function setGamemode(Player $player, $gm)
 {
     if ($gm < 0 or $gm > 3 or $player->gamemode === $gm) {
         return \false;
     }
     $player->getServer()->getPluginManager()->callEvent($ev = new PlayerGameModeChangeEvent($player, (int) $gm));
     if ($ev->isCancelled()) {
         return false;
     }
     if (($player->gamemode & 0x1) === ($gm & 0x1)) {
         $player->gamemode = $gm;
         $player->sendMessage(TextFormat::DARK_AQUA . "게임모드가 변경되었습니다, " . Server::getGamemodeString($player->getGamemode()) . ".\n");
     } else {
         $player->gamemode = $gm;
         $player->sendMessage(TextFormat::DARK_AQUA . "게임모드가 변경되었습니다, " . Server::getGamemodeString($player->getGamemode()) . ".\n");
         $player->getInventory()->clearAll();
         $player->getInventory()->sendContents($player->getViewers());
         $player->getInventory()->sendHeldItem($player->getViewers());
     }
     $player->namedtag->playerGameType = new Int("playerGameType", $player->gamemode);
     $player->sendMessage(TextFormat::DARK_AQUA . "새 게임모드 적용을 위해 서버에서 킥처리됩니다.");
     $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "Kick"], [$player]), 50);
     return true;
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:24,代码来源:GameModeKick.php

示例5: spawnMods

 /**
  * Send Mods
  *
  * @param StatueModel $statue        	
  * @param Player $p        	
  * @internal param unknown $modId
  */
 public function spawnMods(StatueModel $statue, Player $p)
 {
     $pk = new AddEntityPacket();
     $pk->eid = $statue->eid;
     $pk->type = $statue->networkId;
     $pk->x = $statue->position->x;
     $pk->y = $statue->position->y;
     $pk->z = $statue->position->z;
     $pk->yaw = 0;
     $pk->pitch = 30;
     $pk->metadata = array();
     $p->dataPacket($pk);
     Server::broadcastPacket($p->getViewers(), $pk);
     $pk = new SetEntityMotionPacket();
     $pk->entities = [[$statue->eid, 0, 290, 0]];
     $p->dataPacket($pk);
     Server::broadcastPacket($p->getViewers(), $pk);
     $p->addEntityMotion($statue->eid, 64, 290, 0);
 }
开发者ID:robozeri,项目名称:SG,代码行数:26,代码来源:StatueBuilder.php


注:本文中的pocketmine\Player::getViewers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。