Skip to content

Commit 2117d31

Browse files
committed
fix mod loading
1 parent aa1c52d commit 2117d31

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

fabric-loader/minecraft/src/main/java/net/fabricmc/loader/impl/game/minecraft/MinecraftGameProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public class MinecraftGameProvider implements GameProvider {
9191
private boolean hasModLoader = false;
9292

9393
private final GameTransformer transformer = new GameTransformer(
94-
/*new EntrypointPatch(this),
95-
new BrandingPatch(),*/
94+
new EntrypointPatch(this),
95+
/*new BrandingPatch(),*/
9696
new EntrypointPatchFML125(),
9797
new TinyFDPatch());
9898

@@ -527,7 +527,7 @@ public void unlockClassPath(FabricLauncher launcher) {
527527

528528
@Override
529529
public void launch(ClassLoader loader) {
530-
String targetClass = "org.bukkit.craftbukkit.Main";
530+
String targetClass = System.getProperty("banner.entrypoint"); // Banner - we need org.bukkit.craftbukkit.Main there, but we still need to patch the original server main method in EntrypointPatch.
531531

532532
if (envType == EnvType.CLIENT && targetClass.contains("Applet")) {
533533
targetClass = "net.fabricmc.loader.impl.game.minecraft.applet.AppletMain";

fabric-loader/minecraft/src/main/java/net/fabricmc/loader/impl/game/minecraft/patch/EntrypointPatch.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void process(FabricLauncher launcher, Function<String, ClassNode> classSo
107107

108108
if (gameEntrypoint == null) {
109109
// main method searches
110-
MethodNode mainMethod = findMethod(mainClass, (method) -> method.name.equals("main") && method.desc.equals("([Ljava/lang/String;)V") && isPublicStatic(method.access));
110+
MethodNode mainMethod = findMethod(mainClass, (method) -> method.name.equals("main") && method.desc.equals("(Ljoptsimple/OptionSet;)V") && isPublicStatic(method.access));
111111

112112
if (mainMethod == null) {
113113
throw new RuntimeException("Could not find main method in " + entrypoint + "!");
@@ -310,7 +310,7 @@ public void process(FabricLauncher launcher, Function<String, ClassNode> classSo
310310
}
311311
}
312312
} else {
313-
gameMethod = findMethod(mainClass, (method) -> method.name.equals("main") && method.desc.equals("([Ljava/lang/String;)V") && isPublicStatic(method.access));
313+
gameMethod = findMethod(mainClass, (method) -> method.name.equals("main") && method.desc.equals("(Ljoptsimple/OptionSet;)V") && isPublicStatic(method.access));
314314
}
315315

316316
if (gameMethod == null) {
@@ -362,7 +362,7 @@ public void process(FabricLauncher launcher, Function<String, ClassNode> classSo
362362
// If we do not find this, then we are certain this is 20w22a.
363363
MethodNode serverStartMethod = findMethod(mainClass, method -> {
364364
if ((method.access & Opcodes.ACC_SYNTHETIC) == 0 // reject non-synthetic
365-
|| method.name.equals("main") && method.desc.equals("([Ljava/lang/String;)V") // reject main method (theoretically superfluous now)
365+
|| method.name.equals("main") && method.desc.equals("(Ljoptsimple/OptionSet;)V") // reject main method (theoretically superfluous now)
366366
|| VERSION_25w14craftmine.test(gameVersion) && method.parameters.size() < 10) { // reject problematic extra methods
367367
return false;
368368
}

paperclip/java17/src/main/java/io/papermc/paperclip/Paperclip.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ public static void main(final String[] args) {
2626
FabricInstaller.LaunchData launchData = FabricInstaller.initialize(); // Banner
2727
final URL[] classpathUrls = setupClasspath();
2828
FabricInstaller.setLibraryURLs(classpathUrls); // Banner
29+
FabricInstaller.setupRemappingClasspath(classpathUrls, launchData); // Banner
2930
final URLClassLoader classLoader = FabricInstaller.createFabricLoaderClassLoader(launchData); // Banner
31+
final String mainClassName = findMainClass();
32+
System.setProperty("banner.entrypoint", mainClassName); // Banner - Used in fabric loader in MinecraftGameProvider#launch
3033
System.out.println("Starting " + "net.fabricmc.loader.impl.game.minecraft.BundlerClassPathCapture");// Banner - implement fabric loader
31-
3234
final Thread runThread = new Thread(() -> {
3335
try {
3436
// Banner start
@@ -136,6 +138,19 @@ private static FileEntry[] findFileEntries(final String fileName) {
136138
}
137139
}
138140

141+
private static String findMainClass() {
142+
final String mainClassName = System.getProperty("bundlerMainClass");
143+
if (mainClassName != null) {
144+
return mainClassName;
145+
}
146+
147+
try {
148+
return Util.readResourceText("/META-INF/main-class");
149+
} catch (final IOException e) {
150+
throw Util.fail("Failed to read main-class file", e);
151+
}
152+
}
153+
139154
private static Map<String, Map<String, URL>> extractAndApplyPatches(final Path originalJar, final PatchEntry[] patches, final Path repoDir) {
140155
if (originalJar == null && patches.length > 0) {
141156
throw new IllegalArgumentException("Patch data found without patch target");

0 commit comments

Comments
 (0)