Skip to content

Commit 71c2fe7

Browse files
committed
Disable in Cleanroom loader
As in Java21 Math.max/min are internally optimized by the JVM, this has no need to apply when running CleanroomLoader
1 parent 83041be commit 71c2fe7

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package github.kasuminova.stellarcore.common.util;
2+
3+
@SuppressWarnings("unused")
4+
public class RuntimeEnv {
5+
private RuntimeEnv() {
6+
}
7+
8+
public static final boolean IS_CLEANROOM_LOADER = isClassInPath("com.cleanroommc.common.CleanroomContainer");
9+
10+
public static boolean isClassInPath(String className) {
11+
String classPath = className.replace('.', '/') + ".class";
12+
try {
13+
return Thread.currentThread().getContextClassLoader().getResource(classPath) != null;
14+
} catch (Throwable e) {
15+
return false;
16+
}
17+
}
18+
19+
public static boolean isClassLoaded(String className) {
20+
try {
21+
Class.forName(className);
22+
return true;
23+
} catch (Throwable e) {
24+
return false;
25+
}
26+
}
27+
}

src/main/java/github/kasuminova/stellarcore/mixin/StellarCoreEarlyMixinLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import github.kasuminova.stellarcore.common.config.StellarCoreConfig;
44
import github.kasuminova.stellarcore.common.integration.censoredasm.CensoredASMCompat;
55
import github.kasuminova.stellarcore.common.mod.Mods;
6+
import github.kasuminova.stellarcore.common.util.RuntimeEnv;
67
import github.kasuminova.stellarcore.common.util.StellarEnvironment;
78
import github.kasuminova.stellarcore.common.util.StellarLog;
89
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
@@ -40,7 +41,7 @@ public class StellarCoreEarlyMixinLoader implements IFMLLoadingPlugin {
4041
addMixinCFG("mixins.stellar_core_minecraft_nnlist.json", () -> StellarCoreConfig.PERFORMANCE.vanilla.nonNullList);
4142
addMixinCFG("mixins.stellar_core_minecraft_noglerror.json", () -> StellarCoreConfig.PERFORMANCE.vanilla.noGlError);
4243
addMixinCFG("mixins.stellar_core_minecraft_property.json", () -> StellarCoreConfig.PERFORMANCE.vanilla.propertyEnumHashCodeCache);
43-
addMixinCFG("mixins.stellar_core_minecraft_phys.json", () -> StellarCoreConfig.PERFORMANCE.vanilla.boundingBoxIntersectCheck);
44+
addMixinCFG("mixins.stellar_core_minecraft_phys.json", () -> StellarCoreConfig.PERFORMANCE.vanilla.boundingBoxIntersectCheck && !RuntimeEnv.IS_CLEANROOM_LOADER);
4445
addMixinCFG("mixins.stellar_core_minecraft_randomtick.json", () -> StellarCoreConfig.PERFORMANCE.vanilla.parallelRandomBlockTicker);
4546
addMixinCFG("mixins.stellar_core_minecraft_renderglobal.json", () -> StellarCoreConfig.PERFORMANCE.vanilla.alwaysDeferChunkUpdates);
4647
addMixinCFG("mixins.stellar_core_minecraft_resourcelocation.json", () -> StellarCoreConfig.PERFORMANCE.vanilla.resourceLocationCanonicalization && !StellarCoreConfig.PERFORMANCE.vanilla.resourceLocationCanonicalizationAsync);

0 commit comments

Comments
 (0)