Skip to content

Commit

Permalink
Add some basic detection when we have a mismatch between the mappings…
Browse files Browse the repository at this point in the history
… version and the game version.

This just makes the error more understandable as to what's gone wrong.
  • Loading branch information
AlexIIL committed Oct 22, 2023
1 parent 43e45e5 commit a271da6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ group = org.quiltmc
description = The mod loading component of Quilt
url = https://github.com/quiltmc/quilt-loader
# Don't forget to change this in QuiltLoaderImpl as well
quilt_loader = 0.21.2-beta.1
quilt_loader = 0.21.2-beta.2

# Fabric & Quilt Libraries
asm = 9.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.quiltmc.loader.impl.game.minecraft;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand All @@ -32,6 +33,8 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.quiltmc.loader.api.ModDependency;
import org.quiltmc.loader.api.ModDependencyIdentifier;
Expand Down Expand Up @@ -378,10 +381,31 @@ public void initialize(QuiltLauncher launcher) {
launcher.hideParentPath(obf);
}

obfJars = GameProviderHelper.deobfuscate(obfJars,
getGameId(), getNormalizedGameVersion(),
getLaunchDirectory(),
launcher);
try {
obfJars = GameProviderHelper.deobfuscate(obfJars,
getGameId(), getNormalizedGameVersion(),
getLaunchDirectory(),
launcher);
} catch (RuntimeException e) {
if ("Unfixable conflicts".equals(e.getMessage())) {
String source = launcher.getMappingConfiguration().getMappingsSource().replace(File.separator, "/");
// Check for known cases
// Intermediary
Pattern intermediary = Pattern.compile(".+/net/fabricmc/intermediary/([^/]+)/intermediary-([^/]+)\\.jar.+");
Matcher matcher = intermediary.matcher(source);
if (matcher.matches()) {
String version1 = matcher.group(1);
String version2 = matcher.group(2);
if (version1.equals(version2)) {
// Okay, probably an intermediary version
if (!version1.equals(getRawGameVersion())) {
throw new RuntimeException("Mappings version is mismatched with minecraft version " + version1 + " vs mc " + getRawGameVersion(), e);
}
}
}
}
throw e;
}

for (int i = 0; i < gameJars.size(); i++) {
Path newJar = obfJars.get(names[i]);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/quiltmc/loader/impl/QuiltLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public final class QuiltLoaderImpl {

public static final int ASM_VERSION = Opcodes.ASM9;

public static final String VERSION = "0.21.2-beta.1";
public static final String VERSION = "0.21.2-beta.2";
public static final String MOD_ID = "quilt_loader";
public static final String DEFAULT_MODS_DIR = "mods";
public static final String DEFAULT_CACHE_DIR = ".cache";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public final class MappingConfiguration {

private String gameId;
private String gameVersion;
private String mappingsSource;
private TinyTree mappings;

public String getGameId() {
Expand All @@ -57,6 +58,12 @@ public String getGameVersion() {
return gameVersion;
}

public String getMappingsSource() {
initialize();

return mappingsSource;
}

public boolean matches(String gameId, String gameVersion) {
initialize();

Expand Down Expand Up @@ -112,6 +119,7 @@ private void initialize() {

if (mappings.getMetadata().getNamespaces().contains(getTargetNamespace())) {
this.mappings = mappings;
this.mappingsSource = url.toString();
break;
}

Expand Down

0 comments on commit a271da6

Please sign in to comment.