World: account for null chunk edge case in tickChunk()

the target chunk may no longer be loaded if it was unloaded during a previous chunk's tick (e.g. during BlockGrowEvent).
Since the parent function iterates over a pre-selected array of chunks, the chunk will still be present in the list even if it's no longer loaded by the time it's reached.
This commit is contained in:
Dylan K. Taylor 2022-12-19 20:20:52 +00:00
parent 97ef209c5f
commit 1e5597f0d5
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1222,7 +1222,8 @@ class World implements ChunkManager{
private function tickChunk(int $chunkX, int $chunkZ) : void{
$chunk = $this->getChunk($chunkX, $chunkZ);
if($chunk === null){
throw new \InvalidArgumentException("Chunk is not loaded");
//the chunk may have been unloaded during a previous chunk's update (e.g. during BlockGrowEvent)
return;
}
foreach($this->getChunkEntities($chunkX, $chunkZ) as $entity){
$entity->onRandomUpdate();