Search in sources :

Example 1 with ResearchPage

use of thaumcraft.api.research.ResearchPage 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 ResearchPage

use of thaumcraft.api.research.ResearchPage 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 ResearchPage

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

the class ThaumcraftPlugin method setupResearch.

public static void setupResearch() {
    ResearchCategories.registerCategory(RESEARCH_CATEGORY, null, new ResourceLocation("railcraft", "textures/items/tool.crowbar.magic.png"), new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png"));
    // Apothecaries Backpack
    Item item = RailcraftItems.BACKPACK_APOTHECARY_T1.item();
    if (item != null) {
        IArcaneRecipe recipe = ThaumcraftApi.addArcaneCraftingRecipe("RC_ApothecariesBackpack", RailcraftItems.BACKPACK_APOTHECARY_T1.getStack(), new AspectList().add(Aspect.AIR, 16).add(Aspect.ORDER, 16), "X#X", "VYV", "X#X", '#', Blocks.WOOL, 'V', Items.GLASS_BOTTLE, 'X', Items.STRING, 'Y', "chestWood");
        AspectList aspects = new AspectList();
        aspects.add(Aspect.VOID, 3).add(Aspect.CRAFT, 3).add(Aspect.MOTION, 2);
        ResearchItem backpack = new ResearchItemRC("RC_ApothecariesBackpack", ThaumcraftPlugin.RESEARCH_CATEGORY, aspects, 2, 0, 6, RailcraftItems.BACKPACK_APOTHECARY_T1.getStack());
        backpack.setPages(ThaumcraftPlugin.getResearchPage("RC_ApothecariesBackpack"), new ResearchPage(recipe)).setParentsHidden("ENCHFABRIC").registerResearchItem();
    }
    // Thaumium Crowbar
    item = RailcraftItems.CROWBAR_THAUMIUM.item();
    if (item != null) {
        String researchTag = "RC_Crowbar_Thaumium";
        IArcaneRecipe recipe = ThaumcraftApi.addArcaneCraftingRecipe(researchTag, new ItemStack(item), new AspectList().add(Aspect.ORDER, 8), " RI", "RIR", "IR ", 'I', ThaumcraftPlugin.ITEMS.get("ingots", 0), 'R', "dyeRed");
        AspectList aspects = new AspectList();
        aspects.add(Aspect.TOOL, 1).add(Aspect.MECHANISM, 2).add(Aspect.METAL, 1);
        ResearchItem thaumiumCrowbar = new ResearchItemRC(researchTag, ThaumcraftPlugin.RESEARCH_CATEGORY, aspects, 0, 0, 3, new ItemStack(item));
        thaumiumCrowbar.setPages(ThaumcraftPlugin.getResearchPage(researchTag), new ResearchPage(recipe)).setParentsHidden("THAUMIUM").registerResearchItem();
    }
    // Void Crowbar
    item = RailcraftItems.CROWBAR_VOID.item();
    if (item != null) {
        String researchTag = "RC_Crowbar_Void";
        IArcaneRecipe recipe = ThaumcraftApi.addArcaneCraftingRecipe(researchTag, new ItemStack(item), new AspectList().add(Aspect.ENTROPY, 50), " RI", "RIR", "IR ", 'I', ThaumcraftPlugin.ITEMS.get("ingots", 1), 'R', "dyeRed");
        AspectList aspects = new AspectList();
        aspects.add(Aspect.TOOL, 2).add(Aspect.MECHANISM, 4).add(Aspect.METAL, 2);
        ResearchItemRC voidCrowbar = new ResearchItemRC(researchTag, ThaumcraftPlugin.RESEARCH_CATEGORY, aspects, 0, 1, 3, new ItemStack(item));
        voidCrowbar.setPages(ThaumcraftPlugin.getResearchPage(researchTag), new ResearchPage(recipe)).setParents(researchTag).setParentsHidden("VOIDMETAL").registerResearchItem();
    }
}
Also used : Item(net.minecraft.item.Item) ResearchItem(thaumcraft.api.research.ResearchItem) AspectList(thaumcraft.api.aspects.AspectList) ResourceLocation(net.minecraft.util.ResourceLocation) IArcaneRecipe(thaumcraft.api.crafting.IArcaneRecipe) ResearchPage(thaumcraft.api.research.ResearchPage) ItemStack(net.minecraft.item.ItemStack) ResearchItem(thaumcraft.api.research.ResearchItem)

Example 4 with ResearchPage

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

the class ThaumcraftPlugin method getResearchPage.

public static ResearchPage getResearchPage(String researchTag) {
    ResearchPage page = researchPages.get(researchTag);
    if (page == null) {
        page = createResearchPage(researchTag, 1);
        researchPages.put(researchTag, page);
    }
    return page;
}
Also used : ResearchPage(thaumcraft.api.research.ResearchPage)

Example 5 with ResearchPage

use of thaumcraft.api.research.ResearchPage in project BetterStorage by copygirl.

the class ThaumcraftAddon method postInitialize.

@Override
public void postInitialize() {
    addItemAspects();
    addEntityAspects();
    if ((thaumcraftBackpack != null) || (thaumiumChest != null)) {
        List<ResearchPage> pages = new ArrayList<ResearchPage>();
        pages.add(new ResearchPage("tc.research_page.betterstorage.magicstorage.1"));
        if (thaumcraftBackpack != null)
            pages.add(new ResearchPage(thaumcraftBackpackRecipe));
        if (thaumiumChest != null)
            pages.add(new ResearchPage(thaumiumChestRecipe));
        ResearchItem research = new ResearchItem("betterstorage.magicstorage", "ARTIFICE", createAspectList(Aspect.VOID, 8, Aspect.MAGIC, 5, Aspect.EXCHANGE, 5), 2, 2, 2, new ItemStack(((thaumcraftBackpack != null) ? itemThaumcraftBackpack : Item.getItemFromBlock(thaumiumChest)))).setPages(pages.toArray(new ResearchPage[0])).setParents("ENCHFABRIC").setParentsHidden("INFUSION").setConcealed().registerResearchItem();
    }
}
Also used : ArrayList(java.util.ArrayList) ResearchPage(thaumcraft.api.research.ResearchPage) ItemStack(net.minecraft.item.ItemStack) ResearchItem(thaumcraft.api.research.ResearchItem)

Aggregations

ResearchPage (thaumcraft.api.research.ResearchPage)6 ResearchItem (thaumcraft.api.research.ResearchItem)5 ItemStack (net.minecraft.item.ItemStack)3 ResearchCategoryList (thaumcraft.api.research.ResearchCategoryList)3 CrucibleRecipe (thaumcraft.api.crafting.CrucibleRecipe)2 ArrayList (java.util.ArrayList)1 Item (net.minecraft.item.Item)1 IRecipe (net.minecraft.item.crafting.IRecipe)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 AspectList (thaumcraft.api.aspects.AspectList)1 IArcaneRecipe (thaumcraft.api.crafting.IArcaneRecipe)1 InfusionRecipe (thaumcraft.api.crafting.InfusionRecipe)1