Infusion Enchantment
Infusion Enchantment is a special variant of infusion crafting used to apply enchantments to items. It is performed at the Infusion Altar and allows enchantments that cannot normally coexist, with instability and XP cost mechanics.
Registration
ThaumcraftApi.addInfusionEnchantmentRecipe(String research,
Enchantment input, // Enchantment to apply
int instability, // Instability ticks per application
AspectList aspects, // Essentia cost
ItemStack[] recipe) // Component items
Parameters
| Parameter | Type | Description |
|---|---|---|
research |
String |
Research key required |
input |
Enchantment |
The enchantment to apply to the item |
instability |
int |
Instability added per craft operation |
aspects |
AspectList |
Essentia cost |
recipe |
ItemStack[] |
Component items placed around the altar |
Example
ThaumcraftApi.addInfusionEnchantmentRecipe(
"INFUSION_ENCHANT_RESEARCH",
Enchantment.sharpness,
8,
new AspectList()
.add(Aspect.WEAPON, 20)
.add(Aspect.FIRE, 10),
new ItemStack[] {
new ItemStack(Items.diamond_sword),
new ItemStack(Items.blaze_rod),
new ItemStack(Items.ender_pearl)
});
InfusionEnchantmentRecipe Class
public class InfusionEnchantmentRecipe {
public AspectList aspects;
public String research;
public ItemStack[] components;
public Enchantment enchantment;
public int recipeXP;
public int instability;
}
Constructor
public InfusionEnchantmentRecipe(String research, Enchantment input, int instability,
AspectList aspects, ItemStack[] recipe)
The recipeXP field is auto-calculated as Math.max(1, input.getMinEnchantability(1) / 3).
Fields
| Field | Type | Description |
|---|---|---|
aspects |
AspectList |
Essentia cost |
research |
String |
Required research key |
components |
ItemStack[] |
Required surrounding components |
enchantment |
Enchantment |
The enchantment being applied |
recipeXP |
int |
Base XP cost (auto-calculated from enchantment) |
instability |
int |
Instability per craft |
Methods
| Method | Returns | Description |
|---|---|---|
matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) |
boolean |
Checks if recipe matches the altar setup |
getEnchantment() |
Enchantment |
The enchantment to apply |
getAspects() |
AspectList |
Essentia cost |
getResearch() |
String |
Required research key |
calcInstability(ItemStack recipeInput) |
int |
Calculates instability for the given input |
calcXP(ItemStack recipeInput) |
int |
XP cost: recipeXP × (1 + existing enchantment level) |
getEssentiaMod(ItemStack recipeInput) |
float |
Essentia modifier based on input item |
matches()
The match logic validates:
- Research is complete (if required)
- The central item can accept this enchantment (
canApply) - The central item is a valid tool (
isItemTool) - Existing enchantments on the item are compatible (no conflict via
canApplyTogether) - The enchantment is not already at max level on the item
- All components are present in the altar’s input pool
// Enchantment compatibility check
if (!enchantment.canApply(central) || !central.getItem().isItemTool(central)) {
return false;
}
// Check existing enchantments for conflicts
Map map1 = EnchantmentHelper.getEnchantments(central);
Iterator iterator = map1.keySet().iterator();
while (iterator.hasNext()) {
int j1 = ((Integer) iterator.next()).intValue();
Enchantment ench = Enchantment.enchantmentsList[j1];
if (j1 == enchantment.effectId &&
EnchantmentHelper.getEnchantmentLevel(j1, central) >= ench.getMaxLevel()) {
return false; // Already at max level
}
if (enchantment.effectId != ench.effectId &&
(!enchantment.canApplyTogether(ench) || !ench.canApplyTogether(enchantment))) {
return false; // Conflicting enchantment
}
}
calcXP()
public int calcXP(ItemStack recipeInput) {
return recipeXP * (1 + EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, recipeInput));
}
XP cost increases based on the existing level of the same enchantment on the input item. This means re-enchanting an already-enchanted item costs more.
calcInstability()
public int calcInstability(ItemStack recipeInput) {
// Returns instability with recipeInput available for override
return instability;
}
Returns the base instability value. The recipeInput parameter is provided for subclasses to override behavior.
getEssentiaMod()
public float getEssentiaMod(ItemStack recipeInput) { … }
Returns a modifier (0.0–1.0) used to determine how much essentia the recipe actually consumes vs. the base AspectList.
Aspect Compatibility
Infusion enchantments require matching essentia aspects just like regular infusion recipes. The AspectList defines the essentia types and amounts needed. Aspects are drained from the Vis pool in the same way as standard infusion crafting.
Finding Recipes
// Iterate all recipes looking for InfusionEnchantmentRecipe
for (Object r : ThaumcraftApi.getCraftingRecipes()) {
if (r instanceof InfusionEnchantmentRecipe) {
InfusionEnchantmentRecipe er = (InfusionEnchantmentRecipe) r;
// ...
}
}