Skip to content

Commit

Permalink
stage2/fabric: Support for fabric-loader 0.16.1
Browse files Browse the repository at this point in the history
ModCandidate was renamed to ModCandidateImpl:
FabricMC/fabric-loader@da94132

remapMod appears to still be broken due to a separate preexisting issue,
but since it is only required for dev environments, this can be fixed
later.

Linear: EM-2887
  • Loading branch information
DJtheRedstoner committed Aug 18, 2024
1 parent f1423fd commit 051f2cd
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,14 @@ private ModMetadata parseModMetadata(final Path modPath, final Path fabricJson)

@SuppressWarnings("UnstableApiUsage")
public void remapMod(ModMetadata metadata, Path inputPath, Path outputPath) throws Exception {
Class<?> ModCandidate = findImplClass("discovery.ModCandidate");
Class<?> ModCandidate;
try {
// fabric-loader 0.16.1
ModCandidate = findImplClass("discovery.ModCandidateImpl");
} catch (ClassNotFoundException e) {
// fabric-loader 0.16.0
ModCandidate = findImplClass("discovery.ModCandidate");
}
Class<?> ModResolver = findImplClass("discovery.ModResolver");
Class<?> RuntimeModRemapper = findImplClass("discovery.RuntimeModRemapper");

Expand Down Expand Up @@ -313,7 +320,14 @@ public void remapMod(ModMetadata metadata, Path inputPath, Path outputPath) thro

private Object createCandidate(Path path, URL url, Object metadata) throws ClassNotFoundException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException {
Class<?> LoaderModMetadata = findImplClass("metadata.LoaderModMetadata");
Class<?> ModCandidate = findImplClass("discovery.ModCandidate");
Class<?> ModCandidate;
try {
// fabric-loader 0.16.1
ModCandidate = findImplClass("discovery.ModCandidateImpl");
} catch (ClassNotFoundException e) {
// fabric-loader 0.16.0
ModCandidate = findImplClass("discovery.ModCandidate");
}
try {
// fabric loader 0.11
return ModCandidate.getConstructor(LoaderModMetadata, URL.class, int.class, boolean.class)
Expand Down Expand Up @@ -384,9 +398,10 @@ private void injectFakeMod(final Path path, final URL url, final ModMetadata met
.newInstance(metadata, path);
} catch (NoSuchMethodException e1) {
// fabric-loader 0.13
Object modCandidate = createCandidate(path, url, metadata);
modContainer = ModContainerImpl
.getConstructor(findImplClass("discovery.ModCandidate"))
.newInstance(createCandidate(path, url, metadata));
.getConstructor(modCandidate.getClass())
.newInstance(modCandidate);
}
}
mods.add(modContainer);
Expand Down

0 comments on commit 051f2cd

Please sign in to comment.