mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Region: Change chunk offset calculation in regions to use bitmasks
I don't know why it wasn't done like this to start with. However this has not been tested yet, so this goes on a different branch for now to test.
This commit is contained in:
parent
54b23968e7
commit
4db7a7e57f
@ -340,7 +340,7 @@ class McRegion extends BaseLevelProvider{
|
||||
$this->loadRegion($regionX, $regionZ);
|
||||
$this->level->timings->syncChunkLoadDataTimer->startTiming();
|
||||
/** @noinspection PhpStrictTypeCheckingInspection */
|
||||
$chunk = $this->getRegion($regionX, $regionZ)->readChunk($chunkX - $regionX * 32, $chunkZ - $regionZ * 32);
|
||||
$chunk = $this->getRegion($regionX, $regionZ)->readChunk($chunkX & 0x1f, $chunkZ & 0x1f);
|
||||
if($chunk === null and $create){
|
||||
$chunk = new Chunk($chunkX, $chunkZ);
|
||||
}
|
||||
@ -377,7 +377,7 @@ class McRegion extends BaseLevelProvider{
|
||||
|
||||
public function isChunkGenerated(int $chunkX, int $chunkZ) : bool{
|
||||
if(($region = $this->getRegion($chunkX >> 5, $chunkZ >> 5)) !== null){
|
||||
return $region->chunkExists($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32) and $this->getChunk($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32, true)->isGenerated();
|
||||
return $region->chunkExists($chunkX & 0x1f, $chunkZ & 0x1f) and $this->getChunk($chunkX & 0x1f, $chunkZ & 0x1f, true)->isGenerated();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -183,7 +183,7 @@ class RegionLoader{
|
||||
$this->lastUsed = time();
|
||||
$chunkData = $this->levelProvider->nbtSerialize($chunk);
|
||||
if($chunkData !== false){
|
||||
$this->saveChunk($chunk->getX() - ($this->getX() * 32), $chunk->getZ() - ($this->getZ() * 32), $chunkData);
|
||||
$this->saveChunk($chunk->getX() & 0x1f, $chunk->getZ() & 0x1f, $chunkData);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user