use of org.terasology.engine.world.chunks.ChunkProvider in project Terasology by MovingBlocks.
the class ReadWriteStorageManager method isSavingNecessary.
private boolean isSavingNecessary() {
ChunkProvider chunkProvider = CoreRegistry.get(ChunkProvider.class);
int unloadedChunkCount = unloadedAndUnsavedChunkMap.size();
int loadedChunkCount = chunkProvider.getAllChunks().size();
double totalChunkCount = unloadedChunkCount + loadedChunkCount;
double percentageUnloaded = 100.0 * unloadedChunkCount / totalChunkCount;
if (percentageUnloaded >= systemConfig.maxUnloadedChunksPercentageTillSave.get()) {
return true;
}
long currentTime = System.currentTimeMillis();
if (nextAutoSave == null) {
scheduleNextAutoSave();
return false;
}
return currentTime >= nextAutoSave;
}
Aggregations