World: fixed edge case that could lead to crash during block update sending

This commit is contained in:
Dylan K. Taylor 2023-11-17 13:24:06 +00:00
parent a25597ca30
commit 67ad2bad17
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 5 additions and 6 deletions

View File

@ -1016,8 +1016,12 @@ class World implements ChunkManager{
continue;
}
World::getXZ($index, $chunkX, $chunkZ);
if(!$this->isChunkLoaded($chunkX, $chunkZ)){
//a previous chunk may have caused this one to be unloaded by a ChunkListener
continue;
}
if(count($blocks) > 512){
$chunk = $this->getChunk($chunkX, $chunkZ);
$chunk = $this->getChunk($chunkX, $chunkZ) ?? throw new AssumptionFailedError("We already checked that the chunk is loaded");
foreach($this->getChunkPlayers($chunkX, $chunkZ) as $p){
$p->onChunkChanged($chunkX, $chunkZ, $chunk);
}

View File

@ -960,11 +960,6 @@ parameters:
count: 2
path: ../../../src/world/World.php
-
message: "#^Parameter \\#3 \\$chunk of method pocketmine\\\\player\\\\Player\\:\\:onChunkChanged\\(\\) expects pocketmine\\\\world\\\\format\\\\Chunk, pocketmine\\\\world\\\\format\\\\Chunk\\|null given\\.$#"
count: 1
path: ../../../src/world/World.php
-
message: "#^Parameter \\#3 \\$y of method pocketmine\\\\block\\\\Block\\:\\:position\\(\\) expects int, float\\|int given\\.$#"
count: 2