mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
World: add checks for tile position outside of world bounds, closes #4622
This commit is contained in:
parent
5a351d3b17
commit
78ffad5ffc
@ -2373,6 +2373,9 @@ class World implements ChunkManager{
|
||||
if(!$pos->isValid() || $pos->getWorld() !== $this){
|
||||
throw new \InvalidArgumentException("Invalid Tile world");
|
||||
}
|
||||
if(!$this->isInWorld($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ())){
|
||||
throw new \InvalidArgumentException("Tile position is outside the world bounds");
|
||||
}
|
||||
|
||||
$chunkX = $pos->getFloorX() >> Chunk::COORD_BIT_SIZE;
|
||||
$chunkZ = $pos->getFloorZ() >> Chunk::COORD_BIT_SIZE;
|
||||
@ -2530,6 +2533,8 @@ class World implements ChunkManager{
|
||||
$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)){
|
||||
$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())){
|
||||
$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){
|
||||
$logger->error("Cannot add tile at x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z: Another tile is already at that position");
|
||||
}else{
|
||||
|
Loading…
x
Reference in New Issue
Block a user