From 6d89265510212a082f79e333a707b5aef5e5a832 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 26 Oct 2021 23:02:50 +0100 Subject: [PATCH] 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. --- src/player/Player.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/player/Player.php b/src/player/Player.php index 10265f466f..8a8ba1ce29 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -271,9 +271,11 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $world = $spawnLocation->getWorld(); //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); - $world->registerChunkListener($this, $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE); - $this->usedChunks[World::chunkHash($spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE)] = UsedChunkStatus::NEEDED(); + $xSpawnChunk = $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE; + $zSpawnChunk = $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE; + $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); }