mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
World: simplify tile position checking code
This commit is contained in:
parent
78ffad5ffc
commit
e0eeb87ea0
@ -2531,11 +2531,15 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
if($tile === null){
|
if($tile === null){
|
||||||
$logger->warning("Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>"));
|
$logger->warning("Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>"));
|
||||||
}elseif(!$this->isChunkLoaded($tile->getPosition()->getFloorX() >> Chunk::COORD_BIT_SIZE, $tile->getPosition()->getFloorZ() >> Chunk::COORD_BIT_SIZE)){
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tilePosition = $tile->getPosition();
|
||||||
|
if(!$this->isChunkLoaded($tilePosition->getFloorX() >> Chunk::COORD_BIT_SIZE, $tilePosition->getFloorZ() >> Chunk::COORD_BIT_SIZE)){
|
||||||
$logger->error("Found tile saved on wrong chunk - unable to fix due to correct chunk not loaded");
|
$logger->error("Found tile saved on wrong chunk - unable to fix due to correct chunk not loaded");
|
||||||
}elseif(!$this->isInWorld(($tilePosition = $tile->getPosition())->getFloorX(), $tilePosition->getFloorY(), $tilePosition->getFloorZ())){
|
}elseif(!$this->isInWorld($tilePosition->getFloorX(), $tilePosition->getFloorY(), $tilePosition->getFloorZ())){
|
||||||
$logger->error("Cannot add tile with position outside the world bounds: x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z");
|
$logger->error("Cannot add tile with position outside the world bounds: x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z");
|
||||||
}elseif($this->getTile($tilePosition = $tile->getPosition()) !== null){
|
}elseif($this->getTile($tilePosition) !== null){
|
||||||
$logger->error("Cannot add tile at x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z: Another tile is already at that position");
|
$logger->error("Cannot add tile at x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z: Another tile is already at that position");
|
||||||
}else{
|
}else{
|
||||||
$this->addTile($tile);
|
$this->addTile($tile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user