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