跳到正文
烈焰甘蔗Wiki

Infusion Crafting

Infusion crafting is the most powerful crafting system in Thaumcraft. It is performed at the Infusion Altar and supports recipe transformation, enchantment application, and multi-component recipes with instability mechanics.

Registration

ThaumcraftApi.addInfusionCraftingRecipe(String research,   // Research key
    Object result,        // ItemStack or Object[] of ItemStacks
    int instability,      // Instability ticks added per operation
    AspectList aspects,   // Essentia cost
    ItemStack input,     // Central item being crafted/transformed
    ItemStack[] recipe)   // Surrounding component items

Example

ThaumcraftApi.addInfusionCraftingRecipe(
    "INFUSION_RESEARCH",
    new ItemStack(Items.diamond_sword),
    10,                                              // instability
    new AspectList()
        .add(Aspect.FIRE, 25)
        .add(Aspect.WEAPON, 15),
    new ItemStack(Items.iron_sword),                 // central input
    new ItemStack[] {
        new ItemStack(Blocks.diamond_block),
        new ItemStack(Items.blaze_rod),
        new ItemStack(Items.ender_eye)
    });

InfusionRecipe Class

public class InfusionRecipe {
    protected AspectList aspects;
    protected String research;
    private ItemStack[] components;
    private ItemStack recipeInput;
    protected Object recipeOutput;
    protected int instability;
}

Constructor

public InfusionRecipe(String research, Object output, int instability,
        AspectList aspects, ItemStack input, ItemStack[] recipe)
Parameter Type Description
research String Research key required; empty string = no research
output Object ItemStack result or Object[] of possible results
instability int Instability added to the altar per craft
aspects AspectList Essentia cost
input ItemStack The central item in the infusion altar
recipe ItemStack[] Component items placed around the altar

Methods

Method Returns Description
matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) boolean Checks if the recipe matches the current altar setup
getRecipeInput() ItemStack The central input item
getComponents() ItemStack[] Required surrounding components
getRecipeOutput() / getRecipeOutput(ItemStack input) Object Crafted result
getAspects() / getAspects(ItemStack input) AspectList Essentia cost
getInstability() / getInstability(ItemStack input) int Instability value
getResearch() String Required research key

Matching Logic

The matches method:

  1. Returns false if recipeInput is null
  2. Returns false if research is required but incomplete
  3. Checks if the central item matches recipeInput (fuzzy damage match allowed)
  4. Verifies all components are present in the altar’s input pool (fuzzy matching)
  5. Returns true only if all components are consumed exactly

Ore Dictionary entries in components match any item registered to that ore.

ItemStack Matching

public static boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  • fuzzy=true: matches by Ore Dictionary ID
  • NBT tags must match (unless wildcard)
  • Damage value: exact match unless OreDictionary.WILDCARD_VALUE

Instability

Instability is a measure of how unstable the infusion altar becomes during crafting. Higher values cause more frequent and severe effects:

Instability Effect
0–5 Minor flux; occasional particles
6–15 Moderate effects; possible Rifts
16+ Severe effects; dangerous flux events

⚠️ 订正/来源声明:上表三档阈值无法从本仓源码核实。IInfusionStabiliser 只是个标记接口 (crafting/IInfusionStabiliser.java:12),InfusionRecipe 只存储并暴露 instability 字段 (crafting/InfusionRecipe.java 的 getInstability() / getInstability(ItemStack)), 具体的不稳定度→效果映射实现在主 mod,不在 thaumcraft-api 仓内。

IInfusionStabiliser Interface

Blocks implementing this interface act as infusion stabilizers, reducing instability during crafting.

public interface IInfusionStabiliser {
    boolean canStabaliseInfusion(World world, int x, int y, int z);
}

⚠️ 方法名拼写照抄源码:canStabaliseInfusion(Stabalise,非 Stabilise)。 证据:crafting/IInfusionStabiliser.java:14。改名会编译失败。

Method Returns Description
canStabaliseInfusion boolean true if this block can stabilize the infusion altar at the given coordinates

Built-in Stabilizers

⚠️ 订正:原条目把「Candles / skulls / Pure Azure Feather」列为本条目可确认的内置稳定器——无法核实。 本仓只有接口定义,没有任何内置稳定器清单。源码里唯一的线索是接口自身的 javadoc 「Blocks that implement this interface act as infusion crafting stabilisers like candles and skulls」 (crafting/IInfusionStabiliser.java:9),它只是举例说明用途,既未列出具体物品, 也完全没有提到 “Pure Azure Feather”——该条系凭空添加。 可确认的只有:javadoc 举了蜡烛(candles)和头颅(skulls)两个例子;纯血之羽无法核实。

Registering a Stabilizer

⚠️ 已订正:原条目给出 ThaumcraftApi.registerInfusionStabiliser(Block myBlock)——该方法在源码中不存在。 证据:对整个 /Users/evlos/a/mirror/thaumcraft-api/ 全量 grep registerInfusionStabiliser|Stabiliser 只命中 crafting/IInfusionStabiliser.java:12(接口声明本身)一处,ThaumcraftApi.java 内无任何稳定器注册方法。

正确做法:让方块类 implements IInfusionStabiliser 并覆写 canStabaliseInfusion, 由主 mod 在检测时主动调用,无需(也无法)显式注册。

Finding Recipes

// Get InfusionRecipe by output ItemStack
InfusionRecipe recipe = ThaumcraftApi.getInfusionRecipe(ItemStack result);

// Iterate all infusion recipes
for (Object r : ThaumcraftApi.getCraftingRecipes()) {
    if (r instanceof InfusionRecipe) {
        InfusionRecipe ir = (InfusionRecipe) r;
        // ...
    }
}

Recipe Output as Object[]

The result parameter accepts Object[].

⚠️ 已订正:原文「When getRecipeOutput() is called without an input argument, it returns the first element」——这是错的。 API 里无参版只是转发给带 ItemStack 的重载,而该重载原样返回 recipeOutput 字段,没有任何「取首元素」逻辑。 证据:crafting/InfusionRecipe.java:98-100(转发)与 122-124(return recipeOutput;)。 「取首元素」是主 mod 子类覆写后的行为,不在本 API 仓内。

后半句「调用带 ItemStack 的版本时配方可按输入返回不同结果」成立——API 专门预留了该覆写点。

浏览全部模组