Search in sources :

Example 1 with ResearchCategoryList

use of thaumcraft.api.research.ResearchCategoryList in project PneumaticCraft by MineMaarten.

the class ThaumcraftApi method getCraftingRecipeKey.

public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) {
    int[] key = new int[] { Item.getIdFromItem(stack.getItem()), stack.getItemDamage() };
    if (keyCache.containsKey(key)) {
        if (keyCache.get(key) == null)
            return null;
        if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), (String) (keyCache.get(key))[0]))
            return keyCache.get(key);
        else
            return null;
    }
    for (ResearchCategoryList rcl : ResearchCategories.researchCategories.values()) {
        for (ResearchItem ri : rcl.research.values()) {
            if (ri.getPages() == null)
                continue;
            for (int a = 0; a < ri.getPages().length; a++) {
                ResearchPage page = ri.getPages()[a];
                if (page.recipe != null && page.recipe instanceof CrucibleRecipe[]) {
                    CrucibleRecipe[] crs = (CrucibleRecipe[]) page.recipe;
                    for (CrucibleRecipe cr : crs) {
                        if (cr.getRecipeOutput().isItemEqual(stack)) {
                            keyCache.put(key, new Object[] { ri.key, a });
                            if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key))
                                return new Object[] { ri.key, a };
                        }
                    }
                } else if (page.recipeOutput != null && stack != null && page.recipeOutput.isItemEqual(stack)) {
                    keyCache.put(key, new Object[] { ri.key, a });
                    if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key))
                        return new Object[] { ri.key, a };
                    else
                        return null;
                }
            }
        }
    }
    keyCache.put(key, null);
    return null;
}
Also used : ResearchCategoryList(thaumcraft.api.research.ResearchCategoryList) CrucibleRecipe(thaumcraft.api.crafting.CrucibleRecipe) ResearchPage(thaumcraft.api.research.ResearchPage) ResearchItem(thaumcraft.api.research.ResearchItem)

Example 2 with ResearchCategoryList

use of thaumcraft.api.research.ResearchCategoryList in project Railcraft by Railcraft.

the class ThaumcraftApi method getCraftingRecipeKey.

public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) {
    int[] key = new int[] { Item.getIdFromItem(stack.getItem()), stack.getItemDamage() };
    if (keyCache.containsKey(key)) {
        if (keyCache.get(key) == null)
            return null;
        if (ResearchHelper.isResearchComplete(player.getName(), (String) (keyCache.get(key))[0]))
            return keyCache.get(key);
        else
            return null;
    }
    for (ResearchCategoryList rcl : ResearchCategories.researchCategories.values()) {
        for (ResearchItem ri : rcl.research.values()) {
            if (ri.getPages() == null)
                continue;
            for (int a = 0; a < ri.getPages().length; a++) {
                ResearchPage page = ri.getPages()[a];
                if (page.recipe != null && page.recipe instanceof CrucibleRecipe[]) {
                    CrucibleRecipe[] crs = (CrucibleRecipe[]) page.recipe;
                    for (CrucibleRecipe cr : crs) {
                        if (cr.getRecipeOutput().isItemEqual(stack)) {
                            keyCache.put(key, new Object[] { ri.key, a });
                            if (ResearchHelper.isResearchComplete(player.getName(), ri.key))
                                return new Object[] { ri.key, a };
                        }
                    }
                } else if (page.recipe != null && page.recipe instanceof InfusionRecipe[]) {
                    InfusionRecipe[] crs = (InfusionRecipe[]) page.recipe;
                    for (InfusionRecipe cr : crs) {
                        if (cr.getRecipeOutput() instanceof ItemStack && ((ItemStack) cr.getRecipeOutput()).isItemEqual(stack)) {
                            keyCache.put(key, new Object[] { ri.key, a });
                            if (ResearchHelper.isResearchComplete(player.getName(), ri.key))
                                return new Object[] { ri.key, a };
                        }
                    }
                } else if (page.recipe != null && page.recipe instanceof IRecipe[]) {
                    IRecipe[] crs = (IRecipe[]) page.recipe;
                    for (IRecipe cr : crs) {
                        if (cr.getRecipeOutput().isItemEqual(stack)) {
                            keyCache.put(key, new Object[] { ri.key, a });
                            if (ResearchHelper.isResearchComplete(player.getName(), ri.key))
                                return new Object[] { ri.key, a };
                        }
                    }
                } else if (page.recipeOutput != null && stack != null && (page.recipeOutput instanceof ItemStack && ((ItemStack) page.recipeOutput).isItemEqual(stack)) || (page.recipeOutput instanceof String && ThaumcraftApiHelper.containsMatch(true, new ItemStack[] { stack }, OreDictionary.getOres((String) page.recipeOutput)))) {
                    keyCache.put(key, new Object[] { ri.key, a });
                    if (ResearchHelper.isResearchComplete(player.getName(), ri.key))
                        return new Object[] { ri.key, a };
                    else
                        return null;
                }
            }
        }
    }
    keyCache.put(key, null);
    return null;
}
Also used : IRecipe(net.minecraft.item.crafting.IRecipe) CrucibleRecipe(thaumcraft.api.crafting.CrucibleRecipe) ResearchPage(thaumcraft.api.research.ResearchPage) ResearchItem(thaumcraft.api.research.ResearchItem) ResearchCategoryList(thaumcraft.api.research.ResearchCategoryList) InfusionRecipe(thaumcraft.api.crafting.InfusionRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ResearchCategoryList

use of thaumcraft.api.research.ResearchCategoryList in project ArsMagica2 by Mithion.

the class ThaumcraftApi method getCraftingRecipeKey.

public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) {
    int[] key = new int[] { Item.getIdFromItem(stack.getItem()), stack.getItemDamage() };
    if (keyCache.containsKey(key)) {
        if (keyCache.get(key) == null)
            return null;
        if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), (String) (keyCache.get(key))[0]))
            return keyCache.get(key);
        else
            return null;
    }
    for (ResearchCategoryList rcl : ResearchCategories.researchCategories.values()) {
        for (ResearchItem ri : rcl.research.values()) {
            if (ri.getPages() == null)
                continue;
            for (int a = 0; a < ri.getPages().length; a++) {
                ResearchPage page = ri.getPages()[a];
                if (page.recipeOutput != null && stack != null && page.recipeOutput.isItemEqual(stack)) {
                    keyCache.put(key, new Object[] { ri.key, a });
                    if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key))
                        return new Object[] { ri.key, a };
                    else
                        return null;
                }
            }
        }
    }
    keyCache.put(key, null);
    return null;
}
Also used : ResearchCategoryList(thaumcraft.api.research.ResearchCategoryList) ResearchPage(thaumcraft.api.research.ResearchPage) ResearchItem(thaumcraft.api.research.ResearchItem)

Aggregations

ResearchCategoryList (thaumcraft.api.research.ResearchCategoryList)3 ResearchItem (thaumcraft.api.research.ResearchItem)3 ResearchPage (thaumcraft.api.research.ResearchPage)3 CrucibleRecipe (thaumcraft.api.crafting.CrucibleRecipe)2 ItemStack (net.minecraft.item.ItemStack)1 IRecipe (net.minecraft.item.crafting.IRecipe)1 InfusionRecipe (thaumcraft.api.crafting.InfusionRecipe)1