mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Assume chunks are dirty by default
having them be clean by default makes no sense. It only makes sense for them to be clean if they were loaded directly from disk without any alterations. Default clean is a footgun.
This commit is contained in:
parent
c10be0f346
commit
ce5e663a73
@ -2717,7 +2717,13 @@ class World implements ChunkManager{
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->chunks[$chunkHash] = $loadedChunkData->getData()->getChunk();
|
||||
$chunk = $loadedChunkData->getData()->getChunk();
|
||||
if(!$loadedChunkData->isUpgraded()){
|
||||
$chunk->clearTerrainDirtyFlags();
|
||||
}else{
|
||||
$this->logger->debug("Chunk $x $z has been upgraded, will be saved at the next autosave opportunity");
|
||||
}
|
||||
$this->chunks[$chunkHash] = $chunk;
|
||||
unset($this->blockCache[$chunkHash]);
|
||||
|
||||
$this->initChunk($x, $z, $loadedChunkData->getData());
|
||||
|
@ -44,7 +44,7 @@ class Chunk{
|
||||
public const COORD_BIT_SIZE = SubChunk::COORD_BIT_SIZE;
|
||||
public const COORD_MASK = SubChunk::COORD_MASK;
|
||||
|
||||
private int $terrainDirtyFlags = 0;
|
||||
private int $terrainDirtyFlags = ~0;
|
||||
|
||||
protected ?bool $lightPopulated = false;
|
||||
protected bool $terrainPopulated = false;
|
||||
|
@ -695,18 +695,8 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
|
||||
//TODO: tile ticks, biome states (?)
|
||||
|
||||
$chunk = new Chunk(
|
||||
$subChunks,
|
||||
$terrainPopulated
|
||||
);
|
||||
|
||||
if($hasBeenUpgraded){
|
||||
$logger->debug("Flagging chunk as dirty due to upgraded data");
|
||||
$chunk->setTerrainDirty(); //trigger rewriting chunk to disk if it was converted from an older format
|
||||
}
|
||||
|
||||
return new LoadedChunkData(
|
||||
data: new ChunkData($chunk, $entities, $tiles),
|
||||
data: new ChunkData(new Chunk($subChunks, $terrainPopulated), $entities, $tiles),
|
||||
upgraded: $hasBeenUpgraded,
|
||||
fixerFlags: LoadedChunkData::FIXER_FLAG_ALL //TODO: fill this by version rather than just setting all flags
|
||||
);
|
||||
|
@ -117,8 +117,6 @@ class PopulationTask extends AsyncTask{
|
||||
if($chunk === null){
|
||||
throw new AssumptionFailedError("We just set this chunk, so it must exist");
|
||||
}
|
||||
$chunk->setTerrainDirtyFlag(Chunk::DIRTY_FLAG_BLOCKS, true);
|
||||
$chunk->setTerrainDirtyFlag(Chunk::DIRTY_FLAG_BIOMES, true);
|
||||
}
|
||||
return $chunk;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user