Shaped Arcane Crafting Handler(有序奥法合成)
基本信息
| 属性 | 值 |
|---|---|
| 类型 | NEI Recipe Handler(被两个子类继承) |
| 源码类 | com.gtnewhorizons.aspectrecipeindex.nei.arcaneworkbench.ShapedArcaneRecipeHandler |
| 基类 | TemplateThaumHandler |
| Overlay ID | thaumcraft.arcane.shaped |
| 界面名 | aspectrecipeindex.shaped_arcane_crafting.title = “Shaped Arcane Crafting” |
| 底层配方类型 | Thaumcraft ShapedArcaneRecipe |
| 网格坐标常量 | XPOS = {47, 75, 103},YPOS = {38, 65, 92} |
| IMC 关联物品 | Thaumcraft:blockTable:15(奥法工作台,handler 高度 144) |
功能:展示有序奥法合成配方,并把 vis 消耗与材料格分离——vis 走 getOtherStacks(),不占合成格。
vis 与材料的分离设计
ArcaneShapedCachedRecipe 有两个列表:
| 字段 | 用途 | 返回方法 |
|---|---|---|
vis |
vis 消耗(元素物品),源码注释 “Intentionally not added to ingredients unlike essentia in other handlers” | getOtherStacks() |
ingredients(基类) |
真实合成材料 | getIngredients() |
getOtherStacks() 在 shouldShowRecipe 为假时同样返回空列表。
这一分离有实际意义:Arcane Workbench 覆盖 里的 getVisCost 正是从 getOtherStacks() 读 vis 需求来挑魔杖;也避免了元素物品被 元素配方索引机制 里描述的 setIngredientPermutation 特判干扰。
加载路径
| 方法 | 行为 |
|---|---|
loadCraftingRecipes(ItemStack) |
产物用 areStacksSameTypeCraftingWithNBT 匹配 |
loadCraftingRecipes(String, Object...) |
outputId == "item" 时转发给父类 TemplateRecipeHandler(让 NEI 自己的普通合成处理);等于自己 overlay 时遍历全部 ShapedArcaneRecipe |
loadUsageRecipes(ItemStack) |
见下 |
loadUsageRecipes 用匿名子类做懒过滤:构造 ArcaneShapedCachedRecipe 时覆写 isValid(),要求 super.isValid() && contains(ingredients, ingredient) && Util.shouldShowRecipe(recipe.getResearch())。contains 命中则保留并加入列表,否则 isValid() 为假,addIfValid() 静默丢弃。
这是本模组里"扫描全部配方 + 构造时过滤"模式的一个范例。
材料布局
setIngredients(width, height, Object[] items):
- 双层循环
x走width、y走height,索引items[y * width + x]。 - 跳过规则:既不是
ItemStack、也不是ItemStack[]、也不是String、也不是List的跳过;是List但为空的也跳过。 - 放入
new PositionedStack(object, XPOS[x], YPOS[y], object instanceof ItemStack)——第 4 参数控制是否使用 NBT 变体。 - 每个材料
setMaxSize(1)。
vis 布局
setAspects(AspectList) 覆写(先调父类存 aspects,元素数为 0 直接返回):
| 属性 | 值 |
|---|---|
| 基准 Y | 122 |
| 水平间距 | 19 px |
| 起始 X | 35 + (100 - 元素数 * 19) / 2(居中) |
| 排序 | aspects.getAspectsSortedAmount() |
| 元素物品 metadata | 1 |
所有元素同一行排开(columns = sorted.length),与 Alchemy / Infusion 的多行网格不同——奥法配方的 vis 种类数有限。
背景与研究
drawIngredientBackground:
(20, 16, 112, 15, 52, 52)— 合成网格。- 魔杖图标
(0, 52, 68, 76, 12, 12),在glScalef(1.25, 1.25, 1.0)下以 40% alpha 绘制(源码注释 “Wand icon”)。
前置研究:ArcaneShapedCachedRecipe(ShapedArcaneRecipe, boolean) 构造时取 ResearchCategories.getResearch(recipe.getResearch()),非 null 才 addResearch(researchItem.key)。addResearch 对空字符串名会直接返回。
子类
| 子类 | Overlay | 差异 |
|---|---|---|
| Shapeless Arcane Crafting | thaumcraft.arcane.shapeless |
无序布局 |
| Wand Crafting | thaumcraft.wands |
配方来源可切换(GTNH-TC-Wands / 笛卡尔积) |
相关条目
- Shapeless Arcane Crafting Handler - 无序版本
- Wand Crafting Handler - 魔杖配方
- Arcane Workbench 覆盖 - 一键摆放与魔杖自动替换
- Aspect 物品 - vis 展示用的元素物品
- 配置项 -
showLockedRecipes/showResearchKey