Skip to content

Commit

Permalink
Try to avoid more class loading issues... Again
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmuscaria committed Feb 2, 2024
1 parent ba95571 commit 20bc506
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 26 deletions.
25 changes: 13 additions & 12 deletions patches/cpw/mods/fml/relauncher/CoreModManager.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
@@ -31,6 +32,8 @@
@@ -31,6 +32,9 @@
import java.util.jar.Attributes;
import java.util.jar.JarFile;

+import io.github.crucible.CrucibleModContainer;
+import io.github.crucible.bootstrap.CrucibleCoremodHook;
+import io.github.crucible.bootstrap.CrucibleServerMainHook;
import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
@@ -57,10 +60,11 @@
@@ -57,10 +61,11 @@
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;

public class CoreModManager {
Expand All @@ -41,15 +42,15 @@
private static List<String> loadedCoremods = Lists.newArrayList();
private static List<FMLPluginWrapper> loadPlugins;
private static boolean deobfuscatedEnvironment;
@@ -70,6 +74,7 @@
@@ -70,6 +75,7 @@
private static List<String> accessTransformers = Lists.newArrayList();

private static class FMLPluginWrapper implements ITweaker {
+
public final String name;
public final IFMLLoadingPlugin coreModInstance;
public final List<String> predepends;
@@ -99,14 +104,17 @@
@@ -99,14 +105,17 @@
}

@Override
Expand All @@ -75,7 +76,7 @@
FMLRelaunchLog.fine("Injection complete");

FMLRelaunchLog.fine("Running coremod plugin for %s {%s}", name, coreModInstance.getClass().getName());
@@ -160,6 +168,9 @@
@@ -160,6 +169,9 @@

}

Expand All @@ -85,17 +86,17 @@
public static void handleLaunch(File mcDir, LaunchClassLoader classLoader, FMLTweaker tweaker)
{
CoreModManager.mcDir = mcDir;
@@ -206,6 +217,9 @@
@@ -206,6 +218,9 @@
}

FMLRelaunchLog.fine("All fundamental core mods are successfully located");
+ // Crucible start - too lazy for creating a coremod
+ CrucibleServerMainHook.coremodHandleLaunch(mcDir, classLoader, tweaker);
+ CrucibleCoremodHook.coremodHandleLaunch(mcDir, classLoader, tweaker);
+ // Crucible end
// Now that we have the root plugins loaded - lets see what else might
// be around
String commandLineCoremods = System.getProperty("fml.coreMods.load", "");
@@ -219,7 +233,19 @@
@@ -219,7 +234,19 @@
loadCoreMod(classLoader, coreModClassName, null);
}
discoverCoreMods(mcDir, classLoader);
Expand All @@ -116,7 +117,7 @@
}

private static void discoverCoreMods(File mcDir, LaunchClassLoader classLoader)
@@ -336,6 +362,10 @@
@@ -336,6 +363,10 @@
String cascadedTweaker = mfAttributes.getValue("TweakClass");
if (cascadedTweaker != null)
{
Expand All @@ -127,7 +128,7 @@
FMLRelaunchLog.info("Loading tweaker %s from %s", cascadedTweaker, coreMod.getName());
Integer sortOrder = Ints.tryParse(Strings.nullToEmpty(mfAttributes.getValue("TweakOrder")));
sortOrder = (sortOrder == null ? Integer.valueOf(0) : sortOrder);
@@ -365,6 +395,10 @@
@@ -365,6 +396,10 @@
FMLRelaunchLog.fine("Not found coremod data in %s", coreMod.getName());
continue;
}
Expand All @@ -138,7 +139,7 @@
// Support things that are mod jars, but not FML mod jars
try
{
@@ -377,40 +411,76 @@
@@ -377,40 +412,76 @@
else
{
FMLRelaunchLog.finer("Found FMLCorePluginContainsFMLMod marker in %s, it will be examined later for regular @Mod instances",
Expand Down Expand Up @@ -232,7 +233,7 @@
}

/**
@@ -467,19 +537,22 @@
@@ -467,19 +538,22 @@
MCVersion requiredMCVersion = coreModClazz.getAnnotation(IFMLLoadingPlugin.MCVersion.class);
if (!Arrays.asList(rootPlugins).contains(coreModClass) && (requiredMCVersion == null || Strings.isNullOrEmpty(requiredMCVersion.value())))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.github.crucible.bootstrap;

import cpw.mods.fml.common.launcher.FMLTweaker;
import net.minecraft.launchwrapper.LaunchClassLoader;

import java.io.File;

public class CrucibleCoremodHook {
// Too lazy for a coremod
public static void coremodHandleLaunch(File mcDir, LaunchClassLoader classLoader, FMLTweaker tweaker) {
classLoader.addClassLoaderExclusion("io.github.crucible.bootstrap.");
try {
// Ensure our config is loaded way before everything that may need it
Class.forName("io.github.crucible.CrucibleConfigs", true, classLoader);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
Lwjgl3ifyGlue.doCoremodWork(classLoader);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,4 @@ public static void restoreStreams() {
System.setOut(originalOut);
System.setErr(originalErr);
}

// Too lazy for a coremod
public static void coremodHandleLaunch(File mcDir, LaunchClassLoader classLoader, FMLTweaker tweaker) {
classLoader.addClassLoaderExclusion("io.github.crucible.bootstrap.");
try {
// Ensure our config is loaded way before everything that may need it
Class.forName("io.github.crucible.CrucibleConfigs", true, classLoader);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
Lwjgl3ifyGlue.doCoremodWork(classLoader);
}
}
9 changes: 7 additions & 2 deletions src/main/java/io/github/crucible/bootstrap/Lwjgl3ifyGlue.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,20 @@ public class Lwjgl3ifyGlue {
};

public static void checkJava() {
System.out.println("[Crucible] Crucible now supports Java 8-17 by embedding a modified version of lwjgl3ify (https://github.com/GTNewHorizons/lwjgl3ify/).");
System.out.println("[Crucible] Do not report issues to upstream. All issues with newer Java version must be reported to Crucible's issue tracker instead.");
final String specVer = System.getProperty("java.specification.version");

// Is there any jvm where the specs is 8 instead of 1.8?
if (!Boolean.getBoolean("crucible.weAreJava9") && !(specVer.equals("1.8"))) {
System.out.println("[Crucible] Looks like you are missing the special java9+, the server may not launch without them.");
}

if (specVer.equals("1.8")) {
System.out.println("[Crucible] Crucible now supports Java 8-21 by embedding a modified version of lwjgl3ify (https://github.com/GTNewHorizons/lwjgl3ify/).");
} else {
System.out.println("[Crucible] Crucible is running modified version of lwjgl3ify (https://github.com/GTNewHorizons/lwjgl3ify/).");
}
System.out.println("[Crucible] Do not report issues to upstream. All issues with newer Java version must be reported to Crucible's issue tracker instead.");

if (!Boolean.getBoolean("lwjgl3ify.skipjavacheck")) {
if (specVer.equals("17")) {
try {
Expand Down

0 comments on commit 20bc506

Please sign in to comment.