World->getHighestBlockAt() now throws an exception instead of returning -1 in ungenerated terrain

This commit is contained in:
Dylan K. Taylor 2020-11-26 19:44:22 +00:00
parent fd99445c5b
commit 4ea5401d72

View File

@ -2056,13 +2056,14 @@ class World implements ChunkManager{
/**
* Gets the highest block Y value at a specific $x and $z
*
* @return int 0-255, or -1 if the chunk is not generated
* @return int 0-255
* @throws WorldException if the terrain is not generated
*/
public function getHighestBlockAt(int $x, int $z) : int{
if(($chunk = $this->loadChunk($x >> 4, $z >> 4, false)) !== null){
return $chunk->getHighestBlockAt($x & 0x0f, $z & 0x0f);
}
return -1; //TODO: this should probably throw an exception (terrain not generated yet)
throw new WorldException("Cannot get highest block in an ungenerated chunk");
}
/**