Level: use chunk records for tile reading in getTileAt()

the previous revision caused a crash when clicking on the bottom of the world due to a block hash being out of bounds.
This commit is contained in:
Dylan K. Taylor 2018-08-26 18:57:08 +01:00
parent 5d1ec1ad49
commit 66e46e1c07

View File

@ -2039,7 +2039,7 @@ class Level implements ChunkManager, Metadatable{
* @return Tile|null
*/
public function getTileAt(int $x, int $y, int $z) : ?Tile{
return $this->tiles[Level::blockHash($x, $y, $z)] ?? null;
return ($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null ? $chunk->getTile($x & 0x0f, $y, $z & 0x0f) : null;
}
/**