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