pocketmine\Player::setSpawn PHP Method

setSpawn() public method

Sets the spawnpoint of the player (and the compass direction) to a Vector3, or set it on another world with a Position object
public setSpawn ( Vector3 $pos )
$pos pocketmine\math\Vector3
    public function setSpawn(Vector3 $pos)
    {
        if (!$pos instanceof Position) {
            $level = $this->level;
        } else {
            $level = $pos->getLevel();
        }
        $this->spawnPosition = new Position($pos->x, $pos->y, $pos->z, $level);
        $pk = new SetSpawnPositionPacket();
        $pk->x = (int) $this->spawnPosition->x;
        $pk->y = (int) $this->spawnPosition->y;
        $pk->z = (int) $this->spawnPosition->z;
        $this->dataPacket($pk);
    }

Usage Example

Exemplo n.º 1
0
 public function setSpawnOnPlayer(Player $player)
 {
     $player->setSpawn(Settings::loginSpawn($this->getServer()));
 }
Player