From dec235abab5f7e024b954be21941b88b26d07b45 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 31 Oct 2020 21:29:39 +0000 Subject: [PATCH] World: don't create a new chunk just to read biome info the chunk won't be generated, so we can provide the default result without creating a new chunk for no reason. --- src/world/World.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/world/World.php b/src/world/World.php index 40c243869..a2b6a7fea 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -1858,7 +1858,10 @@ class World implements ChunkManager{ } public function getBiomeId(int $x, int $z) : int{ - return $this->getOrLoadChunk($x >> 4, $z >> 4, true)->getBiomeId($x & 0x0f, $z & 0x0f); + if(($chunk = $this->getOrLoadChunk($x >> 4, $z >> 4, false)) !== null){ + return $chunk->getBiomeId($x & 0x0f, $z & 0x0f); + } + return Biome::OCEAN; //TODO: this should probably throw instead (terrain not generated yet) } public function getBiome(int $x, int $z) : Biome{