Moved from storage_config.json to config.json
This commit is contained in:
@@ -23,13 +23,13 @@ public class DistanceTracker {
|
|||||||
private final int maxYSection;
|
private final int maxYSection;
|
||||||
private final int renderDistance;
|
private final int renderDistance;
|
||||||
|
|
||||||
public DistanceTracker(RenderTracker tracker, int[] lodRingScales, int renderDistance, int cacheDistance) {
|
public DistanceTracker(RenderTracker tracker, int[] lodRingScales, int renderDistance, int cacheDistance, int minY, int maxY) {
|
||||||
this.loDRings = new TransitionRing2D[lodRingScales.length];
|
this.loDRings = new TransitionRing2D[lodRingScales.length];
|
||||||
this.cacheLoadRings = new TransitionRing2D[lodRingScales.length];
|
this.cacheLoadRings = new TransitionRing2D[lodRingScales.length];
|
||||||
this.cacheUnloadRings = new TransitionRing2D[lodRingScales.length];
|
this.cacheUnloadRings = new TransitionRing2D[lodRingScales.length];
|
||||||
this.tracker = tracker;
|
this.tracker = tracker;
|
||||||
this.minYSection = MinecraftClient.getInstance().world.getBottomSectionCoord()/2;//-128;
|
this.minYSection = minY;
|
||||||
this.maxYSection = MinecraftClient.getInstance().world.getTopSectionCoord()/2;//128;
|
this.maxYSection = maxY;
|
||||||
this.renderDistance = renderDistance;
|
this.renderDistance = renderDistance;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class VoxelCore {
|
|||||||
|
|
||||||
public VoxelCore(ContextSelectionSystem.Selection worldSelection) {
|
public VoxelCore(ContextSelectionSystem.Selection worldSelection) {
|
||||||
this.world = worldSelection.createEngine();
|
this.world = worldSelection.createEngine();
|
||||||
|
var cfg = worldSelection.getConfig();
|
||||||
System.out.println("Initializing voxy core");
|
System.out.println("Initializing voxy core");
|
||||||
|
|
||||||
//Trigger the shared index buffer loading
|
//Trigger the shared index buffer loading
|
||||||
@@ -73,8 +74,20 @@ public class VoxelCore {
|
|||||||
|
|
||||||
//To get to chunk scale multiply the scale by 2, the scale is after how many chunks does the lods halve
|
//To get to chunk scale multiply the scale by 2, the scale is after how many chunks does the lods halve
|
||||||
int q = VoxyConfig.CONFIG.qualityScale;
|
int q = VoxyConfig.CONFIG.qualityScale;
|
||||||
//TODO: add an option for cache load and unload distance
|
int minY = MinecraftClient.getInstance().world.getBottomSectionCoord()/2;
|
||||||
this.distanceTracker = new DistanceTracker(this.renderTracker, new int[]{q,q,q,q}, (VoxyConfig.CONFIG.renderDistance<0?VoxyConfig.CONFIG.renderDistance:((VoxyConfig.CONFIG.renderDistance+1)/2)), 3);
|
int maxY = MinecraftClient.getInstance().world.getTopSectionCoord()/2;
|
||||||
|
|
||||||
|
if (cfg.minYOverride != Integer.MAX_VALUE) {
|
||||||
|
minY = cfg.minYOverride;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfg.maxYOverride != Integer.MIN_VALUE) {
|
||||||
|
maxY = cfg.maxYOverride;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.distanceTracker = new DistanceTracker(this.renderTracker, new int[]{q,q,q,q},
|
||||||
|
(VoxyConfig.CONFIG.renderDistance<0?VoxyConfig.CONFIG.renderDistance:((VoxyConfig.CONFIG.renderDistance+1)/2)),
|
||||||
|
3, minY, maxY);
|
||||||
System.out.println("Distance tracker initialized");
|
System.out.println("Distance tracker initialized");
|
||||||
|
|
||||||
this.postProcessing = new PostProcessing();
|
this.postProcessing = new PostProcessing();
|
||||||
|
|||||||
@@ -22,11 +22,17 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
//Sets up a world engine with respect to the world the client is currently loaded into
|
//Sets up a world engine with respect to the world the client is currently loaded into
|
||||||
// this is a bit tricky as each world has its own config, e.g. storage configuration
|
// this is a bit tricky as each world has its own config, e.g. storage configuration
|
||||||
public class ContextSelectionSystem {
|
public class ContextSelectionSystem {
|
||||||
|
public static class WorldConfig {
|
||||||
|
public int minYOverride = Integer.MAX_VALUE;
|
||||||
|
public int maxYOverride = Integer.MIN_VALUE;
|
||||||
|
public StorageConfig storageConfig;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Selection {
|
public static class Selection {
|
||||||
private final Path selectionFolder;
|
private final Path selectionFolder;
|
||||||
private final String worldId;
|
private final String worldId;
|
||||||
|
|
||||||
private StorageConfig storageConfig;
|
private WorldConfig config;
|
||||||
|
|
||||||
public Selection(Path selectionFolder, String worldId) {
|
public Selection(Path selectionFolder, String worldId) {
|
||||||
this.selectionFolder = selectionFolder;
|
this.selectionFolder = selectionFolder;
|
||||||
@@ -35,17 +41,18 @@ public class ContextSelectionSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadStorageConfigOrDefault() {
|
private void loadStorageConfigOrDefault() {
|
||||||
var json = this.selectionFolder.resolve("storage_config.json");
|
var json = this.selectionFolder.resolve("config.json");
|
||||||
|
|
||||||
if (Files.exists(json)) {
|
if (Files.exists(json)) {
|
||||||
try {
|
try {
|
||||||
this.storageConfig = Serialization.GSON.fromJson(Files.readString(json), StorageConfig.class);
|
this.config = Serialization.GSON.fromJson(Files.readString(json), WorldConfig.class);
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Failed to load the storage configuration file, resetting it to default");
|
System.err.println("Failed to load the storage configuration file, resetting it to default");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.config = new WorldConfig();
|
||||||
|
|
||||||
//Load the default config
|
//Load the default config
|
||||||
var baseDB = new RocksDBStorageBackend.Config();
|
var baseDB = new RocksDBStorageBackend.Config();
|
||||||
@@ -57,7 +64,7 @@ public class ContextSelectionSystem {
|
|||||||
compression.delegate = baseDB;
|
compression.delegate = baseDB;
|
||||||
compression.compressor = compressor;
|
compression.compressor = compressor;
|
||||||
|
|
||||||
this.storageConfig = compression;
|
this.config.storageConfig = compression;
|
||||||
|
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
@@ -67,18 +74,7 @@ public class ContextSelectionSystem {
|
|||||||
ctx.setProperty(ConfigBuildCtx.BASE_SAVE_PATH, this.selectionFolder.toString());
|
ctx.setProperty(ConfigBuildCtx.BASE_SAVE_PATH, this.selectionFolder.toString());
|
||||||
ctx.setProperty(ConfigBuildCtx.WORLD_IDENTIFIER, this.worldId);
|
ctx.setProperty(ConfigBuildCtx.WORLD_IDENTIFIER, this.worldId);
|
||||||
ctx.pushPath(ConfigBuildCtx.DEFAULT_STORAGE_PATH);
|
ctx.pushPath(ConfigBuildCtx.DEFAULT_STORAGE_PATH);
|
||||||
return this.storageConfig.build(ctx);
|
return this.config.storageConfig.build(ctx);
|
||||||
|
|
||||||
/*
|
|
||||||
var translocator = new TranslocatingStorageAdaptor.Config();
|
|
||||||
translocator.delegate = compression;
|
|
||||||
translocator.transforms.add(new TranslocatingStorageAdaptor.BoxTransform(0,5,0, 200, 64, 200, 0, -5, 0));
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//StorageBackend storage = new RocksDBStorageBackend(VoxyConfig.CONFIG.storagePath);
|
|
||||||
////StorageBackend storage = new FragmentedStorageBackendAdaptor(new File(VoxyConfig.CONFIG.storagePath));
|
|
||||||
//return new CompressionStorageAdaptor(new ZSTDCompressor(VoxyConfig.CONFIG.savingCompressionLevel), storage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldEngine createEngine() {
|
public WorldEngine createEngine() {
|
||||||
@@ -89,14 +85,18 @@ public class ContextSelectionSystem {
|
|||||||
// or just have per world config, cause when creating the world engine doing the string substitution would
|
// or just have per world config, cause when creating the world engine doing the string substitution would
|
||||||
// make it automatically select the right id
|
// make it automatically select the right id
|
||||||
public void save() {
|
public void save() {
|
||||||
var file = this.selectionFolder.resolve("storage_config.json");
|
var file = this.selectionFolder.resolve("config.json");
|
||||||
var json = Serialization.GSON.toJson(this.storageConfig);
|
var json = Serialization.GSON.toJson(this.config);
|
||||||
try {
|
try {
|
||||||
Files.writeString(file, json);
|
Files.writeString(file, json);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WorldConfig getConfig() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gets dimension independent base world, if singleplayer, its the world name, if multiplayer, its the server ip
|
//Gets dimension independent base world, if singleplayer, its the world name, if multiplayer, its the server ip
|
||||||
|
|||||||
Reference in New Issue
Block a user