mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-23 11:26:37 +00:00
Fixed player spawnpoints glitching and not saving
This commit is contained in:
parent
080b35bf53
commit
03826d9cbc
@ -1849,8 +1849,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
protected function completeLoginSequence(){
|
||||
parent::__construct($this->level, $this->namedtag);
|
||||
|
||||
if(!$this->hasValidSpawnPosition() and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName((string) $this->namedtag["SpawnLevel"])) instanceof Level){
|
||||
if(!$this->hasValidSpawnPosition()){
|
||||
if(isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName((string) $this->namedtag["SpawnLevel"])) instanceof Level){
|
||||
$this->spawnPosition = new WeakPosition($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
|
||||
}else{
|
||||
$this->spawnPosition = WeakPosition::fromObject($this->level->getSafeSpawn());
|
||||
}
|
||||
}
|
||||
|
||||
$spawnPosition = $this->getSpawn();
|
||||
@ -3754,10 +3758,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
if($this->hasValidSpawnPosition()){
|
||||
$this->namedtag["SpawnLevel"] = $this->spawnPosition->getLevel()->getFolderName();
|
||||
$this->namedtag["SpawnX"] = (int) $this->spawnPosition->x;
|
||||
$this->namedtag["SpawnY"] = (int) $this->spawnPosition->y;
|
||||
$this->namedtag["SpawnZ"] = (int) $this->spawnPosition->z;
|
||||
$this->namedtag->SpawnLevel = new StringTag("SpawnLevel", $this->spawnPosition->getLevel()->getFolderName());
|
||||
$this->namedtag->SpawnX = new IntTag("SpawnX", (int) $this->spawnPosition->x);
|
||||
$this->namedtag->SpawnY = new IntTag("SpawnY", (int) $this->spawnPosition->y);
|
||||
$this->namedtag->SpawnZ = new IntTag("SpawnZ", (int) $this->spawnPosition->z);
|
||||
}
|
||||
|
||||
foreach($this->achievements as $achievement => $status){
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\command\defaults;
|
||||
use pocketmine\command\Command;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\utils\TextFormat;
|
||||
@ -70,8 +71,8 @@ class SpawnpointCommand extends VanillaCommand{
|
||||
if(count($args) === 4){
|
||||
if($level !== null){
|
||||
$pos = $sender instanceof Player ? $sender->getPosition() : $level->getSpawnLocation();
|
||||
$x = (int) $this->getRelativeDouble($pos->x, $sender, $args[1]);
|
||||
$y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, 128);
|
||||
$x = $this->getRelativeDouble($pos->x, $sender, $args[1]);
|
||||
$y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, Level::Y_MAX);
|
||||
$z = $this->getRelativeDouble($pos->z, $sender, $args[3]);
|
||||
$target->setSpawn(new Position($x, $y, $z, $level));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user