mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
ChunkLoader: remove getLoaderId() (take 2)
This commit is contained in:
@ -106,6 +106,7 @@ use function max;
|
||||
use function microtime;
|
||||
use function min;
|
||||
use function mt_rand;
|
||||
use function spl_object_id;
|
||||
use function strtolower;
|
||||
use function trim;
|
||||
use const INT32_MAX;
|
||||
@ -117,7 +118,6 @@ use const M_PI;
|
||||
class Level implements ChunkManager, Metadatable{
|
||||
|
||||
private static $levelIdCounter = 1;
|
||||
private static $chunkLoaderCounter = 1;
|
||||
|
||||
public const Y_MASK = 0xFF;
|
||||
public const Y_MAX = 0x100; //256
|
||||
@ -321,14 +321,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
$z = ($hash & 0xFFFFFFFF) << 32 >> 32;
|
||||
}
|
||||
|
||||
public static function generateChunkLoaderId(ChunkLoader $loader) : int{
|
||||
if($loader->getLoaderId() === 0){
|
||||
return self::$chunkLoaderCounter++;
|
||||
}else{
|
||||
throw new \InvalidStateException("ChunkLoader has a loader id already assigned: " . $loader->getLoaderId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
*
|
||||
@ -642,7 +634,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
public function registerChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ, bool $autoLoad = true){
|
||||
$loaderId = $loader->getLoaderId();
|
||||
$loaderId = spl_object_id($loader);
|
||||
|
||||
if(!isset($this->chunkLoaders[$chunkHash = Level::chunkHash($chunkX, $chunkZ)])){
|
||||
$this->chunkLoaders[$chunkHash] = [];
|
||||
@ -672,7 +664,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ){
|
||||
$chunkHash = Level::chunkHash($chunkX, $chunkZ);
|
||||
$loaderId = $loader->getLoaderId();
|
||||
$loaderId = spl_object_id($loader);
|
||||
if(isset($this->chunkLoaders[$chunkHash][$loaderId])){
|
||||
unset($this->chunkLoaders[$chunkHash][$loaderId]);
|
||||
unset($this->playerLoaders[$chunkHash][$loaderId]);
|
||||
@ -2401,7 +2393,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$this->chunkSendQueue[$index] = [];
|
||||
}
|
||||
|
||||
$this->chunkSendQueue[$index][$player->getLoaderId()] = $player;
|
||||
$this->chunkSendQueue[$index][spl_object_id($player)] = $player;
|
||||
}
|
||||
|
||||
private function sendCachedChunk(int $x, int $z){
|
||||
|
Reference in New Issue
Block a user