Skip to content

Commit

Permalink
Fix EntrypointPatchFML125 (#732)
Browse files Browse the repository at this point in the history
* Unbreak EntrypointPatchFML125, again

It's almost like only 3 people use this or something

* Handle null values, cleaner logic

* Add explanation for workaround
  • Loading branch information
NeRdTheNed authored Oct 3, 2023
1 parent 1a9728d commit e3e644b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
!/proguard.conf

!/minecraft
!/junit
!/junit

# MacOS junk files
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package net.fabricmc.loader.impl.game.minecraft.patch;

import java.io.IOException;
import java.io.InputStream;
import java.util.function.Consumer;
import java.util.function.Function;

Expand All @@ -27,6 +29,7 @@
import net.fabricmc.loader.impl.game.patch.GamePatch;
import net.fabricmc.loader.impl.launch.FabricLauncher;
import net.fabricmc.loader.impl.launch.knot.Knot;
import net.fabricmc.loader.impl.util.LoaderUtil;
import net.fabricmc.loader.impl.util.log.Log;
import net.fabricmc.loader.impl.util.log.LogCategory;

Expand All @@ -46,7 +49,20 @@ public void process(FabricLauncher launcher, Function<String, ClassReader> class

Log.debug(LogCategory.GAME_PATCH, "Detected 1.2.5 FML - Knotifying ModClassLoader...");

ClassNode patchedClassLoader = readClass(classSource.apply(FROM));
// ModClassLoader_125_FML isn't in the game's class path, so it's loaded from the launcher's class path instead
ClassNode patchedClassLoader = new ClassNode();

try (InputStream stream = launcher.getResourceAsStream(LoaderUtil.getClassFileName(FROM))) {
if (stream != null) {
ClassReader patchedClassLoaderReader = new ClassReader(stream);
patchedClassLoaderReader.accept(patchedClassLoader, 0);
} else {
throw new IOException("Could not find class " + FROM + " in the launcher classpath while transforming ModClassLoader");
}
} catch (IOException e) {
throw new RuntimeException("An error occurred while reading class " + FROM + " while transforming ModClassLoader", e);
}

ClassNode remappedClassLoader = new ClassNode();

patchedClassLoader.accept(new ClassRemapper(remappedClassLoader, new Remapper() {
Expand Down

0 comments on commit e3e644b

Please # to comment.