From 62345907099b0f2c962df8e7d0f14f0b264a34b1 Mon Sep 17 00:00:00 2001 From: FalsePattern Date: Mon, 11 Nov 2024 09:11:13 +0100 Subject: [PATCH] WIP integrate with the gtnhlib api --- build.gradle.kts | 8 +++++--- .../threadedupdates/ThreadedChunkUpdateHelper.java | 12 ++++++++++++ .../falsepattern/falsetweaks/proxy/ClientProxy.java | 7 ++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f1a5836..cb3e918 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,7 +62,9 @@ repositories { includeGroup("com.falsepattern") } } - exclusive(maven("horizon", "https://mvn.falsepattern.com/horizon"), "com.github.GTNewHorizons") + //TODO +// exclusive(maven("horizon", "https://mvn.falsepattern.com/horizon"), "com.github.GTNewHorizons") + mavenLocal() exclusive(jitpack(), "com.github.basdxz") exclusive(maven("mega_uploads", "https://mvn.falsepattern.com/gtmega_uploads"), "optifine") exclusive(mega(), "codechicken") @@ -74,8 +76,8 @@ dependencies { implementationSplit("com.falsepattern:falsepatternlib-mc1.7.10:1.4.4") compileOnly(deobf("optifine:optifine:1.7.10_hd_u_e7")) - - compileOnly("com.github.GTNewHorizons:GTNHLib:0.5.19:dev") + //TODO + compileOnly("com.github.GTNewHorizons:GTNHLib:0.5.19-ct-api.4+446e2dc21e:dev") implementation("org.joml:joml:1.10.5") implementation("it.unimi.dsi:fastutil:8.5.13") diff --git a/src/main/java/com/falsepattern/falsetweaks/modules/threadedupdates/ThreadedChunkUpdateHelper.java b/src/main/java/com/falsepattern/falsetweaks/modules/threadedupdates/ThreadedChunkUpdateHelper.java index 325d43a..388b5db 100644 --- a/src/main/java/com/falsepattern/falsetweaks/modules/threadedupdates/ThreadedChunkUpdateHelper.java +++ b/src/main/java/com/falsepattern/falsetweaks/modules/threadedupdates/ThreadedChunkUpdateHelper.java @@ -33,6 +33,8 @@ import com.falsepattern.falsetweaks.modules.threadexec.ThreadedTask; import com.falsepattern.falsetweaks.modules.triangulator.ToggleableTessellatorManager; import com.google.common.base.Preconditions; +import com.gtnewhorizon.gtnhlib.api.CapturingTesselator; +import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.FMLCommonHandler; @@ -516,6 +518,16 @@ public Tessellator getThreadTessellator() { } } + public static class GTNHLibCompat extends ThreadedChunkUpdateHelper { + @Override + public Tessellator getThreadTessellator() { + if (CapturingTesselator.isCapturing()) { + return TessellatorManager.get(); + } + return super.getThreadTessellator(); + } + } + @RequiredArgsConstructor private static class PendingTaskUpdate { public final List tasks; diff --git a/src/main/java/com/falsepattern/falsetweaks/proxy/ClientProxy.java b/src/main/java/com/falsepattern/falsetweaks/proxy/ClientProxy.java index ba352ec..393497c 100644 --- a/src/main/java/com/falsepattern/falsetweaks/proxy/ClientProxy.java +++ b/src/main/java/com/falsepattern/falsetweaks/proxy/ClientProxy.java @@ -39,6 +39,7 @@ import com.falsepattern.falsetweaks.modules.triangulator.calibration.Calibration; import com.falsepattern.falsetweaks.modules.voxelizer.loading.LayerMetadataSection; import com.falsepattern.falsetweaks.modules.voxelizer.loading.LayerMetadataSerializer; +import cpw.mods.fml.common.Loader; import lombok.val; import net.minecraft.client.Minecraft; @@ -104,7 +105,11 @@ public String call() { public void init(FMLInitializationEvent e) { super.init(e); if (ModuleConfig.THREADED_CHUNK_UPDATES()) { - ThreadedChunkUpdateHelper.instance = new ThreadedChunkUpdateHelper(); + if (Loader.isModLoaded("gtnhlib")) { + ThreadedChunkUpdateHelper.instance = new ThreadedChunkUpdateHelper.GTNHLibCompat(); + } else { + ThreadedChunkUpdateHelper.instance = new ThreadedChunkUpdateHelper(); + } ThreadedChunkUpdateHelper.instance.init(); } }