Fix (well, lower the chance of) reading regions that is actively being saved, reduce that chunk pos error chance.

This commit is contained in:
TomTheFurry
2023-06-11 19:52:59 +08:00
parent 27f7440165
commit 2a3ae34294
3 changed files with 13 additions and 12 deletions
@@ -204,7 +204,7 @@ public class ChunkLoader
ChunkPos actualPos = new ChunkPos(tagLevel.getInt("xPos"), tagLevel.getInt("zPos"));
if (!Objects.equals(chunkPos, actualPos))
{
LOGGER.error("Chunk file at "+chunkPos+" is in the wrong location; Ignoring. (Expected "+chunkPos+", got "+actualPos+")");
LOGGER.warn("Chunk file at "+chunkPos+" is in the wrong location; Ignoring. (Expected "+chunkPos+", got "+actualPos+")");
return null;
}
@@ -47,16 +47,8 @@ public class RegionFileStorageExternalCache implements AutoCloseable {
{
long posLong = ChunkPos.asLong(pos.getRegionX(), pos.getRegionZ());
RegionFile rFile;
// First check our custom cache
for (RegionFileCache cache : this.regionFileCache)
{
if (cache.pos == posLong)
{
return cache.file;
}
}
// Then check vanilla cache
// Check vanilla cache
while (true)
{
try
@@ -74,6 +66,15 @@ public class RegionFileStorageExternalCache implements AutoCloseable {
{
return rFile;
}
// Then check our custom cache
for (RegionFileCache cache : this.regionFileCache)
{
if (cache.pos == posLong)
{
return cache.file;
}
}
// Otherwise, check if file exist, and if so, add it to the cache
Path p = storage.folder;