From 5e5c63d109fe5efc589a5139900ecdd1c4421014 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Sat, 22 Mar 2025 17:54:13 +1000 Subject: [PATCH] stuff --- .../cortex/voxy/client/config/VoxyConfig.java | 19 ++++--------------- .../voxy/client/core/gl/shader/Shader.java | 3 ++- .../client/core/rendering/RenderService.java | 2 +- .../client/saver/ContextSelectionSystem.java | 16 ++++++---------- .../voxy/common/util/TrackedObject.java | 9 ++------- 5 files changed, 15 insertions(+), 34 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/config/VoxyConfig.java b/src/main/java/me/cortex/voxy/client/config/VoxyConfig.java index 583183e8..0007addb 100644 --- a/src/main/java/me/cortex/voxy/client/config/VoxyConfig.java +++ b/src/main/java/me/cortex/voxy/client/config/VoxyConfig.java @@ -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); } } diff --git a/src/main/java/me/cortex/voxy/client/core/gl/shader/Shader.java b/src/main/java/me/cortex/voxy/client/core/gl/shader/Shader.java index 808ffdf5..7fc51216 100644 --- a/src/main/java/me/cortex/voxy/client/core/gl/shader/Shader.java +++ b/src/main/java/me/cortex/voxy/client/core/gl/shader/Shader.java @@ -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); } } diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java b/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java index 8493a243..868c9546 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java @@ -153,7 +153,7 @@ public class RenderService, 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))); diff --git a/src/main/java/me/cortex/voxy/client/saver/ContextSelectionSystem.java b/src/main/java/me/cortex/voxy/client/saver/ContextSelectionSystem.java index 4ef3512b..aea518b4 100644 --- a/src/main/java/me/cortex/voxy/client/saver/ContextSelectionSystem.java +++ b/src/main/java/me/cortex/voxy/client/saver/ContextSelectionSystem.java @@ -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()) { diff --git a/src/main/java/me/cortex/voxy/common/util/TrackedObject.java b/src/main/java/me/cortex/voxy/common/util/TrackedObject.java index 31efae42..514269b0 100644 --- a/src/main/java/me/cortex/voxy/common/util/TrackedObject.java +++ b/src/main/java/me/cortex/voxy/common/util/TrackedObject.java @@ -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); } }); }