Level: Added API method getChunkAtPosition()

This returns the chunk containing the given vector.
This commit is contained in:
Dylan K. Taylor 2018-10-20 15:54:13 +01:00
parent cb1eb1ee09
commit d9ebe6f321

View File

@ -2338,6 +2338,18 @@ class Level implements ChunkManager, Metadatable{
return null;
}
/**
* Returns the chunk containing the given Vector3 position.
*
* @param Vector3 $pos
* @param bool $create
*
* @return null|Chunk
*/
public function getChunkAtPosition(Vector3 $pos, bool $create = false) : ?Chunk{
return $this->getChunk($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $create);
}
/**
* Returns the chunks adjacent to the specified chunk.
*