修复无法为 MC 26.1.1 从官方源安装 NeoForge 的问题#5926
Conversation
Co-authored-by: Burning_TNT <pangyl08@163.com>
There was a problem hiding this comment.
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
recordannotated with@JsonSerializable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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('+'); |
There was a problem hiding this comment.
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.
| 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); |
#5910