stuff
This commit is contained in:
@@ -4,6 +4,7 @@ import com.google.gson.FieldNamingPolicy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import me.cortex.voxy.client.saver.ContextSelectionSystem;
|
||||
import me.cortex.voxy.common.Logger;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import java.io.FileReader;
|
||||
@@ -27,28 +28,17 @@ public class VoxyConfig {
|
||||
public int serviceThreads = Math.max(Runtime.getRuntime().availableProcessors()/2, 1);
|
||||
public float subDivisionSize = 128;
|
||||
public int secondaryLruCacheSize = 1024;
|
||||
public String defaultSaveConfig;
|
||||
//public int renderQuality = 256;//Smaller is higher quality
|
||||
|
||||
|
||||
public static VoxyConfig loadOrCreate() {
|
||||
var path = getConfigPath();
|
||||
if (Files.exists(path)) {
|
||||
try (FileReader reader = new FileReader(path.toFile())) {
|
||||
var cfg = GSON.fromJson(reader, VoxyConfig.class);
|
||||
|
||||
|
||||
//TODO: dont always override it
|
||||
cfg.defaultSaveConfig = ContextSelectionSystem.DEFAULT_STORAGE_CONFIG;
|
||||
|
||||
return cfg;
|
||||
return GSON.fromJson(reader, VoxyConfig.class);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Could not parse config");
|
||||
e.printStackTrace();
|
||||
Logger.error("Could not parse config",e);
|
||||
}
|
||||
}
|
||||
var config = new VoxyConfig();
|
||||
config.defaultSaveConfig = ContextSelectionSystem.DEFAULT_STORAGE_CONFIG;
|
||||
config.save();
|
||||
return config;
|
||||
}
|
||||
@@ -56,8 +46,7 @@ public class VoxyConfig {
|
||||
try {
|
||||
Files.writeString(getConfigPath(), GSON.toJson(this));
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to write config file");
|
||||
e.printStackTrace();
|
||||
Logger.error("Failed to write config file", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.cortex.voxy.client.core.gl.shader;
|
||||
|
||||
import me.cortex.voxy.client.core.gl.GlBuffer;
|
||||
import me.cortex.voxy.client.core.gl.GlDebug;
|
||||
import me.cortex.voxy.common.Logger;
|
||||
import me.cortex.voxy.common.util.TrackedObject;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
|
||||
@@ -143,7 +144,7 @@ public class Shader extends TrackedObject {
|
||||
String log = GL20C.glGetProgramInfoLog(program);
|
||||
|
||||
if (!log.isEmpty()) {
|
||||
System.err.println(log);
|
||||
Logger.error(log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ public class RenderService<T extends AbstractSectionRenderer<J, ?>, J extends Vi
|
||||
private int q = -60;
|
||||
public void setup(Camera camera) {
|
||||
final int W = 32;
|
||||
final int H = 3;
|
||||
final int H = 2;
|
||||
boolean SIDED = false;
|
||||
for (int i = 0; i<64 && q<((W*2+1)*(W*2+1)*H)&&q++>=0;i++) {
|
||||
this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(4, (q%(W*2+1))-(SIDED?0:W), ((q/(W*2+1))/(W*2+1))-1, ((q/(W*2+1))%(W*2+1))-(SIDED?0:W)));
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ContextSelectionSystem {
|
||||
public int maxYOverride = Integer.MIN_VALUE;
|
||||
public SectionStorageConfig sectionStorageConfig;
|
||||
}
|
||||
public static final String DEFAULT_STORAGE_CONFIG;
|
||||
public static final WorldConfig DEFAULT_STORAGE_CONFIG;
|
||||
static {
|
||||
var config = new WorldConfig();
|
||||
|
||||
@@ -48,11 +48,7 @@ public class ContextSelectionSystem {
|
||||
serializer.storage = compression;
|
||||
config.sectionStorageConfig = serializer;
|
||||
|
||||
DEFAULT_STORAGE_CONFIG = Serialization.GSON.toJson(config);
|
||||
|
||||
if (Serialization.GSON.fromJson(DEFAULT_STORAGE_CONFIG, WorldConfig.class) == null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
DEFAULT_STORAGE_CONFIG = config;
|
||||
}
|
||||
|
||||
public static class Selection {
|
||||
@@ -86,13 +82,13 @@ public class ContextSelectionSystem {
|
||||
}
|
||||
|
||||
try {
|
||||
this.config = Serialization.GSON.fromJson(VoxyConfig.CONFIG.defaultSaveConfig, WorldConfig.class);
|
||||
this.config = DEFAULT_STORAGE_CONFIG;
|
||||
this.save();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to deserialize the default config, aborting!", e);
|
||||
}
|
||||
if (this.config == null) {
|
||||
throw new IllegalStateException("Config is still null: \n"+VoxyConfig.CONFIG.defaultSaveConfig);
|
||||
throw new IllegalStateException("Config is still null\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,12 +128,12 @@ public class ContextSelectionSystem {
|
||||
} else {
|
||||
var netHandle = MinecraftClient.getInstance().interactionManager;
|
||||
if (netHandle == null) {
|
||||
System.err.println("Network handle null");
|
||||
Logger.error("Network handle null");
|
||||
basePath = basePath.resolve("UNKNOWN");
|
||||
} else {
|
||||
var info = netHandle.networkHandler.getServerInfo();
|
||||
if (info == null) {
|
||||
System.err.println("Server info null");
|
||||
Logger.error("Server info null");
|
||||
basePath = basePath.resolve("UNKNOWN");
|
||||
} else {
|
||||
if (info.isRealm()) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.cortex.voxy.common.util;
|
||||
|
||||
import me.cortex.voxy.common.Logger;
|
||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||
|
||||
import java.lang.ref.Cleaner;
|
||||
@@ -70,13 +71,7 @@ public abstract class TrackedObject {
|
||||
}
|
||||
cleanable = cleaner.register(obj, () -> {
|
||||
if (!freed[0]) {
|
||||
System.err.println("Object named: " + clazz + " was not freed, location at:\n");
|
||||
if (trace != null) {
|
||||
trace.printStackTrace();
|
||||
} else {
|
||||
System.err.println("Enable allocation stack tracing");
|
||||
}
|
||||
System.err.flush();
|
||||
Logger.error("Object named: " + clazz + " was not freed, location at:\n", trace==null?"Enable allocation stack tracing":trace);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user