mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Stop hardcoding chunk dimensions everywhere (#4443)
This commit is contained in:
@ -51,8 +51,8 @@ class SubChunkExplorer{
|
||||
* @phpstan-return SubChunkExplorerStatus::*
|
||||
*/
|
||||
public function moveTo(int $x, int $y, int $z) : int{
|
||||
$newChunkX = $x >> 4;
|
||||
$newChunkZ = $z >> 4;
|
||||
$newChunkX = $x >> SubChunk::COORD_BIT_SIZE;
|
||||
$newChunkZ = $z >> SubChunk::COORD_BIT_SIZE;
|
||||
if($this->currentChunk === null or $this->currentX !== $newChunkX or $this->currentZ !== $newChunkZ){
|
||||
$this->currentX = $newChunkX;
|
||||
$this->currentZ = $newChunkZ;
|
||||
@ -64,7 +64,7 @@ class SubChunkExplorer{
|
||||
}
|
||||
}
|
||||
|
||||
$newChunkY = $y >> 4;
|
||||
$newChunkY = $y >> SubChunk::COORD_BIT_SIZE;
|
||||
if($this->currentSubChunk === null or $this->currentY !== $newChunkY){
|
||||
$this->currentY = $newChunkY;
|
||||
|
||||
@ -85,7 +85,7 @@ class SubChunkExplorer{
|
||||
*/
|
||||
public function moveToChunk(int $chunkX, int $chunkY, int $chunkZ) : int{
|
||||
//this is a cold path, so we don't care much if it's a bit slower (extra fcall overhead)
|
||||
return $this->moveTo($chunkX << 4, $chunkY << 4, $chunkZ << 4);
|
||||
return $this->moveTo($chunkX << SubChunk::COORD_BIT_SIZE, $chunkY << SubChunk::COORD_BIT_SIZE, $chunkZ << SubChunk::COORD_BIT_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user