Skip to content

fix(install): Fabric API 是否适配判断方式错误#2704

Merged
SALTWOOD merged 1 commit into
devfrom
#2701
Apr 16, 2026
Merged

fix(install): Fabric API 是否适配判断方式错误#2704
SALTWOOD merged 1 commit into
devfrom
#2701

Conversation

@wyc-26

@wyc-26 wyc-26 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

close #2701
上游:Meloong-Git/PCL#8460

Summary by Sourcery

通过利用存储的原始游戏版本数据来修复 Fabric API 版本兼容性检测,并相应调整 Fabric API 的显示标题。

Bug 修复:

  • 修正 Fabric API 兼容性检查逻辑,使其与原始游戏版本标识符进行匹配,而不是依赖解析后的显示名称。

改进:

  • 在组件文件中引入并持久化 RawGameVersions 字段,以保留未经处理的游戏版本标识符,从而实现更精确的逻辑。
  • 简化 Fabric API 条目标题格式化逻辑,移除对元数据后缀进行不必要拆分的操作。
Original summary in English

Summary by Sourcery

Fix Fabric API version compatibility detection by leveraging stored raw game version data and adjust Fabric API display titles accordingly.

Bug Fixes:

  • Correct Fabric API compatibility checks to match against raw game version identifiers instead of relying on parsed display names.

Enhancements:

  • Introduce and persist a RawGameVersions field on component files to retain unprocessed game version identifiers for more accurate logic.
  • Simplify Fabric API entry title formatting by removing unnecessary splitting on metadata suffixes.

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

sourcery-ai Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

将 Fabric API 兼容性检测从解析显示名称改为使用原始游戏版本元数据,引入 CompFile 上的 RawGameVersions 字段以存储未处理的游戏版本标识符,并简化 UI 中显示的 Fabric API 版本文本:移除对 '+' 的额外拆分,同时保持序列化和加载器检测与新字段同步。

使用 RawGameVersions 进行 Fabric API 兼容性检查的时序图

sequenceDiagram
    participant PageDownloadInstall
    participant FabricApi as CompFile_FabricApi

    PageDownloadInstall->>FabricApi: get DisplayName
    PageDownloadInstall->>PageDownloadInstall: normalize _vanillaName to targetName
    PageDownloadInstall->>FabricApi: access RawGameVersions
    FabricApi-->>PageDownloadInstall: List~string~ RawGameVersions
    PageDownloadInstall->>PageDownloadInstall: Any(f == targetName)
    alt any_match
        PageDownloadInstall-->>PageDownloadInstall: Return True (compatible)
    else no_match
        PageDownloadInstall-->>PageDownloadInstall: Return False (not compatible)
    end
Loading

更新后 CompFile 游戏版本字段的类图

classDiagram
    class CompFile {
        +List~CompLoaderType~ ModLoaders
        +List~string~ RawGameVersions
        +List~string~ GameVersions
        +List~string~ DownloadUrls
        +List~string~ RawDependencies
        +List~string~ Dependencies
        +string DisplayName
        +string StatusDescription
        +DateTime ReleaseDate
        +int DownloadCount
        +string FileName
        +JObject ToJson()
    }

    class CompLoaderType {
        <<enumeration>>
        Forge
        Fabric
        Quilt
        NeoForge
    }

    CompFile "1" --> "*" CompLoaderType : uses
    CompFile "1" --> "*" RawGameVersions : stores
    CompFile "1" --> "*" GameVersions : derives_from
Loading

文件级变更

Change Details Files
使用原始 Fabric API 游戏版本标识来进行兼容性检查,替代对显示名称进行脆弱的字符串解析。
  • 将原先复杂的字符串/正则对比逻辑(尝试在 fabricApi.DisplayName 和 _vanillaName 之间做匹配)替换为:在对特殊情况进行归一化并转小写后,对 FabricApi.RawGameVersions 执行直接成员检查。
  • 在与原始版本列表比较之前,通过替换特殊标记("∞" 和 "Combat Test 7c")来规范化目标原版版本名。
  • 简化兼容性函数:在匹配时提前返回,未匹配时返回 false,同时保留异常日志记录。
Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb
在 CompFile 上引入并贯通 RawGameVersions 列表,用于保存来自 CurseForge/Modrinth 的未处理版本字符串。
  • 在 CompFile 模型上新增只读属性 RawGameVersions,用于保存未经归一化的游戏版本标识符。
  • 在构造 CompFile 实例时,从上游 JSON 字段(CurseForge 的 "gameVersions",Modrinth 的 "game_versions")中填充 RawGameVersions。
  • 在将 CompFile 序列化回 JSON 时持久化 RawGameVersions,使其可在会话之间保留。
Plain Craft Launcher 2/Modules/Minecraft/ModComp.vb
调整下游逻辑以使用 RawGameVersions 来生成面向用户的 GameVersions 并进行加载器检测。
  • 通过已有的格式化/过滤逻辑,从 RawGameVersions 派生出更友好的 GameVersions 列表,而不是使用本地 RawVersions 变量,同时保留对快照版、预览版以及未知版本的原有行为。
  • 更新加载器检测逻辑(Forge/Fabric/Quilt/NeoForge),改为在 RawGameVersions 中检查对应标识符。
  • 更新对周快照类版本的处理逻辑,在判断某条目应视为快照版还是未知版本时,改为检查 RawGameVersions。
Plain Craft Launcher 2/Modules/Minecraft/ModComp.vb
简化下载页面和已选安装 UI 中显示的 Fabric API 版本文本。
  • 修改安装页面上的 Fabric API 标签:不再按 '+' 拆分,而是在替换 "Fabric API " 和 " build " 前缀后仅进行 Trim,从而显示包含 '+' 之后构建元数据在内的完整版本字符串。
  • 对 FabricApiDownloadListItem 的标题应用相同的简化逻辑,使其文本与新标签行为保持一致。
Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb
Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb

与关联 Issue 的对照评估

Issue Objective Addressed Explanation
#2701 修复 Fabric API 兼容性检测,使在选择游戏版本时能够正确识别并展示可用的 Fabric API 版本(例如 26.2-snapshot-2)。

可能相关的 Issue

  • #0: PR 更正 Fabric API 适配判断逻辑,修复导致无法正常更改 Fabric 版本的问题。

Tips and commands

Interacting with Sourcery

  • Trigger a new review: 在 pull request 上评论 @sourcery-ai review 来触发一次新的代码审查。
  • Continue discussions: 直接回复 Sourcery 的审查评论以继续讨论。
  • Generate a GitHub issue from a review comment: 在审查评论下回复,要求 Sourcery 从该评论创建 issue。你也可以直接回复 @sourcery-ai issue,从该评论生成一个 issue。
  • Generate a pull request title: 在 pull request 标题中任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • Generate a pull request summary: 在 pull request 正文的任意位置写上 @sourcery-ai summary,即可在该位置生成 PR 总结。你也可以在 pull request 中评论 @sourcery-ai summary 来(重新)生成总结。
  • Generate reviewer's guide: 在 pull request 中评论 @sourcery-ai guide,即可(重新)生成 Reviewer's Guide。
  • Resolve all Sourcery comments: 在 pull request 中评论 @sourcery-ai resolve 来批量标记所有 Sourcery 评论为已解决。如果你已经处理完所有评论且不希望再看到它们,这会很有用。
  • Dismiss all Sourcery reviews: 在 pull request 中评论 @sourcery-ai dismiss 来驳回所有现有的 Sourcery 审查记录。特别适合在你想从头开始一次新审查时使用——别忘了随后评论 @sourcery-ai review 触发新的审查!

Customizing Your Experience

打开你的 dashboard 以:

  • 启用或禁用诸如 Sourcery 生成的 pull request 总结、reviewer's guide 等审查功能。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查指令。
  • 调整其他审查设置。

Getting Help

Original review guide in English

Reviewer's Guide

Refactors Fabric API compatibility detection to use raw game version metadata instead of parsing display names, introduces a RawGameVersions field on CompFile for storing unprocessed game version identifiers, and simplifies Fabric API version text shown in the UI by removing extra splitting on '+' while keeping serialization and loader detection in sync with the new field.

Sequence diagram for Fabric API compatibility check using RawGameVersions

sequenceDiagram
    participant PageDownloadInstall
    participant FabricApi as CompFile_FabricApi

    PageDownloadInstall->>FabricApi: get DisplayName
    PageDownloadInstall->>PageDownloadInstall: normalize _vanillaName to targetName
    PageDownloadInstall->>FabricApi: access RawGameVersions
    FabricApi-->>PageDownloadInstall: List~string~ RawGameVersions
    PageDownloadInstall->>PageDownloadInstall: Any(f == targetName)
    alt any_match
        PageDownloadInstall-->>PageDownloadInstall: Return True (compatible)
    else no_match
        PageDownloadInstall-->>PageDownloadInstall: Return False (not compatible)
    end
Loading

Class diagram for updated CompFile game version fields

classDiagram
    class CompFile {
        +List~CompLoaderType~ ModLoaders
        +List~string~ RawGameVersions
        +List~string~ GameVersions
        +List~string~ DownloadUrls
        +List~string~ RawDependencies
        +List~string~ Dependencies
        +string DisplayName
        +string StatusDescription
        +DateTime ReleaseDate
        +int DownloadCount
        +string FileName
        +JObject ToJson()
    }

    class CompLoaderType {
        <<enumeration>>
        Forge
        Fabric
        Quilt
        NeoForge
    }

    CompFile "1" --> "*" CompLoaderType : uses
    CompFile "1" --> "*" RawGameVersions : stores
    CompFile "1" --> "*" GameVersions : derives_from
Loading

File-Level Changes

Change Details Files
Use raw Fabric API game version identifiers for compatibility checks instead of fragile string parsing of the display name.
  • Replace complex string/regex-based comparison logic that tried to match fabricApi.DisplayName and _vanillaName with a direct membership check against FabricApi.RawGameVersions after normalizing special cases and lowercasing.
  • Normalize the target vanilla version name by replacing special markers ("∞" and "Combat Test 7c") before comparing to the raw versions list.
  • Simplify the compatibility function to return early on match and fall back to false, with exception logging preserved.
Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb
Introduce and wire through a RawGameVersions list on CompFile to store unprocessed version strings from CurseForge/Modrinth.
  • Add a RawGameVersions read-only property on the CompFile model to hold unnormalized game version identifiers.
  • Populate RawGameVersions from the upstream JSON fields ("gameVersions" for CurseForge, "game_versions" for Modrinth) when constructing CompFile instances.
  • Persist RawGameVersions when serializing CompFile back to JSON so it survives across sessions.
Plain Craft Launcher 2/Modules/Minecraft/ModComp.vb
Adjust downstream logic to consume RawGameVersions for user-facing GameVersions and loader detection.
  • Derive the human-friendly GameVersions list from RawGameVersions via existing formatting/filters instead of a local RawVersions variable, preserving previous behavior for snapshots, previews, and unknown versions.
  • Update loader detection (Forge/Fabric/Quilt/NeoForge) to check RawGameVersions for the corresponding identifiers.
  • Update handling of weekly snapshot-style versions to examine RawGameVersions when deciding whether to treat an entry as snapshots vs unknown.
Plain Craft Launcher 2/Modules/Minecraft/ModComp.vb
Simplify Fabric API version text shown in the download and selected-install UI.
  • Change the Fabric API label on the install page to stop splitting on '+' and instead trim only after replacing the "Fabric API " and " build " prefixes, so the full version string (including build metadata after '+') is shown.
  • Apply the same simplification to the FabricApiDownloadListItem title so its text matches the new label behavior.
Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb
Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb

Assessment against linked issues

Issue Objective Addressed Explanation
#2701 Fix Fabric API compatibility detection so that suitable Fabric API versions (e.g., for 26.2-snapshot-2) are recognized and shown as available when selecting a game version.

Possibly linked issues

  • #0: PR 更正 Fabric API 适配判断逻辑,修复导致无法正常更改 Fabric 版本的问题。

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

  • 建议在缓存/JSON 中不包含 RawGameVersions 时,始终将它初始化为非空列表(例如 New List(Of String)),以避免在调用 .Any 或使用 New JArray(RawGameVersions) 进行序列化时出现潜在的 NullReferenceException
  • 新的 Fabric API 兼容性检查对 RawGameVersions 采用的是精确相等判断;如果之前对 _vanillaName 的部分匹配或格式化变体(例如快照/预览别名)是可以匹配的,你可能需要保留或显式重新实现必要的标准化逻辑,以避免出现回归。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- Consider ensuring `RawGameVersions` is always initialized to a non-null list (e.g., `New List(Of String)`) when the cache/json does not contain `RawGameVersions`, to avoid potential `NullReferenceException` when calling `.Any` or when serializing with `New JArray(RawGameVersions)`.
- The new Fabric API compatibility check uses an exact equality against `RawGameVersions`; if partial or formatted variants of `_vanillaName` previously matched (e.g., snapshot/preview aliases), you may want to preserve or explicitly reimplement any necessary normalization to avoid regressions.

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

Hey - I've left some high level feedback:

  • Consider ensuring RawGameVersions is always initialized to a non-null list (e.g., New List(Of String)) when the cache/json does not contain RawGameVersions, to avoid potential NullReferenceException when calling .Any or when serializing with New JArray(RawGameVersions).
  • The new Fabric API compatibility check uses an exact equality against RawGameVersions; if partial or formatted variants of _vanillaName previously matched (e.g., snapshot/preview aliases), you may want to preserve or explicitly reimplement any necessary normalization to avoid regressions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider ensuring `RawGameVersions` is always initialized to a non-null list (e.g., `New List(Of String)`) when the cache/json does not contain `RawGameVersions`, to avoid potential `NullReferenceException` when calling `.Any` or when serializing with `New JArray(RawGameVersions)`.
- The new Fabric API compatibility check uses an exact equality against `RawGameVersions`; if partial or formatted variants of `_vanillaName` previously matched (e.g., snapshot/preview aliases), you may want to preserve or explicitly reimplement any necessary normalization to avoid regressions.

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.

@wyc-26 wyc-26 requested a review from a team April 12, 2026 10:36

@Big-Cake-jpg Big-Cake-jpg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

应该没什么问题吧我觉得……?

@pcl-ce-automation pcl-ce-automation Bot added 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels Apr 16, 2026
@SALTWOOD SALTWOOD merged commit 9ccbc4c into dev Apr 16, 2026
3 checks passed
@pcl-ce-automation pcl-ce-automation Bot added 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线 and removed 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 labels Apr 16, 2026
@wyc-26 wyc-26 deleted the #2701 branch April 16, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M PR 大小评估:中型 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线

Projects

None yet

Development

Successfully merging this pull request may close these issues.

下载26.2-snapshot-2时,Fabric API 显示无可用版本。

3 participants