Skip to content

Commit

Permalink
Add 1.21 as fully compatible with 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Aug 8, 2024
1 parent 3a82922 commit 60874a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 5 additions & 3 deletions loader/src/main/java/net/neoforged/fml/loading/ModSorter.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,10 @@ private static String formatIncompatibleDependencyError(IModInfo.ModVersion depe
modVersions.get(dependency.getModId()).toString());
}

private boolean modVersionNotContained(final IModInfo.ModVersion mv, final Map<String, ArtifactVersion> modVersions) {
return !(VersionSupportMatrix.testVersionSupportMatrix(mv.getVersionRange(), mv.getModId(), "mod", (modId, range) -> modVersions.containsKey(modId) &&
(range.containsVersion(modVersions.get(modId)) || modVersions.get(modId).toString().equals("0.0NONE"))));
private boolean modVersionNotContained(IModInfo.ModVersion mv, Map<String, ArtifactVersion> modVersions) {
return !(VersionSupportMatrix.testVersionSupportMatrix(mv.getVersionRange(), mv.getModId(), "mod", (modId, range) -> {
return modVersions.containsKey(modId) &&
(range.containsVersion(modVersions.get(modId)) || modVersions.get(modId).toString().equals("0.0NONE"));
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ public class VersionSupportMatrix {
private static final HashMap<String, List<ArtifactVersion>> overrideVersions = new HashMap<>();
static {
final ArtifactVersion version = new DefaultArtifactVersion(FMLLoader.versionInfo().mcVersion());
if (MavenVersionAdapter.createFromVersionSpec("[1.19.2]").containsVersion(version)) {
// 1.19.2 is Compatible with 1.19.1
add("languageloader.javafml", "42");
add("mod.minecraft", "1.19.1");
add("mod.forge", "42.0.9");
// If the MC version is 1.21.1 and any default version constraint fails,
// we'll also pass the version check if the versions below match
if (MavenVersionAdapter.createFromVersionSpec("[1.21.1]").containsVersion(version)) {
add("mod.minecraft", "1.21");
add("mod.neoforge", "21.0.166");
}
}

private static void add(String key, String value) {
overrideVersions.computeIfAbsent(key, k -> new ArrayList<>()).add(new DefaultArtifactVersion(value));
}

public static <T> boolean testVersionSupportMatrix(VersionRange declaredRange, String lookupId, String type, BiPredicate<String, VersionRange> standardLookup) {
if (standardLookup.test(lookupId, declaredRange)) return true;
List<ArtifactVersion> custom = overrideVersions.get(type + "." + lookupId);
return custom == null ? false : custom.stream().anyMatch(declaredRange::containsVersion);
public static boolean testVersionSupportMatrix(VersionRange declaredRange, String lookupId, String type, BiPredicate<String, VersionRange> standardLookup) {
if (standardLookup.test(lookupId, declaredRange)) {
return true;
}
var custom = overrideVersions.get(type + "." + lookupId);
return custom != null && custom.stream().anyMatch(declaredRange::containsVersion);
}
}

0 comments on commit 60874a3

Please sign in to comment.