Skip to content

Commit

Permalink
Unbreak EntrypointPatchFML125, again
Browse files Browse the repository at this point in the history
It's almost like only 3 people use this or something
  • Loading branch information
NeRdTheNed committed Jul 13, 2023
1 parent 67bf49c commit 9d606c8
Show file tree
Hide file tree
Showing 2 changed files with 23 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,22 @@ 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));
ClassReader patchedClassLoaderReader = null;

try (InputStream stream = launcher.getResourceAsStream(LoaderUtil.getClassFileName(FROM))) {
patchedClassLoaderReader = new ClassReader(stream);
} catch (IOException e) {
String errorText = String.format("An error occurred while reading %s", FROM);
Log.error(LogCategory.GAME_PATCH, errorText, e);
}

if (patchedClassLoaderReader == null) {
throw new RuntimeException(String.format("Somehow, %s wasn't loaded", FROM));
}

ClassNode patchedClassLoader = new ClassNode();
patchedClassLoaderReader.accept(patchedClassLoader, 0);

ClassNode remappedClassLoader = new ClassNode();

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

0 comments on commit 9d606c8

Please sign in to comment.