Alchemy Handler(坩埚 / 神秘机器)
基本信息
| 属性 | 值 |
|---|---|
| 类型 | NEI Recipe / Usage Handler |
| 源码类 | com.gtnewhorizons.aspectrecipeindex.nei.AlchemyRecipeHandler |
| 基类 | TemplateThaumHandler |
| Overlay ID | thaumcraft.alchemy |
| 界面名 | aspectrecipeindex.alchemy.title = “Alchemy” |
| 底层配方类型 | Thaumcraft CrucibleRecipe(覆盖坩埚与神秘机器) |
| IMC 关联物品 | Thaumcraft:blockMetalDevice(坩埚,handler 高度 136) |
功能:在 NEI 中展示坩埚 / 神秘机器的炼金配方,包括催化产物与元素需求(essentia)。
加载路径
配方来源统一是 ThaumcraftApi.getCraftingRecipes(),每次加载都全量遍历并 instanceof CrucibleRecipe 过滤。
| 方法 | 条件 | 行为 |
|---|---|---|
loadCraftingRecipes(ItemStack) |
— | 产物匹配用 NEIServerUtils.areStacksSameTypeCraftingWithNBT |
loadCraftingRecipes(String, Object...) |
outputId == overlay |
全部 CrucibleRecipe |
| 同上 | outputId == "item" |
转发到 ItemStack 版本 |
loadUsageRecipes(ItemStack) |
— | 见下 |
loadUsageRecipes 的两级匹配(任一命中即生成,且传 shouldShowRecipe = true,因为可见性已在上一行 Util.shouldShowRecipe(recipe.key) 过滤过):
recipe.catalystMatches(ingredient)— 催化产物匹配。recipe.aspects与Util.getEssentiaFromItem(ingredient)有交集 — 元素需求匹配。这正是"搜索某个装有某元素的瓶子能做什么"的实现。
注意第 2 条需要 inputAspects 非空,且 recipe.aspects 及其内部 aspects 字段都非空(源码做了三级判空)。
界面布局
| 元素 | 坐标 / 规则 |
|---|---|
| 催化产物 | (54, 27),setMaxSize(1);仅当 NEIServerUtils.extractRecipeItems(in) 非空才加入 |
| 产物 | (OUTPUT_X, OUTPUT_Y) = (75, 5) |
| 元素网格 | 每行 3 个,共 ceil(元素数 / 3) 行 |
| 元素网格基准 | xBase = 34,yBase = 86 - 10 * 行数 |
| 元素间距 | 水平 20 px,每行按 (100 - 列数 * 20) / 2 居中偏移 |
| 元素排序 | aspects.getAspectsSortedAmount()(按含量降序) |
| 元素物品 metadata | 1(始终显示真实图标,见 Aspect 物品) |
drawIngredientBackground 画两片贴图:
(21, 26, 2, 20, 52, 47)— 坩埚轮廓(源码注释 “Crucible outline”)。(40, 18, 100, 84, 10, 13)— 输入材料箭头(源码注释 “Input item arrow”)。
有效性与前置研究
CachedThaumRecipe.isValid() 要求 ingredients 非空且 result != null,通过 addIfValid() 才会进入 arecipes(同时把 aspects 追加到外层列表)。
前置研究取 ResearchCategories.getResearch(recipe.key);recipe.key 为空或查不到时 tryAddResearch 静默跳过。
已知缺口
IMCForNEI 里神秘机器的催化剂注册被注释掉了,源码注释为 TODO Fix item render for Thaumatorium——神秘机器在 NEI 中的图标渲染有问题。
相关条目
- IMC 注册消息 - 坩埚催化剂与神秘机器的 TODO
- Aspect 物品 - 元素需求以 metadata 1 的元素物品展示
- Arcane Infusion Handler - 另一套炼金配方 handler
- 配置项 -
showLockedRecipes/showResearchKey