mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +00:00
World: avoid duplicated logger code in initChunk()
This commit is contained in:
parent
1cabe4baf3
commit
3dc75644d9
@ -2442,6 +2442,7 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function initChunk(int $chunkX, int $chunkZ, ChunkData $chunkData) : void{
|
private function initChunk(int $chunkX, int $chunkZ, ChunkData $chunkData) : void{
|
||||||
|
$logger = new \PrefixedLogger($this->logger, "Loading chunk $chunkX $chunkZ");
|
||||||
if(count($chunkData->getEntityNBT()) !== 0){
|
if(count($chunkData->getEntityNBT()) !== 0){
|
||||||
$this->timings->syncChunkLoadEntities->startTiming();
|
$this->timings->syncChunkLoadEntities->startTiming();
|
||||||
$entityFactory = EntityFactory::getInstance();
|
$entityFactory = EntityFactory::getInstance();
|
||||||
@ -2449,8 +2450,8 @@ class World implements ChunkManager{
|
|||||||
try{
|
try{
|
||||||
$entity = $entityFactory->createFromData($this, $nbt);
|
$entity = $entityFactory->createFromData($this, $nbt);
|
||||||
}catch(NbtDataException $e){
|
}catch(NbtDataException $e){
|
||||||
$this->getLogger()->error("Chunk $chunkX $chunkZ: Bad entity data at list position $k: " . $e->getMessage());
|
$logger->error("Bad entity data at list position $k: " . $e->getMessage());
|
||||||
$this->getLogger()->logException($e);
|
$logger->logException($e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($entity === null){
|
if($entity === null){
|
||||||
@ -2461,7 +2462,7 @@ class World implements ChunkManager{
|
|||||||
}elseif($saveIdTag instanceof IntTag){ //legacy MCPE format
|
}elseif($saveIdTag instanceof IntTag){ //legacy MCPE format
|
||||||
$saveId = "legacy(" . $saveIdTag->getValue() . ")";
|
$saveId = "legacy(" . $saveIdTag->getValue() . ")";
|
||||||
}
|
}
|
||||||
$this->getLogger()->warning("Chunk $chunkX $chunkZ: Deleted unknown entity type $saveId");
|
$logger->warning("Deleted unknown entity type $saveId");
|
||||||
}
|
}
|
||||||
//TODO: we can't prevent entities getting added to unloaded chunks if they were saved in the wrong place
|
//TODO: we can't prevent entities getting added to unloaded chunks if they were saved in the wrong place
|
||||||
//here, because entities currently add themselves to the world
|
//here, because entities currently add themselves to the world
|
||||||
@ -2477,16 +2478,16 @@ class World implements ChunkManager{
|
|||||||
try{
|
try{
|
||||||
$tile = $tileFactory->createFromData($this, $nbt);
|
$tile = $tileFactory->createFromData($this, $nbt);
|
||||||
}catch(NbtDataException $e){
|
}catch(NbtDataException $e){
|
||||||
$this->getLogger()->error("Chunk $chunkX $chunkZ: Bad tile entity data at list position $k: " . $e->getMessage());
|
$logger->error("Bad tile entity data at list position $k: " . $e->getMessage());
|
||||||
$this->getLogger()->logException($e);
|
$logger->logException($e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($tile === null){
|
if($tile === null){
|
||||||
$this->getLogger()->warning("Chunk $chunkX $chunkZ: 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)){
|
}elseif(!$this->isChunkLoaded($tile->getPosition()->getFloorX() >> Chunk::COORD_BIT_SIZE, $tile->getPosition()->getFloorZ() >> Chunk::COORD_BIT_SIZE)){
|
||||||
$this->logger->error("Chunk $chunkX $chunkZ: 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->getTile($tilePosition = $tile->getPosition()) !== null){
|
}elseif($this->getTile($tilePosition = $tile->getPosition()) !== null){
|
||||||
$this->logger->error("Chunk $chunkX $chunkZ: 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