mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
improve cache configs
This commit is contained in:
@@ -29,12 +29,7 @@ import java.util.Random;
|
||||
public class StructureScript {
|
||||
private final Block block;
|
||||
private final String id;
|
||||
private final LinkedHashMap<Location, StructureBuffer> cache = new LinkedHashMap<Location, StructureBuffer>() {
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<Location, StructureBuffer> eldest) {
|
||||
return this.size() > 128;
|
||||
}
|
||||
};
|
||||
private final LinkedHashMap<Location, StructureBuffer> cache;
|
||||
|
||||
public StructureScript(InputStream inputStream, TerraPlugin main, ScriptRegistry registry) {
|
||||
Parser parser;
|
||||
@@ -58,6 +53,12 @@ public class StructureScript {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.id = parser.getID();
|
||||
this.cache = new LinkedHashMap<Location, StructureBuffer>() {
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<Location, StructureBuffer> eldest) {
|
||||
return this.size() > main.getTerraConfig().getStructureCache();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CarverCache {
|
||||
}
|
||||
|
||||
public List<Worm.WormPoint> getPoints(int chunkX, int chunkZ, UserDefinedCarver carver) {
|
||||
if(carvers.size() > main.getTerraConfig().getCacheSize() * 2) carvers.clear();
|
||||
if(carvers.size() > main.getTerraConfig().getCarverCacheSize()) carvers.clear();
|
||||
return carvers.computeIfAbsent((((long) chunkX) << 32) | (chunkZ & 0xffffffffL), key -> {
|
||||
TerraBiomeGrid grid = main.getWorld(w).getGrid();
|
||||
if(carver.isChunkCarved(w, chunkX, chunkZ, new FastRandom(MathUtil.getCarverChunkSeed(chunkX, chunkZ, w.getSeed() + carver.hashCode())))) {
|
||||
|
||||
@@ -35,9 +35,12 @@ public class PluginConfig implements ConfigTemplate {
|
||||
@Default
|
||||
private int biomeSearch = 4;
|
||||
|
||||
@Value("cache-size")
|
||||
@Value("cache.carver")
|
||||
@Default
|
||||
private int cacheSize = 384;
|
||||
private int carverCache = 512;
|
||||
@Value("cache.structure")
|
||||
@Default
|
||||
private int structureCache = 128;
|
||||
|
||||
@Value("dump-default")
|
||||
@Default
|
||||
@@ -80,7 +83,11 @@ public class PluginConfig implements ConfigTemplate {
|
||||
return biomeSearch;
|
||||
}
|
||||
|
||||
public int getCacheSize() {
|
||||
return cacheSize;
|
||||
public int getCarverCacheSize() {
|
||||
return carverCache;
|
||||
}
|
||||
|
||||
public int getStructureCache() {
|
||||
return structureCache;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
debug: false
|
||||
data-save: PT6M
|
||||
language: "en_us"
|
||||
fail-type: SHUTDOWN
|
||||
dump-default: true
|
||||
biome-search-resolution: 4
|
||||
cache-size: 384
|
||||
cache:
|
||||
carver: 512
|
||||
structure: 128
|
||||
master-disable:
|
||||
caves: false
|
||||
Reference in New Issue
Block a user