Infusion Recipe 模块
基本信息
net.glease.tc4tweak.modules.infusionRecipe —— 注入(Infusion)配方的词典匹配改写。
配置项 oreDictMode(general.infusion_recipes 分组,默认 Default)。
3 个类
| 类 | 职责 |
|---|---|
InfusionOreDictMode |
4 种匹配模式的枚举 |
InfusionRecipeGetOutput |
输出计算 + API 实现 |
MTCompatForInfusionExt |
MineTweaker 兼容 |
InfusionOreDictMode:4 个取值
| 模式 | test() 判定 |
get() 产出的 Ingredient |
|---|---|---|
Default |
getOreID(playerInput) 的第一个 ore 展开后与 recipeSpec 做 containsMatch |
单个 oredict 或 item |
Strict |
两者的全部 ore ID 集合完全相等(TIntHashSet.equals) |
oredictStrict 或多物品 items(...) |
Relaxed |
recipeSpec 的任一 ore ID 出现在 playerInput 集合中即真 | 全部 oreID 用 RecipeIngredient::or 组合 |
None |
isItemEqual 且 areItemStackTagsEqual —— 完全不走词典 |
恒为 item(false, recipeSpec) |
⚠️ 语义容易写反:
Default只用第一个 ore ID(getOreID), 而Strict要求 ID 集合完全一致(最严格),Relaxed只要有交集。名称与严格度并非单调对应。
Strict 的交集算法
Strict.get() 对多个 oreID 逐个求 oresThis 的交集(私有 intersect),
一旦交集只剩 1 个物品就退化为 item(true, recipeSpec)。
get(String name) 的容错
遍历 values() 找名字,找不到返回 Default(不抛异常)。
但 get("Default")(首字母大写)才会命中 —— 配置文件里需写精确枚举名。
InfusionRecipeGetOutput
| 成员 | 行 | 说明 |
|---|---|---|
构造器中向上遍历 getSuperclass() 找 getRecipeOutput(ItemStack) |
18-22 | 反射定位父类方法 |
static shouldModify(InfusionRecipe, ItemStack, ItemStack) |
37 | 判断是否要改写 |
static getOutput(InfusionRecipe, ItemStack, ItemStack) |
59 | 计算输出 |
static reload() |
71 | 重载 |
static class APIImpl implements InfusionExtAPI |
78 | 对外 API 实现 |
MTCompatForInfusionExt
| 成员 | 行 | 说明 |
|---|---|---|
registerCustomBehavior(IIngredient, RecipeNBTBehaviorFunction) |
26 | MineTweaker IIngredient 版 |
registerCustomBehavior(IData, RecipeNBTBehaviorFunction) |
41 | IData 版 |
interface RecipeNBTBehaviorFunction extends InfusionExtAPI.RecipeNBTBehavior |
56 | 函数式接口 |
abstract static class CustomBehavior<T> implements IUndoableAction |
58 | 可撤销动作 |
IUndoableAction(canUndo / apply)用于 MineTweaker 脚本的撤销回滚。
相关配置(nbtcarryover 子分组)
| 键 | 归属字段 |
|---|---|
enable |
infusionRecipeNBTCarryOver |
armorToolOnly |
infusionRecipeNBTModifyArmorToolOnly |
carryOverWhitelist |
infusionRecipeNBTWhitelist |
相关条目
源码
src/main/java/net/glease/tc4tweak/modules/infusionRecipe/InfusionOreDictMode.javasrc/main/java/net/glease/tc4tweak/modules/infusionRecipe/InfusionRecipeGetOutput.javasrc/main/java/net/glease/tc4tweak/modules/infusionRecipe/MTCompatForInfusionExt.java