Skip to content

Commit

Permalink
FalseTweaks threaded rendering compat
Browse files Browse the repository at this point in the history
  • Loading branch information
FalsePattern committed Aug 22, 2024
1 parent 487393a commit a7c3168
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {

compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:0.4.0") { transitive = false }

compileOnly("com.falsepattern:falsetweaks-mc1.7.10:3.1.1:api")
compileOnly('org.jetbrains:annotations:24.0.1')
compileOnly("org.projectlombok:lombok:1.18.22") {transitive = false }
annotationProcessor("org.projectlombok:lombok:1.18.22")
Expand Down
5 changes: 4 additions & 1 deletion repositories.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Add any additional repositories for your dependencies here

repositories {

maven {
name = "mavenpattern"
url = "https://mvn.falsepattern.com/releases/"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.gtnewhorizon.gtnhlib.compat;

import com.falsepattern.falsetweaks.api.Modules;

public class FalseTweaksCompat {

private static final boolean PRESENT;

static {
boolean present = false;
try {
Modules.class.getName();
present = true;
} catch (Throwable ignored) {}
PRESENT = present;
}

public static boolean threadingActive() {
if (PRESENT) {
return ThreadingCompat.threadingActive();
} else {
return false;
}
}

private static class ThreadingCompat {

public static boolean threadingActive() {
return Modules.threadingActive();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;

import com.gtnewhorizon.gtnhlib.compat.FalseTweaksCompat;
import com.gtnewhorizon.gtnhlib.core.transformer.TessellatorRedirectorTransformer;

import cpw.mods.fml.common.Loader;
Expand Down Expand Up @@ -35,7 +36,7 @@ public String[] getLaunchArguments() {
final boolean rfbLoaded = Launch.blackboard.getOrDefault("gtnhlib.rfbPluginLoaded", Boolean.FALSE)
== Boolean.TRUE;

if (!rfbLoaded && !(Loader.isModLoaded("Optifine") || Loader.isModLoaded("FastCraft"))) {
if (!rfbLoaded && !FalseTweaksCompat.threadingActive() && !(Loader.isModLoaded("Optifine") || Loader.isModLoaded("FastCraft"))) {
// Run after Mixins, but before LWJGl3ify
Launch.classLoader.registerTransformer(TessellatorRedirectorTransformer.class.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.objectweb.asm.tree.MethodNode;

import com.gtnewhorizon.gtnhlib.asm.ClassConstantPoolParser;
import com.gtnewhorizon.gtnhlib.compat.FalseTweaksCompat;

public class TessellatorRedirectorTransformer implements IClassTransformer {

Expand All @@ -36,7 +37,7 @@ public static List<String> getTransformerExclusions() {
}

public boolean shouldRfbTransform(byte[] basicClass) {
return cstPoolParser.find(basicClass, true);
return !FalseTweaksCompat.threadingActive() && cstPoolParser.find(basicClass, true);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/gtnewhorizon/gtnhlib/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import java.util.stream.Collectors;

import com.gtnewhorizon.gtnhlib.GTNHLib;
import com.gtnewhorizon.gtnhlib.compat.FalseTweaksCompat;

import cpw.mods.fml.relauncher.FMLLaunchHandler;

public enum Mixins {

TESSELLATOR(new Builder("Sodium").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT).setPhase(Phase.EARLY)
.setApplyIf(() -> true).addExcludedMod(TargetedMod.OPTIFINE).addExcludedMod(TargetedMod.FASTCRAFT)
.addMixinClasses("MixinTessellator")),
.setApplyIf(() -> !FalseTweaksCompat.threadingActive()).addExcludedMod(TargetedMod.OPTIFINE)
.addExcludedMod(TargetedMod.FASTCRAFT).addMixinClasses("MixinTessellator")),
WAVEFRONT_VBO(new Builder("WavefrontObject").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).setApplyIf(() -> true).addExcludedMod(TargetedMod.OPTIFINE)
.addExcludedMod(TargetedMod.FASTCRAFT).addMixinClasses("MixinWavefrontObject")),;
Expand Down

0 comments on commit a7c3168

Please sign in to comment.