Skip to content

Commit

Permalink
Develop beta 34 (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Jan 24, 2024
2 parents 02945d3 + 1661f91 commit 37ae102
Show file tree
Hide file tree
Showing 8 changed files with 619 additions and 476 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=true

# Versions
versionConnector=1.0.0-beta.33
versionAdapter=1.9.0-1.20.1-20231215.155717
versionAdapterDefinition=1.11.4
versionConnector=1.0.0-beta.34
versionAdapter=1.11.12-1.20.1-20240124.174344
versionAdapterDefinition=1.11.12

versionMc=1.20.1
versionForge=47.1.3
versionForgeAutoRenamingTool=1.0.9
versionFabricLoader=2.6.3+0.15.3+1.20.1
versionFabricLoader=2.7.1+0.15.3+1.20.1
versionAccessWidener=2.1.0
versionFabricApi=0.90.7+1.10.3+1.20.1
versionMixin=0.12.5+mixin.0.8.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ private List<IModFile> locateFabricMods(Iterable<IModFile> loadedMods) {
.toList();
Collection<String> loadedModIds = loadedModInfos.stream().filter(mod -> !mod.library()).map(SimpleModInfo::modid).collect(Collectors.toUnmodifiableSet());
// Discover fabric mod jars
List<JarTransformer.TransformableJar> discoveredJars = Stream.concat(scanModsDir(), scanClasspath())
final var excluded = ModDirTransformerDiscoverer.allExcluded();
List<JarTransformer.TransformableJar> discoveredJars = Stream.of(scanModsDir(excluded), scanClasspath(), scanFromArguments(excluded)).flatMap(s -> s)
.map(rethrowFunction(p -> cacheTransformableJar(p.toFile())))
.filter(jar -> {
String modid = jar.modPath().metadata().modMetadata().getId();
Expand Down Expand Up @@ -147,12 +148,15 @@ private List<IModFile> locateFabricMods(Iterable<IModFile> loadedMods) {
return modFiles;
}

private Stream<Path> scanModsDir() {
List<Path> excluded = ModDirTransformerDiscoverer.allExcluded();
return uncheck(() -> Files.list(FMLPaths.MODSDIR.get()))
.filter(p -> !excluded.contains(p) && StringUtils.toLowerCase(p.getFileName().toString()).endsWith(SUFFIX))
.sorted(Comparator.comparing(path -> StringUtils.toLowerCase(path.getFileName().toString())))
.filter(ConnectorLocator::isFabricModJar);
private Stream<Path> scanModsDir(List<Path> excluded) {
return filterPaths(uncheck(() -> Files.list(FMLPaths.MODSDIR.get())), excluded);
}

private Stream<Path> filterPaths(Stream<Path> stream, List<Path> excluded) {
return stream
.filter(p -> !excluded.contains(p) && StringUtils.toLowerCase(p.getFileName().toString()).endsWith(SUFFIX))
.sorted(Comparator.comparing(path -> StringUtils.toLowerCase(path.getFileName().toString())))
.filter(ConnectorLocator::isFabricModJar);
}

private Stream<Path> scanClasspath() {
Expand All @@ -177,6 +181,22 @@ private Stream<Path> scanClasspath() {
}
}

private Stream<Path> scanFromArguments(List<Path> excluded) {
final String[] paths = System.getProperty("connector.additionalModLocations", "").split(",");
if (paths.length == 0) {
return Stream.of();
}
Stream.Builder<Path> files = Stream.builder();
Arrays.stream(paths).filter(s -> !s.isBlank()).map(Path::of).forEach(path -> {
if (Files.isDirectory(path)) {
uncheck(() -> Files.list(path)).forEach(files::add);
} else {
files.add(path);
}
});
return filterPaths(files.build(), excluded);
}

private IModFile createConnectorModFile(SplitPackageMerger.FilteredModPath modPath) {
ModJarMetadata mjm = ConnectorUtil.uncheckThrowable(() -> (ModJarMetadata) MJM_INIT.invoke());
SecureJar modJar = SecureJar.from(Manifest::new, jar -> mjm, modPath.filter(), modPath.paths());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public static IModFileInfo createForgeMetadata(IModFile modFile, ConnectorLoader
Config config = Config.inMemory();
config.add("modLoader", lowCode ? "lowcodefml" : "javafml");
config.add("loaderVersion", "[0, )");
Collection<String> licenses = metadata.getLicense();
Collection<String> licenses = metadata.getLicense()
.stream().map(String::trim).filter(l -> !l.isBlank())
.toList();
config.add("license", licenses.isEmpty() ? DEFAULT_LICENSE : String.join(", ", metadata.getLicense()));

config.add("properties", Map.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dev.su5ed.sinytra.connector.transformer.jar.JarTransformer;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.VersionParsingException;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.fabricmc.loader.impl.FMLModMetadata;
import net.fabricmc.loader.impl.FabricLoaderImpl;
Expand All @@ -20,6 +21,7 @@
import net.fabricmc.loader.impl.metadata.BuiltinModMetadata;
import net.fabricmc.loader.impl.metadata.DependencyOverrides;
import net.fabricmc.loader.impl.metadata.VersionOverrides;
import net.fabricmc.loader.impl.util.version.VersionParser;
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.forgespi.locating.IModFile;
import org.slf4j.Logger;
Expand Down Expand Up @@ -103,9 +105,24 @@ private static ModCandidate createJavaMod() {

private static ModCandidate createFabricLoaderMod() {
String version = EmbeddedDependencies.getFabricLoaderVersion();
ModMetadata metadata = new BuiltinModMetadata.Builder("fabricloader", Objects.requireNonNullElse(version, "0.0NONE"))
.setName("Fabric Loader")
.build();
if (version == null) {
version = "0.0NONE";
} else {
// The patch version can be a wildcard, as some mods like to depend on the newest FLoader version
// even if it's just a bugfix that they didn't need
final String[] components = version.split("\\.");
version = components[0] + "." + components[1] + ".*";
}
ModMetadata metadata;

try {
metadata = new BuiltinModMetadata.Builder("fabricloader", VersionParser.parse(version, true))
.setName("Fabric Loader")
.build();
} catch (VersionParsingException e) {
throw new RuntimeException(e);
}

GameProvider.BuiltinMod builtinMod = new GameProvider.BuiltinMod(Collections.singletonList(Path.of(uncheck(() -> FabricLoader.class.getProtectionDomain().getCodeSource().getLocation().toURI()))), metadata);

return ModCandidate.createBuiltin(builtinMod, VERSION_OVERRIDES, DEPENDENCY_OVERRIDES);
Expand Down
Loading

0 comments on commit 37ae102

Please sign in to comment.