package thaumcraft.api.crafting; import java.util.ArrayList; import java.util.Iterator; import java.util.Map; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.AspectList; public class InfusionEnchantmentRecipe { public AspectList aspects; public String research; public ItemStack[] components; public Enchantment enchantment; public int recipeXP; public int instability; public InfusionEnchantmentRecipe(String research, Enchantment input, int inst, AspectList aspects2, ItemStack[] recipe) { this.research = research; this.enchantment = input; this.aspects = aspects2; this.components = recipe; this.instability = inst; this.recipeXP = Math.max(1, input.getMinEnchantability(1)/3); } /** * Used to check if a recipe matches current crafting inventory * @param player */ public boolean matches(ArrayList input, ItemStack central, World world, EntityPlayer player) { if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) { return false; } if (!enchantment.canApply(central) || !central.getItem().isItemTool(central)) { return false; } 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; if (enchantment.effectId != ench.effectId && (!enchantment.canApplyTogether(ench) || !ench.canApplyTogether(enchantment))) { return false; } } ItemStack i2 = null; ArrayList ii = new ArrayList(); for (ItemStack is:input) { ii.add(is.copy()); } for (ItemStack comp:components) { boolean b=false; for (int a=0;a