/** * This class was created by . It's distributed as * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * * Botania is Open Source and distributed under a * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) * * File Created @ [Jan 14, 2014, 6:15:28 PM (GMT)] */ package vazkii.botania.api; import java.util.ArrayList; import java.util.List; import javax.swing.text.html.HTMLDocument.RunElement; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import vazkii.botania.api.internal.DummyMethodHandler; import vazkii.botania.api.internal.DummySubTile; import vazkii.botania.api.internal.IInternalMethodHandler; import vazkii.botania.api.lexicon.LexiconCategory; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.api.recipe.RecipeRuneAltar; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; public final class BotaniaAPI { private static List categories = new ArrayList(); private static List allEntries = new ArrayList(); public static List petalRecipes = new ArrayList(); public static List runeAltarRecipes = new ArrayList(); public static List manaInfusionRecipes = new ArrayList(); private static BiMap> subTiles = HashBiMap.> create(); static { registerSubTile("", DummySubTile.class); } /** * The internal method handler in use. Do not overwrite. * @see IInternalMethodHandler */ public static IInternalMethodHandler internalHandler = new DummyMethodHandler(); /** * Registers a Petal Recipe. * @param output The ItemStack to craft. * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper * or String (case for Ore Dictionary). The array can't be larger than 16. * @return The recipe created. */ public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) { RecipePetals recipe = new RecipePetals(output, inputs); petalRecipes.add(recipe); return recipe; } /** * Registers a Rune Altar * @param output The ItemStack to craft. * @param mana The amount of mana required. Don't go over 100000! * @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper * or String (case for Ore Dictionary). The array can't be larger than 16. * @return The recipe created. */ public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) { RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs); runeAltarRecipes.add(recipe); return recipe; } /** * Registers a Mana Infusion Recipe (throw an item in a mana pool) * @param output The ItemStack to craft * @param input The input item, be it an ItemStack or an ore dictionary entry String. * @param mana The amount of mana required. Don't go over 100000! * @return The recipe created. */ public static RecipeManaInfusion registerManaInfusionRecipe(ItemStack output, Object input, int mana) { RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana); manaInfusionRecipes.add(recipe); return recipe; } public static void registerSubTile(String key, Class subtileClass) { subTiles.put(key, subtileClass); } /** * Adds a category to the list of registered categories to appear in the Lexicon. */ public static void addCategory(LexiconCategory category) { categories.add(category); } /** * Gets all registered categories. */ public static List getAllCategories() { return categories; } /** * Registers a Lexicon Entry and adds it to the category passed in. */ public static void addEntry(LexiconEntry entry, LexiconCategory category) { allEntries.add(entry); category.entries.add(entry); } /** * Gets the last recipe to have been added to the recipe list. */ public static IRecipe getLatestAddedRecipe() { List list = CraftingManager.getInstance().getRecipeList(); return list.get(list.size() - 1); } /** * Gets the last x recipes added to the recipe list. */ public static List getLatestAddedRecipes(int x) { List list = CraftingManager.getInstance().getRecipeList(); List newList = new ArrayList(); for(int i = x - 1; i >= 0; i--) newList.add(list.get(list.size() - 1 - i)); return newList; } public static Class getSubTileMapping(String key) { if(!subTiles.containsKey(key)) key = ""; return subTiles.get(key); } public static String getSubTileStringMapping(Class clazz) { return subTiles.inverse().get(clazz); } }