Files
Botania/MODSRC/vazkii/botania/api/BotaniaAPI.java
T

150 lines
5.0 KiB
Java
Raw Normal View History

2014-01-14 18:27:01 +00:00
/**
* This class was created by <Vazkii>. 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;
2014-02-06 23:23:31 +00:00
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;
2014-02-05 13:43:27 +00:00
import vazkii.botania.api.internal.DummySubTile;
2014-02-06 23:23:31 +00:00
import vazkii.botania.api.internal.IInternalMethodHandler;
2014-02-05 13:43:27 +00:00
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
2014-01-30 21:59:39 +00:00
import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.api.recipe.RecipePetals;
2014-02-06 23:23:31 +00:00
import vazkii.botania.api.recipe.RecipeRuneAltar;
2014-01-24 17:24:10 +00:00
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
2014-01-14 18:27:01 +00:00
public final class BotaniaAPI {
2014-01-14 18:53:45 +00:00
private static List<LexiconCategory> categories = new ArrayList<LexiconCategory>();
private static List<LexiconEntry> allEntries = new ArrayList<LexiconEntry>();
2014-02-02 13:24:35 +00:00
public static List<RecipePetals> petalRecipes = new ArrayList<RecipePetals>();
2014-02-06 23:23:31 +00:00
public static List<RecipeRuneAltar> runeAltarRecipes = new ArrayList<RecipeRuneAltar>();
2014-01-30 21:59:39 +00:00
public static List<RecipeManaInfusion> manaInfusionRecipes = new ArrayList<RecipeManaInfusion>();
2014-01-24 17:24:10 +00:00
private static BiMap<String, Class<? extends SubTileEntity>> subTiles = HashBiMap.<String, Class<? extends SubTileEntity>> create();
static {
2014-02-05 13:43:27 +00:00
registerSubTile("", DummySubTile.class);
2014-01-24 17:24:10 +00:00
}
2014-02-02 13:24:35 +00:00
/**
* The internal method handler in use. Do not overwrite.
* @see IInternalMethodHandler
*/
public static IInternalMethodHandler internalHandler = new DummyMethodHandler();
2014-01-17 19:34:55 +00:00
/**
* 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;
}
2014-02-06 23:23:31 +00:00
/**
* 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.
2014-02-06 23:23:31 +00:00
* @return The recipe created.
*/
public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) {
2014-02-06 23:23:31 +00:00
RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs);
runeAltarRecipes.add(recipe);
return recipe;
}
2014-02-02 13:24:35 +00:00
2014-01-30 21:59:39 +00:00
/**
* 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!
2014-01-30 21:59:39 +00:00
* @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;
}
2014-02-02 13:24:35 +00:00
2014-01-24 17:24:10 +00:00
public static void registerSubTile(String key, Class<? extends SubTileEntity> subtileClass) {
subTiles.put(key, subtileClass);
}
2014-02-02 13:24:35 +00:00
/**
* Adds a category to the list of registered categories to appear in the Lexicon.
*/
2014-01-14 18:33:52 +00:00
public static void addCategory(LexiconCategory category) {
categories.add(category);
}
2014-01-17 19:34:55 +00:00
/**
* Gets all registered categories.
*/
2014-01-14 18:33:52 +00:00
public static List<LexiconCategory> getAllCategories() {
return categories;
}
2014-01-17 19:34:55 +00:00
/**
* Registers a Lexicon Entry and adds it to the category passed in.
*/
2014-01-14 18:33:52 +00:00
public static void addEntry(LexiconEntry entry, LexiconCategory category) {
allEntries.add(entry);
category.entries.add(entry);
}
2014-02-02 13:24:35 +00:00
/**
* Gets the last recipe to have been added to the recipe list.
*/
public static IRecipe getLatestAddedRecipe() {
List<IRecipe> list = CraftingManager.getInstance().getRecipeList();
return list.get(list.size() - 1);
}
2014-02-02 13:24:35 +00:00
/**
* Gets the last x recipes added to the recipe list.
*/
public static List<IRecipe> getLatestAddedRecipes(int x) {
List<IRecipe> list = CraftingManager.getInstance().getRecipeList();
2014-01-19 18:48:15 +00:00
List<IRecipe> newList = new ArrayList();
2014-02-02 13:24:35 +00:00
for(int i = x - 1; i >= 0; i--)
2014-01-19 18:48:15 +00:00
newList.add(list.get(list.size() - 1 - i));
2014-02-02 13:24:35 +00:00
2014-01-19 18:48:15 +00:00
return newList;
}
2014-02-02 13:24:35 +00:00
2014-01-24 17:24:10 +00:00
public static Class<? extends SubTileEntity> getSubTileMapping(String key) {
if(!subTiles.containsKey(key))
key = "";
2014-02-02 13:24:35 +00:00
2014-01-24 17:24:10 +00:00
return subTiles.get(key);
}
2014-02-02 13:24:35 +00:00
2014-01-24 17:24:10 +00:00
public static String getSubTileStringMapping(Class<? extends SubTileEntity> clazz) {
return subTiles.inverse().get(clazz);
}
2014-01-14 18:27:01 +00:00
}