mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-20 04:33:59 +00:00
World: don't create an empty chunk just for accessing the highest block
this is pointless since the chunk will not be generated anyway, so it serves no end to create it.
This commit is contained in:
parent
f0d62cf4ce
commit
de867f1b86
@ -2032,10 +2032,13 @@ class World implements ChunkManager{
|
|||||||
/**
|
/**
|
||||||
* Gets the highest block Y value at a specific $x and $z
|
* Gets the highest block Y value at a specific $x and $z
|
||||||
*
|
*
|
||||||
* @return int 0-255
|
* @return int 0-255, or -1 if the chunk is not generated
|
||||||
*/
|
*/
|
||||||
public function getHighestBlockAt(int $x, int $z) : int{
|
public function getHighestBlockAt(int $x, int $z) : int{
|
||||||
return $this->getOrLoadChunk($x >> 4, $z >> 4, true)->getHighestBlockAt($x & 0x0f, $z & 0x0f);
|
if(($chunk = $this->getOrLoadChunk($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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user