huge optimizations

This commit is contained in:
nossr50
2024-11-03 17:10:49 -08:00
parent f0973f2500
commit 3aaff1911b
4 changed files with 15 additions and 18 deletions

View File

@ -159,17 +159,16 @@ public class HashChunkManager implements ChunkManager {
ChunkStore check = chunkMap.computeIfAbsent(chunkKey, k -> {
// Load from file
ChunkStore loaded = loadChunk(chunkKey.x, chunkKey.z, world);
if (loaded == null)
return null;
if (loaded != null) {
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
return loaded;
}
// Mark chunk in-use for region tracking
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
return loaded;
// Create a new chunkstore
return new BitSetChunkStore(world, chunkKey.x, chunkKey.z);
});
// No chunk, return false
if (check == null)
return false;
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;
@ -227,19 +226,12 @@ public class HashChunkManager implements ChunkManager {
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
return loaded;
}
// If setting to false, no need to create an empty chunkstore
if (!value)
return null;
// Mark chunk in-use for region tracking
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
// Create a new chunkstore
return new BitSetChunkStore(world, chunkKey.x, chunkKey.z);
});
// Indicates setting false on empty chunkstore
if (cStore == null)
return;
// Get block offset (offset from chunk corner)
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;

View File

@ -28,12 +28,12 @@ public class NullChunkManager implements ChunkManager {
@Override
public boolean isEligible(@NotNull Block block) {
return false;
return true;
}
@Override
public boolean isEligible(@NotNull BlockState blockState) {
return false;
return true;
}
@Override