Player: reduce code duplication

back when this was just hardcoded >> 4 everywhere, nobody thought anything of it, but now it uses constants, it's easy to cross-reference and see where the duplicates are.
This commit is contained in:
Dylan K. Taylor 2021-10-26 23:02:50 +01:00
parent a7d8a598e1
commit 6d89265510
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -271,9 +271,11 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$world = $spawnLocation->getWorld(); $world = $spawnLocation->getWorld();
//load the spawn chunk so we can see the terrain //load the spawn chunk so we can see the terrain
$world->registerChunkLoader($this->chunkLoader, $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE, true); $xSpawnChunk = $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE;
$world->registerChunkListener($this, $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE); $zSpawnChunk = $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE;
$this->usedChunks[World::chunkHash($spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE)] = UsedChunkStatus::NEEDED(); $world->registerChunkLoader($this->chunkLoader, $xSpawnChunk, $zSpawnChunk, true);
$world->registerChunkListener($this, $xSpawnChunk, $zSpawnChunk);
$this->usedChunks[World::chunkHash($xSpawnChunk, $zSpawnChunk)] = UsedChunkStatus::NEEDED();
parent::__construct($spawnLocation, $this->playerInfo->getSkin(), $namedtag); parent::__construct($spawnLocation, $this->playerInfo->getSkin(), $namedtag);
} }