Try catches

This commit is contained in:
mcrcortex
2024-03-23 12:08:15 +10:00
parent fecbef2510
commit 1dd2373f5f
6 changed files with 91 additions and 68 deletions

View File

@@ -62,6 +62,8 @@ dependencies {
modCompileOnly("maven.modrinth:starlight:1.1.3+1.20.4")
//modCompileOnly("maven.modrinth:immersiveportals:v5.1.7-mc1.20.4")
modCompileOnly("maven.modrinth:vivecraft:1.20.4-1.1.6-fabric")
modCompileOnly("maven.modrinth:chunky:1.3.138")
modRuntimeOnly("maven.modrinth:chunky:1.3.138")
}

View File

@@ -204,9 +204,12 @@ public class VoxelCore {
debug.add("");
debug.add("");
debug.add("Voxy Core: " + Voxy.VERSION);
/*
debug.add("Ingest service tasks: " + this.world.ingestService.getTaskCount());
debug.add("Saving service tasks: " + this.world.savingService.getTaskCount());
debug.add("Render service tasks: " + this.renderGen.getTaskCount());
*/
debug.add("I/S/R tasks: " + this.world.ingestService.getTaskCount() + "/"+this.world.savingService.getTaskCount()+"/"+this.renderGen.getTaskCount());
debug.add("Loaded cache sizes: " + Arrays.toString(this.world.getLoadedSectionCacheSizes()));
debug.add("Mesh cache count: " + this.renderGen.getMeshCacheCount());
this.renderer.addDebugData(debug);

View File

@@ -5,6 +5,8 @@ import me.cortex.voxy.client.core.model.IdNotYetComputedException;
import me.cortex.voxy.client.core.model.ModelManager;
import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.common.world.WorldSection;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Semaphore;
@@ -49,6 +51,7 @@ public class RenderGenerationService {
while (this.running) {
this.taskCounter.acquireUninterruptibly();
if (!this.running) break;
try {
BuildTask task;
synchronized (this.taskQueue) {
task = this.taskQueue.removeFirst();
@@ -75,11 +78,16 @@ public class RenderGenerationService {
}
section.release();
if (mesh != null) {
//TODO: if the mesh is null, need to clear the cache at that point
this.resultConsumer.accept(mesh.clone());
if (!this.meshCache.putMesh(mesh)) {
mesh.free();
}
}
} catch (Exception e) {
System.err.println(e);
MinecraftClient.getInstance().executeSync(()->MinecraftClient.getInstance().player.sendMessage(Text.literal("Voxy render service had an exception while executing please check logs and report error")));
}
}
}

View File

@@ -4,6 +4,8 @@ import me.cortex.voxy.common.storage.StorageCompressor;
import me.cortex.voxy.common.world.SaveLoadSystem;
import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.common.world.WorldSection;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import org.lwjgl.system.MemoryUtil;
import java.util.concurrent.ConcurrentLinkedDeque;
@@ -40,12 +42,15 @@ public class SectionSavingService {
if (!this.running) break;
var section = this.saveQueue.pop();
section.assertNotFree();
try {
section.inSaveQueue.set(false);
var saveData = SaveLoadSystem.serialize(section);
this.world.storage.setSectionData(section.key, saveData);
MemoryUtil.memFree(saveData);
} catch (Exception e) {
System.err.println(e);
MinecraftClient.getInstance().executeSync(()->MinecraftClient.getInstance().player.sendMessage(Text.literal("Voxy saver had an exception while executing please check logs and report error")));
}
section.release();
}
}

View File

@@ -4,6 +4,8 @@ import it.unimi.dsi.fastutil.Pair;
import me.cortex.voxy.common.voxelization.VoxelizedSection;
import me.cortex.voxy.common.voxelization.WorldConversionFactory;
import me.cortex.voxy.common.world.WorldEngine;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import net.minecraft.util.math.ChunkSectionPos;
import net.minecraft.world.LightType;
import net.minecraft.world.chunk.ChunkNibbleArray;
@@ -42,6 +44,7 @@ public class VoxelIngestService {
while (this.running) {
this.ingestCounter.acquireUninterruptibly();
if (!this.running) break;
try {
var chunk = this.ingestQueue.pop();
int i = chunk.getBottomSectionCoord() - 1;
for (var section : chunk.getSectionArray()) {
@@ -76,6 +79,10 @@ public class VoxelIngestService {
this.world.insertUpdate(csec);
}
}
} catch (Exception e) {
System.err.println(e);
MinecraftClient.getInstance().executeSync(()->MinecraftClient.getInstance().player.sendMessage(Text.literal("Voxy ingester had an exception while executing please check logs and report error")));
}
}
}

View File

@@ -8,14 +8,12 @@
"minecraft.MixinDebugHud",
"minecraft.MixinMinecraftClient",
"minecraft.MixinWorldRenderer",
"sodium.MixinSodiumWorldRender",
"nvidium.MixinRenderPipeline",
"sodium.MixinDefaultChunkRenderer",
"sodium.MixinRenderSectionManager",
"nvidium.MixinRenderPipeline"
"sodium.MixinSodiumWorldRender"
],
"injectors": {
"defaultRequire": 1
},
"mixins": [
]
}
}