package chemicraft; import java.util.ArrayList; import java.util.HashMap; import net.minecraft.src.ItemStack; import chemicraft.system.ChemiCraftCraftingManager; import chemicraft.util.ChemicalNBTRecipe; import chemicraft.util.ICompoundHandler; import chemicraft.util.MaterialRecipe; /** * ChemiCraftのAPI * 基本的にAddonはこのクラスのインスタンスを使う * @author mozipi * */ public class ChemiCraftAPI { /** * Instance of the ChemiCraftAPI. */ private static ChemiCraftAPI instance = new ChemiCraftAPI(); /** * List of compounds names. */ private ArrayList compoundsNameList = new ArrayList(); /** * List of compounds names(Some kind of language). */ private ArrayList compoundsLangNameList = new ArrayList(); /** * List of compounds the language names. */ private ArrayList compoundsLangList = new ArrayList(); /** * List of compounds handlers. */ private ArrayList compoundHandlers = new ArrayList(); /** * 化合物の文字列をダメージ値に変換します。 */ private HashMap compoundHash = new HashMap(); /** * List of item name of handler to compounds. */ private ArrayList compoundHandlerItemNames = new ArrayList(); /** * 分解台の素材のリスト */ private ArrayList decompositionMaterial = new ArrayList(); /** * 分解台の結果のリスト */ private ArrayList decompositionResults = new ArrayList(); /** * 化合台の原子の種類のリスト */ private ArrayList chemicalCombinationAtoms = new ArrayList(); /** * 化合台の原子の数のリスト */ private ArrayList chemicalCombinationAmounts = new ArrayList(); /** * 化合台の結果のリスト */ private ArrayList chemicalCombinationResult = new ArrayList(); /** * 素材製作台のレシピクラス */ private ArrayList materialRecipe = new ArrayList(); /** * ChemiCraftの化学作業台類のレシピのマネージャー */ private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager(); /** * add compound. * @param name compound name. */ public void addCompound(String name){ compoundsNameList.add(name); compoundsLangNameList.add(""); compoundsLangList.add(""); } /** * add compound corresponding to the language. * @param lang Language to the corresponding * @param englishName compound name * @param langName compound name(specified language) */ public void addLangCompound(String lang, String englishName, String langName){ compoundsNameList.add(englishName); compoundsLangNameList.add(langName); compoundsLangList.add(lang); } public int getDamageByName(String englishName){ for(int i = 0;i < compoundsNameList.size();i++){ if(englishName.equals(compoundsNameList.get(i))){ return i; } } return -1; } public void addCompoundHash(String key, int value){ compoundHash.put(key, value); } public void addCompoundHash(Object[] object){ for(int i = 0;i < compoundsNameList.size();i++){ if(object[i].equals(compoundsNameList.get(i))){ compoundHash.put((String) object[i], i); } } } public int getCompound(String key){ if(compoundHash.get(key) != null){ return compoundHash.get(key); } else { return -1; } } /** * setting compound handler. * @param handlerItemName * @param compoundHandler */ public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){ compoundHandlers.add(compoundHandler); compoundHandlerItemNames.add(handlerItemName); } /** * 分解レシピを追加します。resultの要素数は0<= n <= 16にしてください。 * @param material 素材 * @param result 結果 */ public void addDecompositionRecipe(ItemStack material, ItemStack[] result){ if(result.length <= 16){ decompositionMaterial.add(material); decompositionResults.add(result); }else{ System.err.println("ChemiCraft内でエラー:addDecompositionRecipeの引数resultの要素数が16を超えています。" + "Material:" + material + " Result:" + result); } } /** * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。 * @param material 素材 * @param result 結果 */ public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){ chemicalCombinationAtoms.add(atoms); chemicalCombinationAmounts.add(amounts); chemicalCombinationResult.add(result); } public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){ materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true)); } public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){ materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false)); } //以下システム関連////////////////////////////////////////////////////// public ArrayList getCompoundHandler(){ compoundHandlers.trimToSize(); return compoundHandlers; } public ArrayList getCompoundHandlerItemName(){ compoundHandlerItemNames.trimToSize(); return compoundHandlerItemNames; } public ArrayList getCompoundsName(){ compoundsNameList.trimToSize(); return compoundsNameList; } public ArrayList getCompoundsLangName(){ compoundsLangNameList.trimToSize(); return compoundsLangNameList; } public ArrayList getCompoundsLang(){ compoundsLangList.trimToSize(); return compoundsLangList; } public ArrayList getDecompositionMaterial(){ return decompositionMaterial; } public ArrayList getDecompositionResult(){ return decompositionResults; } public ArrayList getChemicalCombinationAtoms(){ return chemicalCombinationAtoms; } public ArrayList getChemicalCombinationAmounts(){ return chemicalCombinationAmounts; } public ArrayList getChemicalCombinationResult(){ return chemicalCombinationResult; } public ArrayList getMaterialRecipe(){ return materialRecipe; } public ChemiCraftCraftingManager getCraftingManager(){ return chemiCraftCraftingManager; } public static ChemiCraftAPI getInstance(){ return instance; } }