/** * 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.HashMap; import java.util.List; import java.util.Map; 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 vazkii.botania.api.subtile.SubTileEntity; 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(); private static Map oreWeights = new HashMap(); static { registerSubTile("", DummySubTile.class); addOreWeight("oreAluminum", 615); // Tinkers' Construct addOreWeight("oreAmber", 160); // Thaumcraft addOreWeight("oreApatite", 270); // Forestry addOreWeight("oreBlueTopaz", 235); // Ars Magica addOreWeight("oreCertusQuartz", 235); // Applied Energistics addOreWeight("oreChimerite", 270); // Ars Magica addOreWeight("oreCinnabar", 170); // Thaumcraft addOreWeight("oreCoal", 2645); // Vanilla addOreWeight("oreCopper", 600); // IC2, Thermal Expansion, Tinkers' Construct, etc. addOreWeight("oreDiamond", 65); // Vanilla addOreWeight("oreEmerald", 50); // Vanilla addOreWeight("oreFzDarkIron", 60); // Factorization addOreWeight("oreGold", 165); // Vanilla addOreWeight("oreInfusedAir", 45); // Thaumcraft addOreWeight("oreInfusedEarth", 45); // Thaumcraft addOreWeight("oreInfusedEntropy", 45); // Thaumcraft addOreWeight("oreInfusedFire", 45); // Thaumcraft addOreWeight("oreInfusedOrder", 45); // Thaumcraft addOreWeight("oreInfusedWater", 45); // Thaumcraft addOreWeight("oreIron", 1500); // Vanilla addOreWeight("oreLapis", 55); // Vanilla addOreWeight("oreLead", 335); // IC2, Thermal Expansion, Factorization, etc. addOreWeight("oreNickel", 70); // Thermal Expansion addOreWeight("orePeridot", 70); // Project RED addOreWeight("oreRedstone", 365); // Vanilla addOreWeight("oreRuby", 70); // Project RED addOreWeight("oreSapphire", 70); // Project RED addOreWeight("oreSilver", 400); // Thermal Expansion, Factorization, etc. addOreWeight("oreSulfur", 105); // Railcraft addOreWeight("oreTin", 505); // IC2, Thermal Expansion, etc. addOreWeight("oreUranium", 110); // IC2 addOreWeight("oreVinteum", 395); // Ars Magica } /** * 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); } /** * Maps an ore (ore dictionary key) to it's weight on the world generation. This * is used for the Orechid flower. Check the static block in the BotaniaAPI class * to get the weights for the vanilla blocks.
* Alternatively get the values with the OreDetector mod:
* https://gist.github.com/Vazkii/9493322 */ public static void addOreWeight(String ore, int weight) { oreWeights.put(ore, weight); } public static int getOreWeight(String ore) { return oreWeights.get(ore); } /** * 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); } }