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.
*/
- public static ChemiCraftAPI instance = new ChemiCraftAPI();
+ public static final ChemiCraftAPI instance = new ChemiCraftAPI();
/**
* List of compounds names.
*/
- private static ArrayList<String> compoundsNameList = new ArrayList();
+ private ArrayList<String> compoundsNameList = new ArrayList<String>();
/**
* List of compounds names(Some kind of language).
*/
- private static ArrayList<String> compoundsLangNameList = new ArrayList();
+ private ArrayList<String> compoundsLangNameList = new ArrayList<String>();
/**
* List of compounds the language names.
*/
- private static ArrayList<String> compoundsLangList = new ArrayList();
+ private ArrayList<String> compoundsLangList = new ArrayList<String>();
/**
* List of compounds handlers.
*/
- private static ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
+ private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
+
+
+ /**
+ * 化合物の文字列をダメージ値に変換します。
+ */
+ private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
/**
* List of item name of handler to compounds.
*/
- private static ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
+ private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
+
+
+ /**
+ * 分解台の素材のリスト
+ */
+ private ArrayList<ItemStack> decompositionMaterial = new ArrayList<ItemStack>();
+
+
+ /**
+ * 分解台の結果のリスト
+ */
+ private ArrayList<ItemStack[]> decompositionResults = new ArrayList<ItemStack[]>();
+
+
+ /**
+ * 化合台の素材のリスト
+ */
+ private ArrayList<ItemStack[]> chemicalCombinationMaterials = new ArrayList<ItemStack[]>();
+
+
+ /**
+ * 化合台の結果のリスト
+ */
+ private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
+
+
+ /**
+ * 素材製作台のレシピクラス
+ */
+ private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
+
+
+ /**
+ * ChemiCraftの化学作業台類のレシピのマネージャー
+ */
+ private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
+
/**
* add compound.
* @param name compound name.
*/
- public static void addCompound(String name){
+ public void addCompound(String name){
compoundsNameList.add(name);
compoundsLangNameList.add("");
compoundsLangList.add("");
* @param englishName compound name
* @param langName compound name(specified language)
*/
- public static void addLangCompound(String lang, String englishName, String langName){
+ 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))){
+ compoundHash.put(englishName, i);
+ return i;
+ }
+ }
+ return -1;
+ }
+
+
+
+ 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 static void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
- ChemiCraftAPI.compoundHandlers.add(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(ItemStack[] material, ItemStack result){
+ if(material.length <= 16){
+ chemicalCombinationMaterials.add(material);
+ chemicalCombinationResult.add(result);
+ }else{
+ System.err.println("ChemiCraft内でエラー:addChemicalCombinationRecipeの引数materialの要素数が16を超えています。" + "Material:" + material + " Result:" + 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 static ArrayList<ICompoundHandler> getCompoundHandler(){
+ public ArrayList<ICompoundHandler> getCompoundHandler(){
compoundHandlers.trimToSize();
return compoundHandlers;
- public static ArrayList<String> getCompoundHandlerItemName(){
+ public ArrayList<String> getCompoundHandlerItemName(){
compoundHandlerItemNames.trimToSize();
return compoundHandlerItemNames;
}
- public static ArrayList<String> getCompoundsName(){
+ public ArrayList<String> getCompoundsName(){
compoundsNameList.trimToSize();
return compoundsNameList;
}
- public static ArrayList<String> getCompoundsLangName(){
+ public ArrayList<String> getCompoundsLangName(){
compoundsLangNameList.trimToSize();
return compoundsLangNameList;
}
- public static ArrayList<String> getCompoundsLang(){
+ public ArrayList<String> getCompoundsLang(){
compoundsLangList.trimToSize();
return compoundsLangList;
}
+
+
+ public ArrayList<ItemStack> getDecompositionMaterial(){
+ return decompositionMaterial;
+ }
+
+
+
+ public ArrayList<ItemStack[]> getDecompositionResult(){
+ return decompositionResults;
+ }
+
+
+
+ public ArrayList<ItemStack[]> getChemicalCombinationMaterial(){
+ return chemicalCombinationMaterials;
+ }
+
+
+
+ public ArrayList<ItemStack> getChemicalCombinationResult(){
+ return chemicalCombinationResult;
+ }
+
+ public ArrayList<MaterialRecipe> getMaterialRecipe(){
+ return materialRecipe;
+ }
+
+ public ChemiCraftCraftingManager getCraftingManager(){
+ return chemiCraftCraftingManager;
+ }
+
}