OSDN Git Service

ts
[chemicraft/chemicraft.git] / common / chemicraft / ChemiCraftAPI.java
index 4ab1572..2a826e8 100644 (file)
@@ -1,13 +1,13 @@
 package chemicraft;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 
-import net.minecraft.src.CraftingManager;
 import net.minecraft.src.ItemStack;
 import chemicraft.system.ChemiCraftCraftingManager;
+import chemicraft.util.ChemicalNBTRecipe;
 import chemicraft.util.ICompoundHandler;
 import chemicraft.util.MaterialRecipe;
-import chemicraft.util.ChemicalNBTRecipe;
 
 /**
  * ChemiCraftのAPI
@@ -20,25 +20,25 @@ 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 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>();
 
 
        /**
@@ -48,6 +48,12 @@ public class ChemiCraftAPI {
 
 
        /**
+        * 化合物の文字列をダメージ値に変換します。
+        */
+       private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
+
+
+       /**
         * List of item name of handler to compounds.
         */
        private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
@@ -116,6 +122,28 @@ public class ChemiCraftAPI {
 
 
 
+       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