mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-16 00:00:04 +00:00
Player->setSpawn() now accepts NULL (fallback to world spawn)
This commit is contained in:
parent
c0af05fcad
commit
8b87cf73b9
@ -949,16 +949,20 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
* Sets the spawnpoint of the player (and the compass direction) to a Vector3, or set it on another world with a
|
* Sets the spawnpoint of the player (and the compass direction) to a Vector3, or set it on another world with a
|
||||||
* Position object
|
* Position object
|
||||||
*
|
*
|
||||||
* @param Vector3|Position $pos
|
* @param Vector3|Position|null $pos
|
||||||
*/
|
*/
|
||||||
public function setSpawn(Vector3 $pos) : void{
|
public function setSpawn(?Vector3 $pos) : void{
|
||||||
if(!($pos instanceof Position)){
|
if($pos !== null){
|
||||||
$world = $this->getWorld();
|
if(!($pos instanceof Position)){
|
||||||
|
$world = $this->getWorld();
|
||||||
|
}else{
|
||||||
|
$world = $pos->getWorld();
|
||||||
|
}
|
||||||
|
$this->spawnPosition = new Position($pos->x, $pos->y, $pos->z, $world);
|
||||||
}else{
|
}else{
|
||||||
$world = $pos->getWorld();
|
$this->spawnPosition = null;
|
||||||
}
|
}
|
||||||
$this->spawnPosition = new Position($pos->x, $pos->y, $pos->z, $world);
|
$this->networkSession->syncPlayerSpawnPoint($this->getSpawn());
|
||||||
$this->networkSession->syncPlayerSpawnPoint($this->spawnPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSleeping() : bool{
|
public function isSleeping() : bool{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user