mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Extract mandatory parameters into constructor parameters
the goal is obviously to ditch NBT entirely here, but there's more work to be done before that becomes possible.
This commit is contained in:
@ -267,7 +267,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
$this->networkSession = $session;
|
||||
$this->playerInfo = $playerInfo;
|
||||
$this->authenticated = $authenticated;
|
||||
$this->skin = $this->playerInfo->getSkin();
|
||||
|
||||
$this->username = $username;
|
||||
$this->displayName = $this->username;
|
||||
@ -282,16 +281,11 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
|
||||
$namedtag = $this->server->getOfflinePlayerData($this->username); //TODO: make this async
|
||||
|
||||
$spawnReset = false;
|
||||
|
||||
if($namedtag !== null and ($world = $this->server->getWorldManager()->getWorldByName($namedtag->getString("Level", ""))) !== null){
|
||||
/** @var float[] $pos */
|
||||
$pos = $namedtag->getListTag("Pos")->getAllValues();
|
||||
$spawn = new Vector3($pos[0], $pos[1], $pos[2]);
|
||||
$spawn = EntityFactory::parseLocation($namedtag, $world);
|
||||
}else{
|
||||
$world = $this->server->getWorldManager()->getDefaultWorld(); //TODO: default world might be null
|
||||
$spawn = $world->getSafeSpawn();
|
||||
$spawnReset = true;
|
||||
$world = $this->server->getWorldManager()->getDefaultWorld();
|
||||
$spawn = Location::fromObject($world->getSafeSpawn(), $world);
|
||||
}
|
||||
|
||||
//load the spawn chunk so we can see the terrain
|
||||
@ -300,20 +294,13 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
$this->usedChunks[World::chunkHash($spawn->getFloorX() >> 4, $spawn->getFloorZ() >> 4)] = UsedChunkStatus::NEEDED();
|
||||
|
||||
if($namedtag === null){
|
||||
$namedtag = EntityFactory::createBaseNBT($spawn);
|
||||
$namedtag = new CompoundTag();
|
||||
|
||||
$namedtag->setByte("OnGround", 1); //TODO: this hack is needed for new players in-air ticks - they don't get detected as on-ground until they move
|
||||
//TODO: old code had a TODO for SpawnForced
|
||||
|
||||
}elseif($spawnReset){
|
||||
$namedtag->setTag("Pos", new ListTag([
|
||||
new DoubleTag($spawn->x),
|
||||
new DoubleTag($spawn->y),
|
||||
new DoubleTag($spawn->z)
|
||||
]));
|
||||
}
|
||||
|
||||
parent::__construct($world, $namedtag);
|
||||
parent::__construct($spawn, $this->playerInfo->getSkin(), $namedtag);
|
||||
|
||||
$ev = new PlayerLoginEvent($this, "Plugin reason");
|
||||
$ev->call();
|
||||
|
Reference in New Issue
Block a user