-
Notifications
You must be signed in to change notification settings - Fork 0
Recipes.zh CN
本文介绍 Tinker Foundry 在 NeoForge 1.21.1 和 NeoForge 26.1.2 中实现的自定义配方 JSON 格式。
本文示例以当前源码中的 MeltingRecipe、AlloyingRecipe、CastingRecipe、MoldingRecipe、FuelRecipe、OreMeltingRecipe、DamageableMeltingRecipe 和 EntityMeltingRecipe Codec 为准。一个版本能加载的配方,不代表另一个版本也能直接加载。
配方放在:
src/main/resources/data/tinker_foundry/recipe/<recipe_path>.json
例如:
src/main/resources/data/tinker_foundry/recipe/melting/copper_ingot.json
recipe 目录以下的路径就是配方 ID,因此上面的文件对应 tinker_foundry:melting/copper_ingot。文件名和目录用于组成配方 ID,但 JSON 中仍必须显式写出 type,由它选择对应的 Codec。
所有物品和流体都应使用注册表 ID,例如 minecraft:copper_ingot 或 tinker_foundry:copper。物品结果中的 id 是物品 ID,流体结果中的 id 是流体 ID,两者都不是配方 ID。
流体容量使用项目的流体单位。当前常量为:
| 含义 | 数值 |
|---|---|
| 金粒/碎片 | 10 |
| 金属锭 | 90 |
| 金属块 | 810 |
| 原版桶 | 1000 |
两个版本的流体结果通常都写成:
{
"id": "tinker_foundry:copper",
"amount": 90
}两个版本的物品结果通常都写成:
{
"id": "minecraft:copper_ingot",
"count": 1
}amount 是流体数量,count 是物品堆数量。不要把流体结果写成物品结果,或反过来。
迁移时最重要的区别是当前 Codec 对输入成分的写法不同。
| 输入 | NeoForge 1.21.1 | NeoForge 26.1.2 |
|---|---|---|
| 精确物品 | { "item": "minecraft:copper_ingot" } |
"minecraft:copper_ingot" |
| 物品标签 | { "tag": "c:ingots/copper" } |
"#c:ingots/copper" |
| 精确流体 | { "fluid": "tinker_foundry:copper" } |
"tinker_foundry:copper" |
| 流体标签 | { "tag": "c:molten/copper" } |
"#c:molten/copper" |
| 精确模具 | { "item": "tinker_foundry:ingot_cast" } |
"tinker_foundry:ingot_cast" |
| 模具标签 | { "tag": "c:ingots" } |
"#c:ingots" |
1.21.1 的流体成分通常嵌套在带容量的流体输入对象中:
"fluid": {
"ingredient": { "fluid": "tinker_foundry:copper" },
"amount": 90
}26.1.2 的当前资源使用字符串形式:
"fluid": {
"ingredient": "tinker_foundry:copper",
"amount": 90
}这是两个版本的 Ingredient 和 FluidIngredient Codec 不同造成的。迁移配方时,物品、流体和模具的每一处输入都要转换,不能只把顶层 type 改掉。
实现层面上,1.21.1 配方使用 FluidStack/ItemStack Codec,26.1.2 的数据配方记录使用 FluidStackTemplate/ItemStackTemplate。但常规 JSON 的结果形状仍然是流体使用 id 加 amount,物品使用 id 加 count;变化主要在 Codec 实现。
JSON type
|
输入 → 输出 | 用途 |
|---|---|---|
tinker_foundry:melting |
物品 → 流体 | 普通物品熔炼 |
tinker_foundry:ore_melting |
物品 → 流体 | 矿石式金属/宝石倍率与副产物 |
tinker_foundry:damageable_melting |
可损坏物品 → 流体 | 根据剩余耐久计算产量 |
tinker_foundry:entity_melting |
实体匹配 → 流体 | 实体或实体标签对应的流体来源 |
tinker_foundry:alloying |
两种或更多流体 → 流体 | 合金炉和多方块熔炼体系合金 |
tinker_foundry:casting |
流体 + 可选模具 → 物品 | 铸造台/浇注盆式配方 |
tinker_foundry:molding |
模具 + 流体 → 物品 | 可复用或消耗模具配方 |
tinker_foundry:fuel |
物品或流体 → 热量 | 加热器和燃料罐燃料定义 |
这些是 Tinker Foundry 的自定义配方类型。处理熔融流体时不要使用 minecraft:smelting。
NeoForge 1.21.1:
{
"type": "tinker_foundry:melting",
"ingredient": { "item": "minecraft:copper_ingot" },
"result": { "id": "tinker_foundry:copper", "amount": 90 },
"temperature": 500,
"time": 50
}NeoForge 26.1.2:
{
"type": "tinker_foundry:melting",
"ingredient": "minecraft:copper_ingot",
"result": { "id": "tinker_foundry:copper", "amount": 90 },
"temperature": 500,
"time": 50
}字段说明:
| 字段 | 是否必需 | 含义 |
|---|---|---|
ingredient |
是 | 一个物品、物品标签或物品成分列表 |
result |
是 | 流体 ID 和基础数量 |
temperature |
是 | 所需最低温度 |
time |
否 | 处理时间,单位为 tick;默认 100
|
rate |
否 | 默认 none,也可以是 metal 或 gem
|
byproducts |
否 | 额外的流体产物 |
如果配方要接受一整组材料,请使用物品标签。
// 1.21.1 的 ingredient
{ "tag": "c:ingots/copper" }// 26.1.2 的 ingredient
"#c:ingots/copper"rate 由模组的金属/宝石换算逻辑解释。none 保持结果数量不变;只有配方确实要参与对应换算时才使用 metal 或 gem。
如果配方是矿石式熔炼,并且要参与项目的金属或宝石倍率,请使用 ore_melting:
{
"type": "tinker_foundry:ore_melting",
"ingredient": "#c:ores/copper",
"result": { "id": "tinker_foundry:copper", "amount": 90 },
"temperature": 500,
"time": 100,
"rate": "metal"
}上面是 26.1.2 的输入写法。1.21.1 要改成对象:
"ingredient": { "tag": "c:ores/copper" }ore_melting 的 rate 默认值是 metal;为了让意图清楚,建议在正式配方中显式写出。
在 melting 或 ore_melting 中加入 byproducts 数组:
"byproducts": [
{
"result": { "id": "tinker_foundry:slag", "amount": 10 },
"rate": "default"
}
]default 会继承主配方的倍率。单个副产物也可以写 metal、gem 或 none。副产物是额外流体输出,不是物品输出。
工具或其他可损坏物品使用 damageable_melting。它比普通熔炼多出 unit_size:
{
"type": "tinker_foundry:damageable_melting",
"ingredient": "minecraft:iron_pickaxe",
"result": { "id": "tinker_foundry:iron", "amount": 90 },
"temperature": 800,
"time": 100,
"unit_size": 1
}unit_size 控制按耐久计算流体产量时的最小换算粒度,必须保持为正数。需要时可以按普通熔炼的格式添加 byproducts。
合金配方的 ingredients 至少要有两个元素。每个元素包含:
-
ingredient:精确流体或流体标签; -
amount:从某一层已存流体/输入流体中要求的最小数量; -
catalyst:可选,默认false。
匹配时,每个合金输入会分配到不同的流体层或输入槽。流体多出来没有问题。催化流体必须参与匹配,但合金完成时不会被抽走。结果数量不会自动按输入相加,必须自己写出预期数量。
NeoForge 1.21.1:
{
"type": "tinker_foundry:alloying",
"ingredients": [
{
"ingredient": { "fluid": "tinker_foundry:iron" },
"amount": 180
},
{
"ingredient": { "fluid": "tinker_foundry:nickel" },
"amount": 90
}
],
"result": { "id": "tinker_foundry:invar", "amount": 270 },
"temperature": 1000
}NeoForge 26.1.2:
{
"type": "tinker_foundry:alloying",
"ingredients": [
{
"ingredient": "tinker_foundry:iron",
"amount": 180
},
{
"ingredient": "tinker_foundry:nickel",
"amount": 90
}
],
"result": { "id": "tinker_foundry:invar", "amount": 270 },
"temperature": 1000
}催化输入示例:
{
"ingredient": "tinker_foundry:cobalt",
"amount": 90,
"catalyst": true
}AlloyingRecipe 没有 time 字段。合金按照机器自身的处理周期和 temperature 温度门槛运行,不要添加一个期望改变处理时长但实际不会生效的 time 字段。
浇注使用带数量的流体输入并产出物品,mold 对 casting 配方是可选的。
NeoForge 1.21.1:
{
"type": "tinker_foundry:casting",
"fluid": {
"ingredient": { "fluid": "tinker_foundry:iron" },
"amount": 90
},
"mold": { "item": "tinker_foundry:ingot_cast" },
"result": { "id": "minecraft:iron_ingot", "count": 1 },
"time": 60
}NeoForge 26.1.2:
{
"type": "tinker_foundry:casting",
"fluid": {
"ingredient": "tinker_foundry:iron",
"amount": 90
},
"mold": "tinker_foundry:ingot_cast",
"result": { "id": "minecraft:iron_ingot", "count": 1 },
"time": 60
}可选字段:
| 字段 | 默认值 | 含义 |
|---|---|---|
time |
60 |
浇注时间,单位为 tick |
cast_consumed |
false |
配方完成时是否消耗模具/铸型 |
switch_slots |
false |
是否使用配方的槽位交换行为 |
copy_potion_contents |
false |
结果支持时是否复制药水内容 |
模具配方是另一种方向:模具物品和流体共同产出物品。
{
"type": "tinker_foundry:molding",
"mold": "tinker_foundry:ingot_sand_cast",
"fluid": {
"ingredient": "tinker_foundry:copper",
"amount": 90
},
"result": { "id": "minecraft:copper_ingot", "count": 1 },
"time": 60
}上面 mold 和 fluid.ingredient 的字符串是 26.1.2 写法。1.21.1 中,mold 要使用 { "item": ... } 或 { "tag": ... },fluid.ingredient 内使用 { "fluid": ... } 或 { "tag": ... }。
可选字段:
| 字段 | 默认值 | 含义 |
|---|---|---|
time |
60 |
模具处理时间,单位为 tick |
remainder |
空 | 处理后返回的物品(如果有) |
pattern_consumed |
true |
配方完成时是否消耗模具/图案 |
燃料配方定义物品燃料、流体燃料,或两者。item 和 fluid 是相互独立的可选输入字段;根据加热器或燃料罐的实际需求填写对应字段。
1.21.1 物品燃料:
{
"type": "tinker_foundry:fuel",
"item": { "tag": "minecraft:coals" },
"duration": 1600,
"temperature": 800,
"consumption": 1,
"rate": 8
}26.1.2 物品燃料:
{
"type": "tinker_foundry:fuel",
"item": "#minecraft:coals",
"duration": 1600,
"temperature": 800,
"consumption": 1,
"rate": 8
}1.21.1 的流体燃料使用 { "fluid": "..." };26.1.2 使用流体 ID 字符串:
// 1.21.1
"fluid": { "fluid": "tinker_foundry:blazing_blood" }// 26.1.2
"fluid": "tinker_foundry:blazing_blood"字段说明:
| 字段 | 是否必需 | 含义 |
|---|---|---|
item 或 fluid
|
至少填写实际需要的输入 | 物品或流体匹配器 |
duration |
是 | 燃料持续时间 |
temperature |
是 | 提供的温度 |
consumption |
否 | 每次操作消耗量,默认 1
|
rate |
否 | 燃料传递/处理速率,默认 10,必须为正数 |
实体熔炼可以匹配明确的实体 ID、实体标签,或两者同时使用:
{
"type": "tinker_foundry:entity_melting",
"entity_tag": "tinker_foundry:melting/blazes",
"result": { "id": "tinker_foundry:blazing_blood", "amount": 20 },
"damage": 2
}明确列出实体 ID:
"entities": ["minecraft:blaze", "minecraft:magma_cube"]damage 默认是 2,并且必须处于 Codec 允许的正数范围。两个版本的结果流体都使用相同的 id/amount 结构。
提交配方前:
- 确认目标版本中每一个物品、流体和标签都存在。
- 确认顶层
type对应 Tinker Foundry 已注册的配方序列化器。 - 按目标版本转换物品、流体和模具的输入写法。
- 确认流体容量足够支撑预期物品产出。
- 合金配方至少使用两个不同的输入层,并明确标记催化流体。
- 在开发世界执行
/reload,检查日志中的配方加载错误。 - 打开对应的 Tinker Foundry 或 JEI 配方页面,确认配方确实存在。
最常见的迁移错误是:在 26.1.2 资源中仍保留 1.21.1 的对象输入,或者在 1.21.1 资源中使用 26.1.2 的 #tag 字符串。JSON 看起来合法,并不代表它符合目标分支的 Codec。