Skip to content

Fix #5907: 修复无法为 MC 26.1.1 从官方源安装 NeoForge 的问题#5910

Merged
Glavo merged 2 commits intoHMCL-dev:mainfrom
Glavo:neoforge
Apr 4, 2026
Merged

Fix #5907: 修复无法为 MC 26.1.1 从官方源安装 NeoForge 的问题#5910
Glavo merged 2 commits intoHMCL-dev:mainfrom
Glavo:neoforge

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented Apr 4, 2026

No description provided.

@Glavo
Copy link
Copy Markdown
Member Author

Glavo commented Apr 4, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the NeoForge version parsing logic to accommodate changes in versioning for major version 26 and above, while also converting the OfficialAPIResult class into a Java record. Review feedback identifies a critical indexing error in the substring logic for extracting Minecraft versions, which may result in truncated or incorrect version strings. Additionally, the current check for a third dot in the version string is flagged as potentially over-restrictive, as it could cause valid version formats to be ignored.

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

修复从 NeoForge 官方 Maven 版本列表解析 Minecraft 26.1.1 对应版本失败,导致无法从官方源安装 NeoForge 的问题。

Changes:

  • 调整 NeoForge 版本字符串解析逻辑:对 majorVersion >= 26 的版本按新的段位规则提取对应的 MC 版本号(支持区分 26.126.1.1)。
  • 为无法解析/不支持的版本号增加显式告警日志并跳过处理,避免异常中断刷新流程。
  • OfficialAPIResult 从内部类改为 record,并补充 @JsonSerializable 标注以匹配项目 Gson 序列化约定。

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

Comment on lines 86 to +91
int majorVersion = Integer.parseInt(version.substring(0, si1));
if (majorVersion == 0) { // Snapshot version.
mcVersion = version.substring(si1 + 1, si2);
} else {
String ver = version.substring(0, Integer.parseInt(version.substring(si1 + 1, si2)) == 0 ? si1 : si2);
if (majorVersion >= 26) {
int si3 = version.indexOf('.', si2 + 1);
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

The parsing logic switches behavior on majorVersion >= 26, but the threshold is a magic number here and the rationale isn’t obvious from the code. Consider extracting it into a named constant (e.g., indicating the NeoForge/Minecraft versioning scheme change) or adding a short comment explaining why 26 is the cutoff, so future updates don’t accidentally break version parsing again.

Copilot uses AI. Check for mistakes.
@Glavo Glavo merged commit 8d69cbc into HMCL-dev:main Apr 4, 2026
6 checks passed
@Glavo Glavo deleted the neoforge branch April 4, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants