Skip to content

Commit

Permalink
Support non-semver game versions (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfPlayer1 committed Apr 12, 2024
1 parent 2a614a8 commit dcbda1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
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

0 comments on commit dcbda1b

Please sign in to comment.