From 1e5597f0d5d0b9f1aaa1c9db1acbfc9e498c4349 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 19 Dec 2022 20:20:52 +0000 Subject: [PATCH] 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. --- src/world/World.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/world/World.php b/src/world/World.php index 4c8d6a44c..54fd7863b 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -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();