Skip to content

fix(install): 修复 26.1 无法列表 NeoForge 的问题#2645

Open
Pigeon0v0 wants to merge 3 commits intodevfrom
fix/neoforge
Open

fix(install): 修复 26.1 无法列表 NeoForge 的问题#2645
Pigeon0v0 wants to merge 3 commits intodevfrom
fix/neoforge

Conversation

@Pigeon0v0
Copy link
Copy Markdown
Contributor

@Pigeon0v0 Pigeon0v0 commented Mar 29, 2026

Resolve #2642

我不知道为啥这个码在 CE 这里跑不了

Summary by Sourcery

修复 Minecraft 26.1 及相关版本的 NeoForge 版本列表与继承处理问题。

Bug 修复:

  • 更正针对 Minecraft 1.26.x 及更高版本的 NeoForge 继承版本字符串生成逻辑。
  • 通过使用专用的正则表达式模式解析版本列表 JSON,修复 NeoForge 版本发现功能。

增强功能:

  • 添加可复用的辅助方法,用于从字符串中收集所有正则匹配结果。
  • 在共享正则工具中引入集中管理的 NeoForge 版本提取正则表达式模式。
Original summary in English

Summary by Sourcery

Fix NeoForge version listing and inheritance handling for Minecraft 26.1 and related versions.

Bug Fixes:

  • Correct NeoForge inheritance version string generation for Minecraft 1.26.x and later.
  • Fix NeoForge version discovery by using a dedicated regex pattern for parsing version list JSON.

Enhancements:

  • Add a reusable helper to collect all regex matches from a string.
  • Introduce a centralized regex pattern for NeoForge version extraction in the shared regex utilities.

@pcl-ce-automation pcl-ce-automation bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: M PR 大小评估:中型 labels Mar 29, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 29, 2026

Reviewer's Guide

添加可复用的正则助手和一个带类型的 NeoForge 版本正则表达式,并调整 NeoForge 版本继承逻辑和列表生成方式,以修复缺失的 26.1 版本问题。

正则助手和 NeoForge 版本列表的类图

classDiagram
    class ModBase {
        +List~string~ RegexSearch(str string, regex Regex, options RegexOptions)
        +string RegexSeek(str string, regex string, options RegexOptions)
    }

    class RegexPatterns {
        <<static>>
        +Regex DlNeoForgeVersion
        -Regex _DlNeoForgeVersion()
    }

    class ModDownload {
        +List~DlNeoForgeListEntry~ GetNeoForgeEntries(latestJson string, latestLegacyJson string)
    }

    class DlNeoForgeListEntry {
        +DlNeoForgeListEntry(name string)
    }

    ModDownload ..> ModBase : uses RegexSearch
    ModDownload ..> RegexPatterns : uses DlNeoForgeVersion
    ModDownload --> DlNeoForgeListEntry : creates
Loading

更新后的 NeoForge 条目获取流程图

flowchart TD
    A[Start GetNeoForgeEntries
latestJson, latestLegacyJson] --> B[Concatenate latestLegacyJson and latestJson]
    B --> C[Call RegexSearch
with DlNeoForgeVersion
pattern]
    C --> D[Obtain list versionNames]
    D --> E[Filter out versionName == 47.1.82]
    E --> F[For each remaining versionName
create DlNeoForgeListEntry]
    F --> G[Collect entries into list]
    G --> H[Return list of DlNeoForgeListEntry]
    H --> I[End]
Loading

文件级变更

Change Details Files
引入一个可复用的正则搜索扩展,用于返回所有匹配项并在统一位置处理异常。
  • 添加 RegexSearch(string, Regex, RegexOptions) 扩展方法,遍历 Matches 并将 Match.Value 收集到 List 中。
  • 在 try/catch 中封装匹配逻辑,通过 Log 记录异常,并在失败时返回空列表。
Plain Craft Launcher 2/Modules/Base/ModBase.vb
在核心正则工具中为 NeoForge 版本字符串定义一个编译的、强类型的正则模式。
  • 新增 DlNeoForgeVersion Regex 字段及其 GeneratedRegex 工厂方法,用于匹配 JSON 中的 NeoForge 版本标识符。
  • 将新模式放入单独的“Minecraft 下载信息”区域以便组织管理。
PCL.Core/Utils/RegexPatterns.cs
修复 NeoForge 版本继承,并将 NeoForge 列表生成切换为使用共享的正则模式。
  • 对主版本号 >= 24 的构造 Inherit 方式进行修改,改为使用“Major.Minor”,而不是对 Version.ToString() 做字符串替换。
  • 更新 GetNeoForgeEntries,使其使用 RegexPatterns.DlNeoForgeVersion 调用 RegexSearch 来提取版本,而不是使用内联正则字符串。
  • 在构造 DlNeoForgeListEntry 实例时继续过滤掉已知有问题的 NeoForge 版本 “47.1.82”。
Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb

针对关联 Issue 的评估

Issue Objective Addressed Explanation
#2642 修复 NeoForge 安装器,使在选择 Minecraft 版本 26.1 时,启动器能够列出可用的 NeoForge 版本,而不是显示“无可用版本”。

可能相关的 Issue


技巧与命令

与 Sourcery 交互

  • 触发新的代码审查: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 在审查评论下回复,要求 Sourcery 从该评论创建一个 issue。你也可以在审查评论下回复 @sourcery-ai issue 来基于该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题中任意位置写上 @sourcery-ai,即可随时生成标题。也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文任意位置写上 @sourcery-ai summary,即可在指定位置生成 PR 摘要。也可以在 pull request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 一次性解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论并且不想再看到它们,这会很有用。
  • 一次性驳回所有 Sourcery 审查: 在 pull request 中评论 @sourcery-ai dismiss,即可驳回所有现有 Sourcery 审查。尤其适用于你想以新的审查重新开始时——别忘了之后再评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

访问你的 控制面板 可进行以下操作:

  • 启用或禁用审查功能,例如 Sourcery 自动生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查指令。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Adds a reusable regex helper and a typed NeoForge-version regex, and adjusts NeoForge version inheritance logic and listing to fix missing 26.1 versions.

Class diagram for regex helpers and NeoForge version listing

classDiagram
    class ModBase {
        +List~string~ RegexSearch(str string, regex Regex, options RegexOptions)
        +string RegexSeek(str string, regex string, options RegexOptions)
    }

    class RegexPatterns {
        <<static>>
        +Regex DlNeoForgeVersion
        -Regex _DlNeoForgeVersion()
    }

    class ModDownload {
        +List~DlNeoForgeListEntry~ GetNeoForgeEntries(latestJson string, latestLegacyJson string)
    }

    class DlNeoForgeListEntry {
        +DlNeoForgeListEntry(name string)
    }

    ModDownload ..> ModBase : uses RegexSearch
    ModDownload ..> RegexPatterns : uses DlNeoForgeVersion
    ModDownload --> DlNeoForgeListEntry : creates
Loading

Flow diagram for updated NeoForge entries retrieval

flowchart TD
    A[Start GetNeoForgeEntries
latestJson, latestLegacyJson] --> B[Concatenate latestLegacyJson and latestJson]
    B --> C[Call RegexSearch
with DlNeoForgeVersion
pattern]
    C --> D[Obtain list versionNames]
    D --> E[Filter out versionName == 47.1.82]
    E --> F[For each remaining versionName
create DlNeoForgeListEntry]
    F --> G[Collect entries into list]
    G --> H[Return list of DlNeoForgeListEntry]
    H --> I[End]
Loading

File-Level Changes

Change Details Files
Introduce a reusable regex search extension that returns all matches and handles exceptions centrally.
  • Add RegexSearch(string, Regex, RegexOptions) extension that iterates Matches and collects Match.Value into a List.
  • Wrap matching in try/catch, logging exceptions via Log and returning an empty list on failure.
Plain Craft Launcher 2/Modules/Base/ModBase.vb
Define a compiled, strongly-typed regex pattern for NeoForge version strings in the core regex utility.
  • Add DlNeoForgeVersion Regex field and its GeneratedRegex factory method to match NeoForge version identifiers in JSON.
  • Place the new pattern in its own "Minecraft 下载信息" region for organization.
PCL.Core/Utils/RegexPatterns.cs
Fix NeoForge version inheritance and switch NeoForge listing to use the shared regex pattern.
  • Change construction of Inherit for major versions >= 24 to use "Major.Minor" instead of string replace on Version.ToString().
  • Update GetNeoForgeEntries to call RegexSearch with RegexPatterns.DlNeoForgeVersion instead of an inline regex string for version extraction.
  • Keep filtering out the known-bad NeoForge version "47.1.82" while constructing DlNeoForgeListEntry instances.
Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb

Assessment against linked issues

Issue Objective Addressed Explanation
#2642 Fix the NeoForge installer so that when selecting Minecraft version 26.1, the launcher can list available NeoForge versions instead of showing 'no available version'.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - 我在这里给出了一些整体性的反馈:

  • 在新的接收 RegexRegexSearch 扩展中,Optional options As RegexOptions 参数从未被使用,可以将其移除,以避免混淆并让 API 表面保持最小化。
  • 既然 RegexSearch 现在已经有一个接收 Regex 的重载,建议检查一下剩余仍然传入模式字符串的调用方,以确保各个重载之间没有歧义,并且每个调用点都在使用最合适的重载。
面向 AI 代理的提示
请根据本次代码评审中的评论进行修改:

## 总体评论
- 在新的接收 `Regex``RegexSearch` 扩展中,`Optional options As RegexOptions` 参数从未被使用,可以将其移除,以避免混淆并让 API 表面保持最小化。
- 既然 `RegexSearch` 现在已经有一个接收 `Regex` 的重载,建议检查一下剩余仍然传入模式字符串的调用方,以确保各个重载之间没有歧义,并且每个调用点都在使用最合适的重载。

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • In the new RegexSearch extension that takes a Regex, the Optional options As RegexOptions parameter is never used and can be removed to avoid confusion and keep the API surface minimal.
  • Now that RegexSearch has an overload that takes a Regex, it would be good to check for any remaining callers that pass a pattern string to ensure there’s no ambiguity between overloads and that each call site is using the most appropriate overload.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the new `RegexSearch` extension that takes a `Regex`, the `Optional options As RegexOptions` parameter is never used and can be removed to avoid confusion and keep the API surface minimal.
- Now that `RegexSearch` has an overload that takes a `Regex`, it would be good to check for any remaining callers that pass a pattern string to ensure there’s no ambiguity between overloads and that each call site is using the most appropriate overload.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M PR 大小评估:中型 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

下载26.1时,NeoForge显示无可用版本。

1 participant