mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Improved Level->getTile() to a direct lookup instead of linear search
This commit is contained in:
@ -1366,13 +1366,10 @@ class Level implements ChunkManager, Metadatable{
|
||||
if($pos instanceof Position and $pos->getLevel() !== $this){
|
||||
return null;
|
||||
}
|
||||
$tiles = $this->getChunkTiles($pos->x >> 4, $pos->z >> 4);
|
||||
if(count($tiles) > 0){
|
||||
foreach($tiles as $tile){
|
||||
if($tile->x === (int) $pos->x and $tile->y === (int) $pos->y and $tile->z === (int) $pos->z){
|
||||
return $tile;
|
||||
}
|
||||
}
|
||||
$chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4);
|
||||
|
||||
if($chunk instanceof FullChunk){
|
||||
return $chunk->getTile($pos->x & 0x0f, $pos->y & 0x7f, $pos->z & 0x0f);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user