World: make less noise about deleted tile entities

no need to repeat the same message 100 times
This commit is contained in:
Dylan K. Taylor 2025-05-28 22:10:20 +01:00
parent 035d2dec23
commit 56da492e48
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -2982,6 +2982,8 @@ class World implements ChunkManager{
if(count($chunkData->getEntityNBT()) !== 0){ if(count($chunkData->getEntityNBT()) !== 0){
$this->timings->syncChunkLoadEntities->startTiming(); $this->timings->syncChunkLoadEntities->startTiming();
$entityFactory = EntityFactory::getInstance(); $entityFactory = EntityFactory::getInstance();
$deletedEntities = [];
foreach($chunkData->getEntityNBT() as $k => $nbt){ foreach($chunkData->getEntityNBT() as $k => $nbt){
try{ try{
$entity = $entityFactory->createFromData($this, $nbt); $entity = $entityFactory->createFromData($this, $nbt);
@ -2998,18 +3000,23 @@ 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() . ")";
} }
$logger->warning("Deleted unknown entity type $saveId"); $deletedEntities[$saveId] = ($deletedEntities[$saveId] ?? 0) + 1;
} }
//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
} }
foreach(Utils::promoteKeys($deletedEntities) as $saveId => $count){
$logger->warning("Deleted unknown entity type $saveId x$count");
}
$this->timings->syncChunkLoadEntities->stopTiming(); $this->timings->syncChunkLoadEntities->stopTiming();
} }
if(count($chunkData->getTileNBT()) !== 0){ if(count($chunkData->getTileNBT()) !== 0){
$this->timings->syncChunkLoadTileEntities->startTiming(); $this->timings->syncChunkLoadTileEntities->startTiming();
$tileFactory = TileFactory::getInstance(); $tileFactory = TileFactory::getInstance();
$deletedTiles = [];
foreach($chunkData->getTileNBT() as $k => $nbt){ foreach($chunkData->getTileNBT() as $k => $nbt){
try{ try{
$tile = $tileFactory->createFromData($this, $nbt); $tile = $tileFactory->createFromData($this, $nbt);
@ -3019,7 +3026,8 @@ class World implements ChunkManager{
continue; continue;
} }
if($tile === null){ if($tile === null){
$logger->warning("Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>")); $saveId = $nbt->getString("id", "<unknown>");
$deletedTiles[$saveId] = ($deletedTiles[$saveId] ?? 0) + 1;
continue; continue;
} }
@ -3035,6 +3043,10 @@ class World implements ChunkManager{
} }
} }
foreach(Utils::promoteKeys($deletedTiles) as $saveId => $count){
$logger->warning("Deleted unknown tile entity type $saveId x$count");
}
$this->timings->syncChunkLoadTileEntities->stopTiming(); $this->timings->syncChunkLoadTileEntities->stopTiming();
} }
} }