Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-semver game versions #916

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import net.fabricmc.loader.impl.launch.FabricLauncher;
import net.fabricmc.loader.impl.util.log.Log;
import net.fabricmc.loader.impl.util.log.LogCategory;
import net.fabricmc.loader.impl.util.version.VersionParser;
import net.fabricmc.loader.impl.util.version.VersionPredicateParser;

public class EntrypointPatch extends GamePatch {
Expand Down Expand Up @@ -567,7 +566,7 @@ private boolean hasStrInMethod(String cls, String methodName, String methodDesc,

private Version getGameVersion() {
try {
return VersionParser.parseSemantic(gameProvider.getNormalizedGameVersion());
return Version.parse(gameProvider.getNormalizedGameVersion());
} catch (VersionParsingException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.zip.ZipInputStream;

import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.SemanticVersion;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.fabricmc.loader.impl.FabricLoaderImpl;
import net.fabricmc.loader.impl.FormattedException;
Expand Down Expand Up @@ -118,6 +119,17 @@ public List<ModCandidate> discoverMods(FabricLoaderImpl loader, Map<String, Set<

// add builtin mods
for (BuiltinMod mod : loader.getGameProvider().getBuiltinMods()) {
if (!(mod.metadata.getVersion() instanceof SemanticVersion)) {
String error = String.format("%s uses the non-semantic version %s, which doesn't support range comparisons and may cause mod dependencies against it to fail unexpectedly. Consider updating Fabric Loader or explicitly specifying the game version with the fabric.gameVersion system property.",
mod.metadata.getId(), mod.metadata.getVersion());

if (loader.isDevelopmentEnvironment()) { // fail hard in-dev
throw new FormattedException("Invalid game version", error);
} else {
Log.warn(LogCategory.GENERAL, error);
}
}

ModCandidate candidate = ModCandidate.createBuiltin(mod, versionOverrides, depOverrides);
candidates.add(MetadataVerifier.verifyIndev(candidate, loader.isDevelopmentEnvironment()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import net.fabricmc.loader.api.metadata.ModEnvironment;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.fabricmc.loader.api.metadata.Person;
import net.fabricmc.loader.impl.util.version.VersionParser;

public final class BuiltinModMetadata extends AbstractModMetadata {
private final String id;
Expand Down Expand Up @@ -172,7 +171,7 @@ public Builder(String id, String version) {
this.name = this.id = id;

try {
this.version = VersionParser.parseSemantic(version);
this.version = Version.parse(version);
} catch (VersionParsingException e) {
throw new RuntimeException(e);
}
Expand Down