NetworkSession: Sync world spawn on world change

This commit is contained in:
Dylan K. Taylor 2021-10-04 22:51:31 +01:00
parent bb6ea8cbdc
commit f2d6059613
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -756,6 +756,11 @@ class NetworkSession{
$this->sendDataPacket(SetSpawnPositionPacket::playerSpawn($x, $y, $z, DimensionIds::OVERWORLD, $x, $y, $z));
}
public function syncWorldSpawnPoint(Position $newSpawn) : void{
[$x, $y, $z] = [$newSpawn->getFloorX(), $newSpawn->getFloorY(), $newSpawn->getFloorZ()];
$this->sendDataPacket(SetSpawnPositionPacket::worldSpawn($x, $y, $z, DimensionIds::OVERWORLD, $x, $y, $z));
}
public function syncGameMode(GameMode $mode, bool $isRollback = false) : void{
$this->sendDataPacket(SetPlayerGameTypePacket::create(TypeConverter::getInstance()->coreGameModeToProtocol($mode)));
if($this->player !== null){
@ -939,8 +944,8 @@ class NetworkSession{
$world = $this->player->getWorld();
$this->syncWorldTime($world->getTime());
$this->syncWorldDifficulty($world->getDifficulty());
$this->syncWorldSpawnPoint($world->getSpawnLocation());
//TODO: weather needs to be synced here (when implemented)
//TODO: world spawn needs to be synced here
}
}