thaumcraft.api.research.ResearchItem Java Examples

The following examples show how to use thaumcraft.api.research.ResearchItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EMTResearchItem.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ResearchItem setPages(ResearchPage... par) {
    for (ResearchPage page : par) {
        if (page.type == PageType.TEXT)
            page.text = "emt.text." + key;

        if (page.type == PageType.INFUSION_CRAFTING) {
            if (parentsHidden == null || parentsHidden.length == 0)
                parentsHidden = new String[]{"INFUSION"};
            else {
                String[] newParents = new String[parentsHidden.length + 1];
                newParents[0] = "INFUSION";
                for (int i = 0; i < parentsHidden.length; i++)
                    newParents[i + 1] = parentsHidden[i];
                parentsHidden = newParents;
            }
        }
    }

    return super.setPages(par);
}
 
Example #2
Source File: IfAnyParentResearchItem.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public boolean isHidden() {
    if(anyParents != null) {
        boolean hasFoundAny = false;
        boolean doesAnyExist = false;
        for(String res : anyParents) {
            ResearchItem ri = ResearchCategories.getResearch(res);
            if(ri != null) {
                doesAnyExist = true;
                if(GuiResearchBrowser.completedResearch.get(Minecraft.getMinecraft().thePlayer.getCommandSenderName()).contains(ri.key)) {
                    hasFoundAny = true;
                }
            }
        }
        if(doesAnyExist) {
            return !hasFoundAny;
        }
    }
    return super.isHidden();
}
 
Example #3
Source File: ExThaumiquo.java    From Ex-Aliquo with MIT License 6 votes vote down vote up
private static void removeResearch(String research)
{
	Collection researchcategory = ResearchCategories.researchCategories.values();
	for (Object obj : researchcategory)
	{
		Collection researchlist = ((ResearchCategoryList)obj).research.values();
		for (Object researchitem : researchlist)
		{
			if (((ResearchItem)researchitem).key.equals(research))
			{
				researchlist.remove(researchitem);
				break;
			}
		}
	}
}
 
Example #4
Source File: RegisteredResearches.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void postInit() {
    ResearchItem researchJar = PseudoResearchItem.create("JARLABEL", -3, -7).registerResearchItem();

    RecipeVisualStickyJar visualRecipe = new RecipeVisualStickyJar();
    ResearchPage page = new ResearchPage(visualRecipe);

    researchStickyJar = new StickyJarResearchItem("STICKYJAR", -5, -5, 2,
            new AspectList().add(Aspect.SLIME, 8).add(Aspect.EARTH, 8))
            .setParents(researchJar.key).setConcealed()
            .setPages(new ResearchPage("gadomancy.research_page.STICKYJAR.1"), page).registerResearchItem();

    if(researchBlockProtector != null) {
        researchBlockProtector.setParents(researchStickyJar.key);
    }

    String[] parents = Config.allowMirrors ? new String[] { researchJar.key, "MIRRORESSENTIA" } : new String[] { researchJar.key };
    researchRemoteJar = new SimpleResearchItem("REMOTEJAR", -4, -3, 3,
            RegisteredRecipes.recipeRemoteJar.getRecipeOutput(),
            new AspectList().add(Aspect.WATER, 4).add(Aspect.MECHANISM, 8).add(Aspect.EARTH, 4).add(Aspect.ORDER, 8))
            .setParents(parents).setConcealed()
            .setPages(new ResearchPage("gadomancy.research_page.REMOTEJAR.1"), new ResearchPage(RegisteredRecipes.recipeRemoteJar), new ResearchPage("gadomancy.research_page.REMOTEJAR.2")).registerResearchItem();

    //Aura researches
    AuraResearchManager.registerAuraResearches();
}
 
Example #5
Source File: ThaumcraftApi.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #6
Source File: GuiResearchRecipeAuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public GuiResearchRecipeAuraEffects(ResearchItem research, int page, double x, double y) {
    super(research, page, x, y);

    Injector inj = new Injector(this, GuiResearchRecipe.class);

    ResearchPage[] additionalPages = ResearchPageAuraAspects.createAllAuraPagesFor(Minecraft.getMinecraft().thePlayer);
    ResearchPage[] pages = inj.getField("pages");
    ResearchPage[] newPages = new ResearchPage[pages.length + additionalPages.length];
    System.arraycopy(pages, 0, newPages, 0, pages.length);
    System.arraycopy(additionalPages, 0, newPages, pages.length, additionalPages.length);
    inj.setField("pages", newPages);
    inj.setField("maxPages", newPages.length);

    List<String> list = Thaumcraft.proxy.getScannedObjects().get(Minecraft.getMinecraft().thePlayer.getCommandSenderName());
    if ((list != null) && (list.size() > 0)) {
        for (String s : list) {
            try {
                String s2 = s.substring(1);
                ItemStack is = getFromCache(Integer.parseInt(s2));
                if (is != null) {
                    AspectList tags = ThaumcraftCraftingManager.getObjectTags(is);
                    tags = ThaumcraftCraftingManager.getBonusTags(is, tags);
                    if ((tags != null) && (tags.size() > 0)) {
                        for (Aspect a : tags.getAspects()) {
                            ArrayList<ItemStack> items = itemMap.get(a.getTag());
                            if (items == null) {
                                items = new ArrayList<ItemStack>();
                            }
                            ItemStack is2 = is.copy();
                            is2.stackSize = tags.getAmount(a);
                            items.add(is2);
                            itemMap.put(a.getTag(), items);
                        }
                    }
                }
            } catch (NumberFormatException e) {}
        }
    }
}
 
Example #7
Source File: ThaumcraftApi.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
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;
}
 
Example #8
Source File: ThaumcraftApi.java    From GardenCollection with MIT License 5 votes vote down vote up
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;
}
 
Example #9
Source File: ThaumcraftApi.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: ExThaumiquo.java    From Ex-Aliquo with MIT License 5 votes vote down vote up
private static ResearchItem copyResearch(ResearchItem research)
{
	String k = research.key;
	String cat = research.category;
	AspectList as = research.tags;
	int col = research.displayColumn;
	int row = research.displayRow;
	int complex = research.getComplexity();
	ItemStack icon = research.icon_item;
	
	ResearchItem override = new ResearchItem(research.key, research.category, research.tags, research.displayColumn, research.displayRow, research.getComplexity(), research.icon_item);
	//override.setPages(research.getPages());
	if (research.isAutoUnlock()) override.setSpecial();
	if (research.isConcealed()) override.setStub();
	if (research.isHidden()) override.setHidden();
	if (research.isRound()) override.setRound();
	if (research.isSecondary()) override.setSecondary();
	if (research.isStub()) override.setStub();
	if (research.isVirtual()) override.setVirtual();
	override.setSiblings(research.siblings);
	override.setParents(research.parents);
	override.setParentsHidden(research.parentsHidden);
	override.setAspectTriggers(research.getAspectTriggers());
	override.setItemTriggers(research.getItemTriggers());
	
	return override;
}
 
Example #11
Source File: ThaumcraftApi.java    From AdvancedMod with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #12
Source File: TileKnowledgeBook.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean shouldVortexResearchNote(ItemStack stack) {
    ResearchNoteData nd = ResearchManager.getData(stack);
    if(nd == null) return false;
    if(nd.isComplete()) return false;
    ResearchItem ri = ResearchCategories.getResearch(nd.key);
    return ri != null;
}
 
Example #13
Source File: DisguiseResearchItem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ResearchItem setPages(ResearchPage... pages) {
    for(ResearchPage page : pages) {
        if(page.type == ResearchPage.PageType.INFUSION_CRAFTING
                && page.recipe instanceof InfusionVisualDisguiseArmor) {
            recipe = (InfusionVisualDisguiseArmor) page.recipe;
        }
    }
    return super.setPages(pages);
}
 
Example #14
Source File: PseudoResearchItem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static ResearchItem create(String original, int col, int row, boolean doubleInThisPage) {
    ResearchItem item = ResearchCategories.getResearch(original);

    if(item != null) {
        ResearchItem pseudo;

        if(item.icon_resource == null) {
            pseudo = new PseudoResearchItem(item, item.key, col, row, item.icon_item, doubleInThisPage);
        } else {
            pseudo = new PseudoResearchItem(item, item.key, col, row, item.icon_resource, doubleInThisPage);
        }

        String[] siblings = item.siblings;
        if(siblings == null) {
            siblings = new String[]{ pseudo.key };
        } else {
            siblings = Arrays.copyOf(siblings, siblings.length + 1);
            siblings[siblings.length - 1] = pseudo.key;
        }

        item.setSiblings(siblings);

        if(item.isSecondary()) {
            pseudo.setSecondary();
        }

        return pseudo.setParentsHidden(original);
    }
    return null;
}
 
Example #15
Source File: GuiResearchRecipeAuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static GuiResearchRecipeAuraEffects create(GuiResearchRecipe oldGui) {
    Injector inj = new Injector(oldGui);
    ResearchItem ri = inj.getField("research");
    double guiX = inj.getField("guiMapX");
    double guiY = inj.getField("guiMapY");
    int page = inj.getField("page");
    return new GuiResearchRecipeAuraEffects(ri, page, guiX, guiY);
}
 
Example #16
Source File: AuraResearchManager.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void registerAuraResearches() {
    for(Aspect a : AuraEffectHandler.registeredEffects.keySet()) {
        new ResearchItem(String.format(TC_AURA_RESEARCH_STR, a.getTag()), Gadomancy.MODID).registerResearchItem();
    }
}
 
Example #17
Source File: PseudoResearchItem.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static ResearchItem create(String original, int col, int row) {
    return create(original, col, row, false);
}
 
Example #18
Source File: PseudoResearchItem.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private PseudoResearchItem(ResearchItem original, String key, int col, int row, ItemStack icon, boolean doubleThisPage) {
    super(PSEUDO_PREFIX + key + (doubleThisPage ? ".2" : ""), col, row, original.getComplexity(), icon, new AspectList());
    this.original = original;
    setStub().setHidden();
}
 
Example #19
Source File: PseudoResearchItem.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private PseudoResearchItem(ResearchItem original, String key, int col, int row, ResourceLocation icon, boolean doubleThisPage) {
    super(PSEUDO_PREFIX + key + (doubleThisPage ? ".2" : ""), col, row, original.getComplexity(), icon, new AspectList());
    this.original = original;
    setStub().setHidden();
}