pocketmine\entity\Human::spawnTo PHP Method

spawnTo() public method

public spawnTo ( Player $player )
$player pocketmine\Player
    public function spawnTo(Player $player)
    {
        if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) {
            $this->hasSpawned[$player->getLoaderId()] = $player;
            if (strlen($this->skin) < 64 * 32 * 4) {
                throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set");
            }
            if (!$this instanceof Player) {
                $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getName(), $this->skinId, $this->skin, [$player]);
            }
            $pk = new AddPlayerPacket();
            $pk->uuid = $this->getUniqueId();
            $pk->username = $this->getName();
            $pk->eid = $this->getId();
            $pk->x = $this->x;
            $pk->y = $this->y;
            $pk->z = $this->z;
            $pk->speedX = $this->motionX;
            $pk->speedY = $this->motionY;
            $pk->speedZ = $this->motionZ;
            $pk->yaw = $this->yaw;
            $pk->pitch = $this->pitch;
            $pk->item = $this->getInventory()->getItemInHand();
            $pk->metadata = $this->dataProperties;
            $player->dataPacket($pk);
            $this->sendLinkedData();
            $this->inventory->sendArmorContents($player);
            if (!$this instanceof Player) {
                $this->server->removePlayerListData($this->getUniqueId(), [$player]);
            }
        }
    }

Usage Example

コード例 #1
0
ファイル: Player.php プロジェクト: ZenaGamingsky/Steadfast2
 /**
  * @param Player $player
  */
 public function spawnTo(Player $player)
 {
     if ($this->spawned === true and $player->spawned === true and $this->dead !== true and $player->dead !== true and $player->getLevel() === $this->level and $player->canSee($this)) {
         parent::spawnTo($player);
     }
 }
All Usage Examples Of pocketmine\entity\Human::spawnTo