Skip to content

Commit

Permalink
Fix jar path filter for game layer libraries
Browse files Browse the repository at this point in the history
Fixes #453
  • Loading branch information
Su5eD committed Oct 30, 2023
1 parent 957605b commit d159198
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.JarMetadata;
import cpw.mods.jarhandling.SecureJar;
import dev.su5ed.sinytra.connector.ConnectorUtil;
import dev.su5ed.sinytra.connector.loader.ConnectorEarlyLoader;
Expand All @@ -21,7 +22,6 @@
import net.minecraftforge.forgespi.locating.IDependencyLocator;
import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.forgespi.locating.IModLocator;
import net.minecraftforge.forgespi.locating.IModProvider;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -136,26 +136,31 @@ private List<IModFile> locateFabricMods(Iterable<IModFile> loadedMods) {
// Deal with split packages (thanks modules)
List<SplitPackageMerger.FilteredModPath> moduleSafeJars = SplitPackageMerger.mergeSplitPackages(transformed, loadedMods, ignoredModFiles);

List<IModFile> modFiles = new ArrayList<>(moduleSafeJars.stream().map(mod -> createConnectorModFile(mod, this)).toList());
List<IModFile> modFiles = new ArrayList<>(moduleSafeJars.stream().map(this::createConnectorModFile).toList());
// Create mod file for generated adapter mixins jar
Path generatedAdapterJar = JarTransformer.getGeneratedJarPath();
if (Files.exists(generatedAdapterJar)) {;
if (Files.exists(generatedAdapterJar)) {
modFiles.add(createModOrThrow(generatedAdapterJar));
}
return modFiles;
}

private IModFile createConnectorModFile(SplitPackageMerger.FilteredModPath modPath, IModProvider provider) {
private IModFile createConnectorModFile(SplitPackageMerger.FilteredModPath modPath) {
if (modPath.metadata().generated()) {
return createModOrThrow(modPath.paths());
return createGameLibraryMod(modPath);
}
ModJarMetadata mjm = ConnectorUtil.uncheckThrowable(() -> (ModJarMetadata) MJM_INIT.invoke());
SecureJar modJar = SecureJar.from(Manifest::new, jar -> mjm, modPath.filter(), modPath.paths());
IModFile mod = new ModFile(modJar, provider, modFile -> ConnectorModMetadataParser.createForgeMetadata(modFile, modPath.metadata().modMetadata()));
IModFile mod = new ModFile(modJar, this, modFile -> ConnectorModMetadataParser.createForgeMetadata(modFile, modPath.metadata().modMetadata()));
mjm.setModFile(mod);
return mod;
}

protected IModFile createGameLibraryMod(SplitPackageMerger.FilteredModPath modPath) {
SecureJar sj = SecureJar.from(Manifest::new, jar -> JarMetadata.from(jar, modPath.paths()), modPath.filter(), modPath.paths());
return new ModFile(sj, this, this::manifestParser, IModFile.Type.GAMELIBRARY.name());
}

private IModFile createModOrThrow(Path... paths) {
IModLocator.ModFileOrException moe = createMod(paths);
if (moe.ex() != null) {
Expand Down

0 comments on commit d159198

Please sign in to comment.