diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 09c88a8c3..a86a11b3d 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -214,8 +214,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** @var int */ protected $gamemode; - /** @var int */ - private $loaderId = 0; /** @var bool[] chunkHash => bool (true = sent, false = needs sending) */ public $usedChunks = []; /** @var bool[] chunkHash => dummy */ @@ -664,7 +662,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->networkSession = $session; $this->perm = new PermissibleBase($this); - $this->loaderId = Level::generateChunkLoaderId($this); $this->chunksPerTick = (int) $this->server->getProperty("chunk-sending.per-tick", 4); $this->spawnThreshold = (int) (($this->server->getProperty("chunk-sending.spawn-radius", 4) ** 2) * M_PI); @@ -3382,8 +3379,4 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ public function onBlockChanged(Vector3 $block){ } - - public function getLoaderId() : int{ - return $this->loaderId; - } } diff --git a/src/pocketmine/level/ChunkLoader.php b/src/pocketmine/level/ChunkLoader.php index 9f10e8ac1..9d3615075 100644 --- a/src/pocketmine/level/ChunkLoader.php +++ b/src/pocketmine/level/ChunkLoader.php @@ -39,14 +39,6 @@ use pocketmine\math\Vector3; */ interface ChunkLoader{ - /** - * Returns the ChunkLoader id. - * Call Level::generateChunkLoaderId($this) to generate and save it - * - * @return int - */ - public function getLoaderId() : int; - /** * @return float */ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 2ef63effc..f8dc009c9 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -91,7 +91,6 @@ use pocketmine\utils\ReversePriorityQueue; class Level implements ChunkManager, Metadatable{ private static $levelIdCounter = 1; - private static $chunkLoaderCounter = 1; public const Y_MASK = 0xFF; public const Y_MAX = 0x100; //256 @@ -280,14 +279,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 * @return int @@ -624,7 +615,7 @@ class Level implements ChunkManager, Metadatable{ } public function registerChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ, bool $autoLoad = true){ - $hash = $loader->getLoaderId(); + $hash = spl_object_id($loader); if(!isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)])){ $this->chunkLoaders[$index] = []; @@ -653,7 +644,7 @@ class Level implements ChunkManager, Metadatable{ } public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ){ - if(isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)][$hash = $loader->getLoaderId()])){ + if(isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)][$hash = spl_object_id($loader)])){ unset($this->chunkLoaders[$index][$hash]); unset($this->playerLoaders[$index][$hash]); if(count($this->chunkLoaders[$index]) === 0){