Skip to content

修复无法为 MC 26.1.1 从官方源安装 NeoForge 的问题#5926

Merged
Glavo merged 1 commit intoHMCL-dev:release/3.12from
Glavo:backport/3.12/5910
Apr 6, 2026
Merged

修复无法为 MC 26.1.1 从官方源安装 NeoForge 的问题#5926
Glavo merged 1 commit intoHMCL-dev:release/3.12from
Glavo:backport/3.12/5910

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix an issue where NeoForge could not be installed for Minecraft/NeoForge version 26.1.1 when using the official Maven source.

Changes:

  • Adjust NeoForge version string parsing to derive the corresponding mcVersion, adding extra validation/logging for unsupported formats.
  • Refactor the official API response model from an inner class to a record annotated with @JsonSerializable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +74 to 85
int si3 = version.indexOf('.', si2 + 1);

if (si3 < 0) {
LOG.warning("Unsupported NeoForge version: " + version);
continue;
}

String ver = Integer.parseInt(version.substring(si2 + 1, si3)) == 0
? version.substring(0, si2)
: version.substring(0, si3);

int separator = version.indexOf('+');
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For majorVersion >= 26, this parsing requires a third '.' (si3) and skips the version if it’s absent. Versions like "26.1.1" / "26.1.0" (only 2 dots, optionally with a '+') will be treated as unsupported and never added to the list, which likely reintroduces the install issue. Consider deriving the end of the patch component from the '+' (if present) or string length when no third '.' exists, instead of continueing when si3 < 0.

Suggested change
int si3 = version.indexOf('.', si2 + 1);
if (si3 < 0) {
LOG.warning("Unsupported NeoForge version: " + version);
continue;
}
String ver = Integer.parseInt(version.substring(si2 + 1, si3)) == 0
? version.substring(0, si2)
: version.substring(0, si3);
int separator = version.indexOf('+');
int separator = version.indexOf('+');
int patchEnd = separator >= 0 ? separator : version.length();
String ver = Integer.parseInt(version.substring(si2 + 1, patchEnd)) == 0
? version.substring(0, si2)
: version.substring(0, patchEnd);

Copilot uses AI. Check for mistakes.
@Glavo Glavo merged commit 997b75b into HMCL-dev:release/3.12 Apr 6, 2026
6 checks passed
@Glavo Glavo deleted the backport/3.12/5910 branch April 6, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants