跳到主要内容

从 Fabric 移植到 NeoForge

本文说明原版 Fabric 版本(Apace100/origins-fabric)与 NeoForge 重写版(IAFEnvoy/Origins-NeoForge)之间的差异。你可以用它把现有的数据包、扩展模组或文档从 Fabric 版本转换为 NeoForge 版本。

信息

你可以尝试使用自动转换器来完成数据包的自动转换,但务必仔细检查输出,并根据本指南列出的差异进行必要的手动调整。


数据路径变化​

所有 JSON 文件都从自定义路径迁移到**原版数据包注册表(DataPack Registry)**路径。

内容Fabric 路径NeoForge 路径
起源data/<ns>/origins/data/<ns>/origins/origin/
能力data/<ns>/powers/data/<ns>/origins/power/
起源层data/<ns>/origin_layers/data/<ns>/origins/layer/
徽章(Fabric 中不存在)data/<ns>/origins/badge/
全局能力集data/<ns>/global_powers/data/<ns>/origins/global_powers/

操作: 移动文件,并加上注册表子目录(origin/、power/、layer/、badge/)。


起源 JSON 变化​

字段状态备注
name改为可选更推荐使用翻译键 origin.<ns>.<path>.name
description改为可选更推荐使用翻译键 origin.<ns>.<path>.description
loading_priority❌ 已移除数据包现在按优先级自然覆盖
powers已改变现在支持 #tag 引用。优先使用 #tag,而不是逐个列出能力 ID
icon已改变从 Item+Damage+NBT 改为 {"id": "minecraft:feather"}
order已改变默认值从 0 改为 Integer.MAX_VALUE
impact未变0=None,1=Low,2=Medium,3=High
unchoosable未变
upgrades未变

操作: 从所有起源 JSON 中移除 name/description/loading_priority。改为通过语言文件添加 name/description。把 icon 更新为新的 {"id": "..."} 格式。尽可能在 powers 中使用 #tag 引用,而不是逐个列出能力 ID。


起源层 JSON 变化​

字段状态备注
replace❌ 已移除使用数据包覆盖行为
name改为可选更推荐使用翻译键 layer.<ns>.<path>.name
missing_name❌ 已移除不再需要
missing_description❌ 已移除不再需要
origins已改变现在支持 #tag 引用。优先使用 #tag,而不是逐个列出起源 ID
gui_title.choose_origin已重命名原本是顶层的 choose_origin;现在嵌套在 gui_title 下
gui_title.view_origin已重命名原本是顶层的 view_origin;现在嵌套在 gui_title 下
order未变
enabled未变
allow_random未变
hidden未变
auto_choose未变
default_origin未变
allow_random_unchoosable未变
exclude_random未变

操作: 把 choose_origin/view_origin 移到 gui_title 下。移除 replace/name/missing_name/missing_description。尽可能在 origins 中使用 #tag 引用,而不是逐个列出起源 ID。


能力 JSON 变化​

字段状态备注
hidden未变
condition未变实体条件
loading_priority未变
badges未变支持内联 {badge} 对象
type未变能力类型 ID

操作: 能力 JSON 基本兼容。通过 power.<ns>.<path>.name / .description 键翻译能力名称和描述。

origins:multiple — 拆分为单独文件​

Fabric 的 origins:multiple 能力类型(把多个子能力打包进一个 JSON 文件)在 NeoForge 中不存在。每个子能力都必须提取为独立的、单独的能力 JSON 文件。

FabricNeoForge
一个包含嵌套子能力的 multiple JSON每个能力一个文件,分别引用
"type": "origins:multiple" 加 "powers": [...]每个能力都有自己的文件,放在 data/<ns>/origins/power/

操作: 为 origins:multiple 的 powers 列表中的每个条目创建一个单独的能力 JSON 文件。在起源的 powers 字段或能力 #tag 中引用所有拆分后的能力 ID。


已移除的条件类型​

Fabric 类型在 NeoForge 中的状态备注
origins:command❌ 已移除
origins:entity_group⚠️ 作为能力重新引入origins:entity_group 现在提供有限的战斗组兼容性;通用类型标签检查请使用 origins:in_tag
origins:category(生物群系)❌ 已移除1.21.1 不再有生物群系类别,请改用 origins:in_tag
origins:high_humidity(生物群系)❌ 已移除1.21.1 不再有湿度条件,请改用 origins:in_tag
origins:owner(双实体)❌ 已移除后续会添加

新特性​

特性备注
数据包注册表系统所有 Origins JSON 都使用原版数据包注册表
能力标签在起源的 powers 和起源层的 origins 中引用 #tag
徽章注册表徽章使用位于 origins:badge 的原版注册表
内联徽章定义能力中的 badges 可以接受内联 {badge} 对象
ColorSettingsred/green/blue/alpha 浮点数,外加单个 color 十六进制整数

关键 API 差异​

Fabric(Apoli)APINeoForge API
PowerTypeRegistry通过 Registry 访问 PowerRegistries.POWER_KEY
OriginsRegistryOriginRegistries.ORIGIN_KEY
OriginLayerRegistryLayerRegistries.LAYER_KEY
OriginsAPI以 attachment 形式使用 OriginDataHolder.get(entity)
PowerType 接口带 MapCodec 的 Power 抽象类
PowerHolderComponentOriginDataHolder(NeoForge attachment)
PowerTypeRegistry#registerBuiltInRegistries + DeferredRegister 模式

操作: 对于面向 NeoForge 的 Java 扩展模组,从 Apoli 的 PowerTypeRegistry 移植到 NeoForge 的 DeferredRegister<MapCodec<? extends Power>> 模式。


AI 移植提示词​

在把 Fabric Origins 数据包转换为 NeoForge 版本时,使用以下提示词:

You are porting an Origins Fabric data pack to the NeoForge version (IAFEnvoy/Origins-NeoForge).

Changes to apply:
1. Move all JSON files to datapack registry paths:
- origin JSONs: data/<ns>/origins/ → data/<ns>/origins/origin/
- power JSONs: data/<ns>/powers/ → data/<ns>/origins/power/
- layer JSONs: data/<ns>/origin_layers/ → data/<ns>/origins/layer/
2. Remove from Origin JSONs: name, description, loading_priority.
Add translations to language file: "origin.<ns>.<id>.name" and ".description".
3. Remove from Layer JSONs: replace, name, missing_name, missing_description.
Move choose_origin/view_origin under a new "gui_title" object.
Add translations: "layer.<ns>.<id>.name".
Use #tag references in origins instead of listing individual origin IDs.
4. Update icon format: old "item"/"damage"/"nbt" → new {"id": "minecraft:..."}
Use #tag references in powers instead of listing individual power IDs.
5. Split any origins:multiple powers into individual power JSON files.
6. Replace removed condition types (command, category, high_humidity, owner) with equivalent alternatives or JS scripts. `entity_group` is available again as a limited power, not a condition.
7. Check the porting guide at porting.md for the full list of differences.