OSDN Git Service

競合確認
[chemicraft/chemicraft.git] / common / chemicraft / ChemiCraftAPI.java
index 8111626..a538fed 100644 (file)
@@ -1,8 +1,14 @@
 package chemicraft;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 
-import net.minecraft.src.ItemStack;
+import net.minecraft.item.ItemStack;
+import chemicraft.system.ChemiCraftCraftingManager;
+import chemicraft.tileentity.TileEntityPyrolysisTable;
+import chemicraft.util.ChemicalNBTRecipe;
+import chemicraft.util.ICompoundHandler;
+import chemicraft.util.MaterialRecipe;
 
 /**
  * ChemiCraftのAPI
@@ -15,25 +21,25 @@ public class ChemiCraftAPI {
        /**
         * Instance of the ChemiCraftAPI.
         */
-       public static ChemiCraftAPI instance = new ChemiCraftAPI();
+       private static ChemiCraftAPI instance = new ChemiCraftAPI();
 
 
        /**
         * List of compounds names.
         */
-       private ArrayList<String> compoundsNameList = new ArrayList();
+       private ArrayList<String> compoundsNameList = new ArrayList<String>();
 
 
        /**
         * List of compounds names(Some kind of language).
         */
-       private ArrayList<String> compoundsLangNameList = new ArrayList();
+       private ArrayList<String> compoundsLangNameList = new ArrayList<String>();
 
 
        /**
         * List of compounds the language names.
         */
-       private ArrayList<String> compoundsLangList = new ArrayList();
+       private ArrayList<String> compoundsLangList = new ArrayList<String>();
 
 
        /**
@@ -43,27 +49,27 @@ public class ChemiCraftAPI {
 
 
        /**
-        * List of item name of handler to compounds.
+        * 化合物の文字列をダメージ値に変換します。
         */
-       private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
+       private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
 
 
        /**
-        * 分解台の素材のリスト
+        * List of item name of handler to compounds.
         */
-       private ArrayList<ItemStack> decompositionMaterial = new ArrayList<ItemStack>();
+       private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
 
 
        /**
-        * å\88\86解å\8f°ã\81®çµ\90æ\9e\9cのリスト
+        * å\8c\96å\90\88å\8f°ã\81®å\8e\9få­\90ã\81®ç¨®é¡\9eのリスト
         */
-       private ArrayList<ItemStack[]> decompositionResults = new ArrayList<ItemStack[]>();
+       private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
 
 
        /**
-        * 化合台の素材のリスト
+        * 化合台の原子の数のリスト
         */
-       private ArrayList<ItemStack[]> chemicalCombinationMaterials = new ArrayList<ItemStack[]>();
+       private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
 
 
        /**
@@ -72,40 +78,10 @@ public class ChemiCraftAPI {
        private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
 
 
-
-       /**
-        * 素材製作台の効果添付素材のリスト
-        */
-       private ArrayList<ItemStack[]> materialEffectMaterials = new ArrayList<ItemStack[]>();
-
-
-
-       /**
-        * 素材製作台の素材のリスト
-        */
-       private ArrayList<ItemStack[]> materialMaterials = new ArrayList<ItemStack[]>();
-
-
-
-       /**
-        * 素材製作台の結果のリスト
-        */
-       private ArrayList<ItemStack> materialResult = new ArrayList<ItemStack>();
-
-
-
-       /**
-        * 素材製作台の効果のキーリスト
-        */
-       private ArrayList<String[]> materialEffectKey = new ArrayList<String[]>();
-
-
-
        /**
-        * 素材製作台の効果のリスト
+        * 素材製作台のレシピクラス
         */
-       private ArrayList<Object[]> materialEffectValue = new ArrayList<Object[]>();
-
+       private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
 
 
        /**
@@ -120,9 +96,7 @@ public class ChemiCraftAPI {
         * @param name compound name.
         */
        public void addCompound(String name){
-               compoundsNameList.add(name);
-               compoundsLangNameList.add("");
-               compoundsLangList.add("");
+               addLangCompound("", name, "");
        }
 
 
@@ -137,6 +111,17 @@ public class ChemiCraftAPI {
                compoundsNameList.add(englishName);
                compoundsLangNameList.add(langName);
                compoundsLangList.add(lang);
+               compoundHash.put(englishName, compoundHash.size());
+       }
+
+
+
+       public int getCompound(String key){
+               if(compoundHash.get(key) != null){
+                       return compoundHash.get(key);
+               } else {
+                       return -1;
+               }
        }
 
 
@@ -154,50 +139,42 @@ public class ChemiCraftAPI {
 
 
        /**
-        * å\88\86解ã\83¬ã\82·ã\83\94ã\82\92追å\8a ã\81\97ã\81¾ã\81\99ã\80\82resultの要素数は0<= n <= 16にしてください。
+        * å\8c\96å\90\88ã\83¬ã\82·ã\83\94ã\82\92追å\8a ã\81\97ã\81¾ã\81\99ã\80\82materialの要素数は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);
-               }
+       public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
+               chemicalCombinationAtoms.add(atoms);
+               chemicalCombinationAmounts.add(amounts);
+               chemicalCombinationResult.add(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 addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
+               ItemStack[] itemstacks = new ItemStack[results.length];
+               for (int i = 0; i < itemstacks.length; i++) {
+                       itemstacks[i] = new ItemStack(ChemiCraft.instance.itemAtoms,stacks[i], results[i]);
                }
+               TileEntityPyrolysisTable.addRecipe(material, itemstacks);
        }
 
 
 
-       public void addMaterialRecipe(ItemStack[] materials, ItemStack[] effectMaterials,ItemStack result, String[] key, Object[] value){
-               if(materials.length <= 9){
-                       if(effectMaterials.length <= 3){
-                               materialMaterials.add(materials);
-                               materialResult.add(result);
-                               materialEffectKey.add(key);
-                               materialEffectValue.add(value);
-                       }else{
-                               System.err.println("ChemiCraft内でエラー:addMaterialRecipeの引数effectMaterialsの要素数が3を超えています。" + "Material:" + materials + " Result:" + result + " key" + key + " value:" + value);
-                       }
-               }else{
-                       System.err.println("ChemiCraft内でエラー:addMaterialRecipeの引数materialsの要素数が9を超えています。" + "Material:" + materials + " Result:" + result + " key" + key + " value:" + value);
-               }
+       public void addDecompositionFuel(ItemStack itemstack, int burnTime) {
+               TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
+       }
+
+
+
+       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));
        }
        //以下システム関連//////////////////////////////////////////////////////
 
@@ -237,26 +214,26 @@ public class ChemiCraftAPI {
 
 
 
-       public ArrayList<ItemStack> getDecompositionMaterial(){
-               return decompositionMaterial;
+       public ArrayList<String[]> getChemicalCombinationAtoms(){
+               return chemicalCombinationAtoms;
        }
 
 
 
-       public ArrayList<ItemStack[]> getDecompositionResult(){
-               return decompositionResults;
+       public ArrayList<Integer[]> getChemicalCombinationAmounts(){
+               return chemicalCombinationAmounts;
        }
 
 
 
-       public ArrayList<ItemStack[]> getChemicalCombinationMaterial(){
-               return chemicalCombinationMaterials;
+       public ArrayList<ItemStack> getChemicalCombinationResult(){
+               return chemicalCombinationResult;
        }
 
 
 
-       public ArrayList<ItemStack> getChemicalCombinationResult(){
-               return chemicalCombinationResult;
+       public ArrayList<MaterialRecipe> getMaterialRecipe(){
+               return materialRecipe;
        }
 
 
@@ -265,4 +242,10 @@ public class ChemiCraftAPI {
                return chemiCraftCraftingManager;
        }
 
+
+
+       public static ChemiCraftAPI getInstance(){
+               return instance;
+       }
+
 }