diff --git a/src/main/java/me/cortex/voxy/client/Voxy.java b/src/main/java/me/cortex/voxy/client/Voxy.java index 7c76b3b1..9989edca 100644 --- a/src/main/java/me/cortex/voxy/client/Voxy.java +++ b/src/main/java/me/cortex/voxy/client/Voxy.java @@ -3,6 +3,7 @@ package me.cortex.voxy.client; import me.cortex.voxy.client.core.VoxelCore; import me.cortex.voxy.client.saver.ContextSelectionSystem; import me.cortex.voxy.client.terrain.WorldImportCommand; +import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.config.Serialization; import me.cortex.voxy.common.storage.compressors.ZSTDCompressor; import me.cortex.voxy.common.storage.config.StorageConfig; @@ -41,9 +42,4 @@ public class Voxy implements ClientModInitializer { public static void breakpoint() { int breakpoint = 0; } - - - public static void logError(Object... args) { - System.err.println(Arrays.toString(args)); - } } diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/HierarchicalNodeManager.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/HierarchicalNodeManager.java index 2646bc4d..b0f5e2b2 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/HierarchicalNodeManager.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/HierarchicalNodeManager.java @@ -8,6 +8,7 @@ import me.cortex.voxy.client.core.rendering.building.BuiltSection; import me.cortex.voxy.client.core.rendering.building.SectionUpdateRouter; import me.cortex.voxy.client.core.rendering.section.AbstractSectionGeometryManager; import me.cortex.voxy.client.core.util.ExpandingObjectAllocationList; +import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldSection; import me.jellysquid.mods.sodium.client.util.MathUtil; @@ -219,7 +220,7 @@ public class HierarchicalNodeManager { //============================================================================================================================================ public void processChildChange(long position, byte childExistence) { if (childExistence == 0) { - Voxy.logError("Section at " + WorldEngine.pprintPos(position) + " had empty child existence!!"); + Logger.logError("Section at " + WorldEngine.pprintPos(position) + " had empty child existence!!"); } int nodeId = this.activeSectionMap.get(position); if (nodeId == NO_NODE) { diff --git a/src/main/java/me/cortex/voxy/common/Logger.java b/src/main/java/me/cortex/voxy/common/Logger.java new file mode 100644 index 00000000..72050f37 --- /dev/null +++ b/src/main/java/me/cortex/voxy/common/Logger.java @@ -0,0 +1,16 @@ +package me.cortex.voxy.common; + +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class Logger { + private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger("Voxy"); + + public static void logError(Object... args) { + var stackEntry = new Throwable().getStackTrace()[1]; + LOGGER.error("["+stackEntry.getClassName()+"]: "+ Stream.of(args).map(Object::toString).collect(Collectors.joining(" "))); + } +} diff --git a/src/main/java/me/cortex/voxy/commonImpl/IGetWorldInterface.java b/src/main/java/me/cortex/voxy/commonImpl/IGetWorldInterface.java new file mode 100644 index 00000000..ca609d30 --- /dev/null +++ b/src/main/java/me/cortex/voxy/commonImpl/IGetWorldInterface.java @@ -0,0 +1,4 @@ +package me.cortex.voxy.commonImpl; + +public interface IGetWorldInterface { +} diff --git a/src/main/java/me/cortex/voxy/commonImpl/VoxyWorldService.java b/src/main/java/me/cortex/voxy/commonImpl/VoxyWorldService.java new file mode 100644 index 00000000..29107716 --- /dev/null +++ b/src/main/java/me/cortex/voxy/commonImpl/VoxyWorldService.java @@ -0,0 +1,5 @@ +package me.cortex.voxy.commonImpl; + +public class VoxyWorldService { + +} diff --git a/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java b/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java new file mode 100644 index 00000000..96abad26 --- /dev/null +++ b/src/main/java/me/cortex/voxy/commonImpl/mixin/minecraft/MixinWorld.java @@ -0,0 +1,24 @@ +package me.cortex.voxy.commonImpl.mixin.minecraft; + +import me.cortex.voxy.client.Voxy; +import me.cortex.voxy.common.world.WorldEngine; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(World.class) +public class MixinWorld { + @Unique private WorldEngine voxyWorldEngine; + + + @Inject(method = "close", at = @At("HEAD")) + private void closeVoxyWorld(CallbackInfo ci) { + if (this.voxyWorldEngine != null) { + try {this.voxyWorldEngine.shutdown();} catch (Exception e) { + } + } + } +} diff --git a/src/main/resources/voxy.mixins.json b/src/main/resources/client.voxy.mixins.json similarity index 90% rename from src/main/resources/voxy.mixins.json rename to src/main/resources/client.voxy.mixins.json index 641a7221..95d6a553 100644 --- a/src/main/resources/voxy.mixins.json +++ b/src/main/resources/client.voxy.mixins.json @@ -3,6 +3,7 @@ "package": "me.cortex.voxy.client.mixin", "compatibilityLevel": "JAVA_17", "client": [ + "chunky.MixinFabricWorld", "joml.AccessFrustumIntersection", "minecraft.MixinClientChunkManager", "minecraft.MixinDebugHud", @@ -16,8 +17,5 @@ ], "injectors": { "defaultRequire": 1 - }, - "mixins": [ - "chunky.MixinFabricWorld" - ] + } } diff --git a/src/main/resources/common.voxy.mixins.json b/src/main/resources/common.voxy.mixins.json new file mode 100644 index 00000000..2fb690da --- /dev/null +++ b/src/main/resources/common.voxy.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "me.cortex.voxy.commonImpl.mixin", + "compatibilityLevel": "JAVA_17", + "injectors": { + "defaultRequire": 1 + }, + "mixins": [ + "minecraft.MixinWorld" + ] +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7f8d11b4..b211af18 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,7 +24,8 @@ ] }, "mixins": [ - "voxy.mixins.json" + "client.voxy.mixins.json", + "common.voxy.mixins.json" ], "depends": { "minecraft": "1.21",