feat(crash): ModResolutionException (Could not resolve valid mod collection)

This commit is contained in:
huanghongxun 2021-10-13 02:32:56 +08:00
parent 6b656bdc48
commit 7973179ddf
9 changed files with 53 additions and 10 deletions

View File

@ -140,6 +140,7 @@ public class GameCrashWindow extends Stage {
break;
case MOD_RESOLUTION_CONFLICT:
case MOD_RESOLUTION_MISSING:
case MOD_RESOLUTION_COLLECTION:
reasonText.append(i18n("game.crash.reason." + result.getRule().name().toLowerCase(Locale.ROOT),
translateFabricModId(result.getMatcher().group("sourcemod")),
parseFabricModId(result.getMatcher().group("destmod")),
@ -177,6 +178,8 @@ public class GameCrashWindow extends Stage {
private String translateFabricModId(String modName) {
switch (modName) {
case "fabricloader":
return "Fabric";
case "fabric":
return "Fabric API";
case "minecraft":

View File

@ -352,12 +352,13 @@ game.crash.reason.gl_operation_failure=Game crashed due to some mods, shader pac
game.crash.reason.graphics_driver=Game crashed due to a problem with your graphics driver.\nPlease update your graphics driver to the latest version.\nIf your computer has a discrete graphics card, you need to check whether the game uses itegrated/core graphics. If so, please run HMCL and game using discrete graphics card. If you still have these problems, you may consider getting a new graphics card or a new computer.
game.crash.reason.illegal_access_error=Game crashed because of some mods.\nIf you recognize: %1$s, you may update or delete the mod and try again.
game.crash.reason.jdk_9=Game cannot run because the Java version is too high.\nYou need download and install Java 8 and select the newly installed Java in game settings.
game.crash.reason.jvm_32bit=If your OS is 64-bit, please install and use 64-bit Java. If your OS is 32-bit, you may reinstall a 64-bit OS or change a new computer.
game.crash.reason.jvm_32bit=Game crashed because memory allocation exceeds the limit of 32-bit Java VM.\nIf your OS is 64-bit, please install and use 64-bit Java. If your OS is 32-bit, you may reinstall a 64-bit OS or change a new computer.\nOr, you can disable automatic memory allocation and set maxmium memory size to 1024MB or below.
game.crash.reason.loading_crashed_forge=Game crashed due to mod %1$s (%2$s) crashed.\nYou can try to delete or update it.
game.crash.reason.loading_crashed_fabric=Game crashed due to mod %1$s crashed.\nYou can try to delete or update it.
game.crash.reason.memory_exceeded=Game crashed because not enough memory for JVM to allocate.\nThis problem is caused by too small page size.\nYou need to turn off automatic memory allocation in game settings, and adjust the memory allocation down to the value that your system may handle.\nYou can also adjust the system page size to a large enough value.
game.crash.reason.mod=Game crashed because of the mod: %1$s.\nYou may update or delete the mod and try again.
game.crash.reason.mod_resolution=Game crashed because of mod resolution failure.\nFabric gives following information:\n%s
game.crash.reason.mod_resolution_collection=Game crashed because the required mod version is not compatible.\n%1$s requires %2$s.\nThis means that you need to upgrade or downgrade %2$s. You need to download %3$s.
game.crash.reason.mod_resolution_conflict=Game crashed because of conflicted mods.\n%1$s conflicts with %2$s.
game.crash.reason.mod_resolution_missing=Game crashed because the mod that some mod depends on is not installed.\n%1$s requires mod to be installed: %2$s.\nThis means that you need to download %2$s from the download page or online websites.
game.crash.reason.mod_resolution_missing_minecraft=Game crashed because a mod is incompatible with current Minecraft version.\n%1$s requires Minecraft version %2$s。\nIf you want to keep the installed version of the mod, you should change the game version.\nIf you want to continue using current game version, you should reinstall a suitable mod.

View File

@ -352,12 +352,13 @@ game.crash.reason.gl_operation_failure=當前遊戲因為你使用的某些 Mod
game.crash.reason.graphics_driver=當前遊戲因為你的顯示卡驅動存在問題崩潰了。\n請嘗試升級你的顯示卡驅動到最新版本後再嘗試啟動遊戲。\n如果你的電腦存在獨立顯示卡你需要檢查遊戲是否使用集成/核心顯示卡啟動,如果是,請嘗試使用獨立顯示卡啟動 HMCL 與遊戲。如果仍有問題,你可能需要考慮換一個新顯示卡或新電腦。
game.crash.reason.illegal_access_error=當前遊戲因為某些 Mod 的問題,無法繼續運行。\n如果你認識%1$s你可以更新或刪除對應 Mod 再試。
game.crash.reason.jdk_9=當前遊戲因為 Java 版本過高,無法繼續運行。\n你需要下載安裝 Java 8並在遊戲設置中將 Java 設置為 1.8 的版本。
game.crash.reason.jvm_32bit=如果你的電腦是 64 位系統,請下載安裝並更換 64 位 Java。如果你的電腦室 32 位系統,你或許可以重新安裝 64 位系統,或換一台新電腦。
game.crash.reason.jvm_32bit=當前遊戲因為記憶體分配過大,超過了 32 位 Java 記憶體限制,無法繼續運行。\n如果你的電腦是 64 位系統,請下載安裝並更換 64 位 Java。如果你的電腦室 32 位系統,你或許可以重新安裝 64 位系統,或換一台新電腦。\n或者你可以關閉遊戲記憶體的自動分配並且把記憶體限制調節為 1024 MB 或以下
game.crash.reason.loading_crashed_forge=當前遊戲因為模組 %1$s (%2$s) 錯誤,無法繼續運行。\n你可以嘗試刪除或更新該模組以解決問題。
game.crash.reason.loading_crashed_fabric=當前遊戲因為模組 %1$s 錯誤,無法繼續運行。\n你可以嘗試刪除或更新該模組以解決問題。
game.crash.reason.memory_exceeded=當前遊戲因為分配的記憶體過大,無法繼續運行。\n該問題是由於系統頁面文件太小導致的。\n你需要在遊戲設置中關閉遊戲記憶體的自動分配並將遊戲記憶體調低至遊戲能正常啟動為止。\n你還可以嘗試調大系統的頁面大小。
game.crash.reason.mod=當前遊戲因為 %1$s 的問題,無法繼續運行。\n你可以更新或刪除已經安裝的 %1$s 再試。
game.crash.reason.mod_resolution=當前遊戲因為 Mod 依賴問題無法繼續運行。Fabric 提供了如下訊息:\n%1$s
game.crash.reason.mod_resolution_collection=當前遊戲因為前置 Mod 版本不匹配,無法繼續運行。\n%1$s 需要前置 Mod%2$s 才能繼續運行。\n這表示你需要更新或降級前置。你可以到下載頁的模組下載或到網路上下載 %3$s。
game.crash.reason.mod_resolution_conflict=當前遊戲因為 Mod 衝突,無法繼續運行。\n%1$s 與 %2$s 不能相容。
game.crash.reason.mod_resolution_missing=當前遊戲因為缺少 Mod 前置,無法繼續運行。\n%1$s 需要前置 Mod%2$s 才能繼續運行。\n這表示你少安裝了 Mod或該 Mod 版本不夠。你可以到下載頁的模組下載,或到網路上下載 %2$s。
game.crash.reason.mod_resolution_missing_minecraft=當前遊戲因為 Mod 和 Minecraft 遊戲版本不匹配,無法繼續運行。\n%1$s 需要 Minecraft %2$s 才能運行。\n如果你要繼續使用你已經安裝的 Mod你可以選擇安裝對應的 Minecraft 版本;如果你要繼續使用當前 Minecraft 版本,你需要安裝對應版本的 Mod。

View File

@ -352,12 +352,13 @@ game.crash.reason.gl_operation_failure=当前游戏因为你使用的某些 Mod
game.crash.reason.graphics_driver=当前游戏因为你的显卡驱动存在问题崩溃了。\n请尝试升级你的显卡驱动到最新版本后再尝试启动游戏。\n如果你的电脑存在独立显卡你需要检查游戏是否使用集成/核心显卡启动。如果是,请尝试使用独立显卡启动 HMCL 与游戏。如果仍有问题,你可能需要考虑换一个新显卡或新电脑。
game.crash.reason.illegal_access_error=当前游戏因为某些 Mod 的问题,无法继续运行。\n如果你认识%1$s你可以更新或删除对应 Mod 再试。
game.crash.reason.jdk_9=当前游戏因为 Java 版本过高,无法继续运行。\n你需要下载安装 Java 8并在游戏设置中将 Java 设置为 1.8 的版本。
game.crash.reason.jvm_32bit=如果你的电脑是 64 位系统,请下载安装并更换 64 位 Java。如果你的电脑室 32 位系统,你或许可以重新安装 64 位系统,或换一台新电脑。
game.crash.reason.jvm_32bit=当前游戏因为内存分配过大,超过了 32 位 Java 内存限制,无法继续运行。\n如果你的电脑是 64 位系统,请下载安装并更换 64 位 Java。如果你的电脑室 32 位系统,你或许可以重新安装 64 位系统,或换一台新电脑。\n或者你可以关闭游戏内存的自动分配并且把内存限制调节为 1024 MB 或以下
game.crash.reason.loading_crashed_forge=当前游戏因为模组 %1$s (%2$s) 错误,无法继续运行。\n你可以尝试删除或更新该模组以解决问题。
game.crash.reason.loading_crashed_fabric=当前游戏因为模组 %1$s 错误,无法继续运行。\n你可以尝试删除或更新该模组以解决问题。
game.crash.reason.memory_exceeded=当前游戏因为分配的内存过大,无法继续运行。\n该问题是由于系统页面文件太小导致的。\n你需要在游戏设置中关闭游戏内存的自动分配并将游戏内存调低至游戏能正常启动为止。\n你还可以尝试调大系统的页面大小。
game.crash.reason.mod=当前游戏因为 %1$s 的问题,无法继续运行。\n你可以更新或删除已经安装的 %1$s 再试。
game.crash.reason.mod_resolution=当前游戏因为 Mod 依赖问题无法继续运行。Fabric 提供了如下信息:\n%1$s
game.crash.reason.mod_resolution_collection=当前游戏因为前置 Mod 版本不匹配,无法继续运行。\n%1$s 需要前置 Mod%2$s 才能继续运行。\n这表示你需要更新或降级前置。你可以到下载页的模组下载或到网上下载 %3$s。
game.crash.reason.mod_resolution_conflict=当前游戏因为 Mod 冲突,无法继续运行。\n%1$s 与 %2$s 不能兼容。
game.crash.reason.mod_resolution_missing=当前游戏因为缺少 Mod 前置,无法继续运行。\n%1$s 需要前置 Mod%2$s 才能继续运行。\n这表示你少安装了 Mod或该 Mod 版本不够。你可以到下载页的模组下载,或到网上下载 %3$s。
game.crash.reason.mod_resolution_missing_minecraft=当前游戏因为 Mod 和 Minecraft 游戏版本不匹配,无法继续运行。\n%1$s 需要 Minecraft %2$s 才能运行。\n如果你要继续使用你已经安装的 Mod你可以选择安装对应的 Minecraft 版本;如果你要继续使用当前 Minecraft 版本,你需要安装对应版本的 Mod。

View File

@ -37,7 +37,7 @@ public final class CrashReportAnalyzer {
OPENJ9(Pattern.compile("(Open J9 is not supported|OpenJ9 is incompatible)")),
TOO_OLD_JAVA(Pattern.compile("java\\.lang\\.UnsupportedClassVersionError: (.*?) version (?<expected>\\d+)\\.0"), "expected"),
JVM_32BIT(Pattern.compile("Could not reserve enough space for (.*?) object heap")),
JVM_32BIT(Pattern.compile("(Could not reserve enough space for (.*?) object heap|The specified size exceeds the maximum representable size)")),
// Some mods/shader packs do incorrect GL operations.
GL_OPERATION_FAILURE(Pattern.compile("1282: Invalid operation")),
@ -68,6 +68,7 @@ public final class CrashReportAnalyzer {
MOD_RESOLUTION_CONFLICT(Pattern.compile("ModResolutionException: Found conflicting mods: (?<sourcemod>.*) conflicts with (?<destmod>.*)"), "sourcemod", "destmod"),
MOD_RESOLUTION_MISSING(Pattern.compile("ModResolutionException: Could not find required mod: (?<sourcemod>.*) requires (?<destmod>.*)"), "sourcemod", "destmod"),
MOD_RESOLUTION_MISSING_MINECRAFT(Pattern.compile("ModResolutionException: Could not find required mod: (?<mod>.*) requires \\{minecraft @ (?<version>.*)}"), "mod", "version"),
MOD_RESOLUTION_COLLECTION(Pattern.compile("ModResolutionException: Could not resolve valid mod collection \\(at: (?<sourcemod>.*) requires (?<destmod>.*)\\)"), "sourcemod", "destmod"),
// Some mods require a file not existing, asking user to manually delete it
FILE_ALREADY_EXISTS(Pattern.compile("java\\.nio\\.file\\.FileAlreadyExistsException: (?<file>.*)"), "file"),
// Forge found some mod crashed in game loading

View File

@ -51,18 +51,34 @@ public class CrashReportAnalyzerTest {
CrashReportAnalyzer.Rule.JDK_9);
}
@Test
public void jvm32() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(
CrashReportAnalyzer.anaylze(loadLog("/logs/jvm_32bit.txt")),
CrashReportAnalyzer.Rule.JVM_32BIT);
}
@Test
public void modResolution() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(
CrashReportAnalyzer.anaylze(loadLog("/logs/mod_resolution.txt")),
CrashReportAnalyzer.Rule.MOD_RESOLUTION);
Assert.assertEquals(("Errors were found!\n" +
" - Mod test depends on mod {fabricloader @ [>=0.11.3]}, which is missing!\n" +
" - Mod test depends on mod {fabric @ [*]}, which is missing!\n" +
" - Mod test depends on mod {java @ [>=16]}, which is missing!\n").replaceAll("\\s+", ""),
" - Mod test depends on mod {fabricloader @ [>=0.11.3]}, which is missing!\n" +
" - Mod test depends on mod {fabric @ [*]}, which is missing!\n" +
" - Mod test depends on mod {java @ [>=16]}, which is missing!\n").replaceAll("\\s+", ""),
result.getMatcher().group("reason").replaceAll("\\s+", ""));
}
@Test
public void modResolutionCollection() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(
CrashReportAnalyzer.anaylze(loadLog("/logs/mod_resolution_collection.txt")),
CrashReportAnalyzer.Rule.MOD_RESOLUTION_COLLECTION);
Assert.assertEquals("tabtps-fabric", result.getMatcher().group("sourcemod"));
Assert.assertEquals("{fabricloader @ [>=0.11.1]", result.getMatcher().group("destmod"));
}
@Test
public void tooOldJava() throws IOException {
CrashReportAnalyzer.Result result = findResultByRule(

View File

@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.game;
import org.jackhuang.hmcl.util.Pair;
import org.jackhuang.hmcl.util.Range;
import org.jackhuang.hmcl.util.versioning.VersionNumber;
import org.junit.Assert;
@ -27,13 +26,13 @@ public class JavaVersionConstraintTest {
@Test
public void vanillaJava16() {
Pair<Range<VersionNumber>, Range<VersionNumber>> range = JavaVersionConstraint.findSuitableJavaVersionRange(
JavaVersionConstraint.VersionRange range = JavaVersionConstraint.findSuitableJavaVersionRange(
VersionNumber.asVersion("1.17"),
null
);
Assert.assertEquals(
Range.between(VersionNumber.asVersion("16"), VersionNumber.asVersion(JavaVersionConstraint.MAX)),
range.getKey());
range.getMandatory());
}
}

View File

@ -0,0 +1,4 @@
Invalid initial heap size: -Xms4096M
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

View File

@ -0,0 +1,17 @@
[00:39:00] [main/INFO]: Loading for game Minecraft 1.17.1
Exception in thread "main" java.lang.RuntimeException: Failed to resolve mods!
at net.fabricmc.loader.FabricLoader.load(FabricLoader.java:159)
at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:122)
at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)
Caused by: net.fabricmc.loader.discovery.ModResolutionException: Could not resolve valid mod collection (at: tabtps-fabric requires {fabricloader @ [>=0.11.1]})
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:184)
at net.fabricmc.loader.discovery.ModResolver.resolve(ModResolver.java:508)
at net.fabricmc.loader.FabricLoader.load(FabricLoader.java:157)
... 2 more
Caused by: net.fabricmc.loader.util.sat4j.specs.ContradictionException: Creating Empty clause ?
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.propagationCheck(Clauses.java:117)
at net.fabricmc.loader.util.sat4j.minisat.constraints.cnf.Clauses.sanityCheck(Clauses.java:97)
at net.fabricmc.loader.util.sat4j.minisat.constraints.MixedDataStructureDanielWL.createClause(MixedDataStructureDanielWL.java:81)
at net.fabricmc.loader.util.sat4j.minisat.core.Solver.addClause(Solver.java:401)
at net.fabricmc.loader.discovery.ModResolver.findCompatibleSet(ModResolver.java:182)
... 4 more