mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
ChunkCache: explicitly check for requesting of unloaded chunk
NetworkSession will never do this, but other things might.
This commit is contained in:
parent
1d27225553
commit
37299ab804
6
src/network/mcpe/cache/ChunkCache.php
vendored
6
src/network/mcpe/cache/ChunkCache.php
vendored
@ -94,6 +94,10 @@ class ChunkCache implements ChunkListener{
|
||||
*/
|
||||
public function request(int $chunkX, int $chunkZ) : CompressBatchPromise{
|
||||
$this->world->registerChunkListener($this, $chunkX, $chunkZ);
|
||||
$chunk = $this->world->getChunk($chunkX, $chunkZ);
|
||||
if($chunk === null){
|
||||
throw new \InvalidArgumentException("Cannot request an unloaded chunk");
|
||||
}
|
||||
$chunkHash = World::chunkHash($chunkX, $chunkZ);
|
||||
|
||||
if(isset($this->caches[$chunkHash])){
|
||||
@ -111,7 +115,7 @@ class ChunkCache implements ChunkListener{
|
||||
new ChunkRequestTask(
|
||||
$chunkX,
|
||||
$chunkZ,
|
||||
$this->world->getChunk($chunkX, $chunkZ),
|
||||
$chunk,
|
||||
$this->caches[$chunkHash],
|
||||
$this->compressor,
|
||||
function() use ($chunkX, $chunkZ) : void{
|
||||
|
Loading…
x
Reference in New Issue
Block a user