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