OSDN Git Service

修正
[chemicraft/ChemiCraftNext.git] / common / pcc / chemicraft / ChemiCraftAPI.java
index 2110f73..821bb97 100644 (file)
@@ -3,13 +3,17 @@ package pcc.chemicraft;
 import java.util.ArrayList;
 import java.util.HashMap;
 
+import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
+import pcc.chemicraft.gen.WorldGenAtomsOre;
 import pcc.chemicraft.system.ChemiCraftCraftingManager;
 import pcc.chemicraft.tileentity.TileEntityPyrolysisTable;
 import pcc.chemicraft.util.ChemicalNBTRecipe;
 import pcc.chemicraft.util.ICompoundHandler;
+import pcc.chemicraft.util.ListHash;
 import pcc.chemicraft.util.MaterialRecipe;
 
+
 /**
  * ChemiCraftのAPI
  * 基本的にAddonはこのクラスのインスタンスを使う
@@ -24,46 +28,56 @@ public class ChemiCraftAPI {
        private static ChemiCraftAPI instance = new ChemiCraftAPI();
 
 
+       public static ChemiCraftAPI instance(){
+               return instance;
+       }
+
+
        /**
-        * List of compounds names.
+        * 鉱石別元素数リスト
         */
-       private ArrayList<String> compoundsNameList = new ArrayList<String>();
+       private HashMap<String, Integer[]> atomOresAmountsHash = new HashMap<String, Integer[]>();
 
 
        /**
-        * List of compounds names(Some kind of language).
+        * 鉱石別元素リスト
         */
-       private ArrayList<String> compoundsLangNameList = new ArrayList<String>();
+       private HashMap<String, Integer[]> atomOresAtomsHash = new HashMap<String, Integer[]>();
 
 
        /**
-        * List of compounds the language names.
+        * 鉱石の言語リスト
         */
-       private ArrayList<String> compoundsLangList = new ArrayList<String>();
+       private ListHash<String, String> atomOresLangListHash = new ListHash<String, String>();
 
 
        /**
-        * List of compounds handlers.
+        * 鉱石リスト
         */
-       private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
+       private ArrayList<WorldGenAtomsOre> atomOresList = new ArrayList<WorldGenAtomsOre>();
 
 
        /**
-        * 化合物の文字列をダメージ値に変換します。
+        * 鉱石名リスト
         */
-       private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
+       private ListHash<String, String> atomOresNameListHash = new ListHash<String, String>();
+
 
 
        /**
-        * List of item name of handler to compounds.
+        * 電池言語リスト
         */
-       private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
+       private ListHash<String, String> chemicalCellsLangListHash = new ListHash<String, String>();
 
 
        /**
-        * 化合台の原子の種類のリスト
+        * 電池名リスト
         */
-       private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
+       private ListHash<String, String> chemicalCellsNameListHash = new ListHash<String, String>();
+
+
+       private HashMap<ItemStack, Integer> chemicalCellsFuelList = new HashMap<ItemStack, Integer>();
+
 
 
        /**
@@ -73,15 +87,15 @@ public class ChemiCraftAPI {
 
 
        /**
-        * 化合台の結果のリスト
+        * 化合台の原子の種類のリスト
         */
-       private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
+       private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
 
 
        /**
-        * 素材製作台のレシピクラス
+        * 化合台の結果のリスト
         */
-       private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
+       private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
 
 
        /**
@@ -91,6 +105,43 @@ public class ChemiCraftAPI {
 
 
        /**
+        * List of item name of handler to compounds.
+        */
+       private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
+
+
+       /**
+        * List of compounds handlers.
+        */
+       private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
+
+
+       /**
+        * 化合物の文字列をダメージ値に変換します。
+        */
+       private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
+
+
+       /**
+        * List of compounds the language names.
+        */
+       private ListHash<String, String> compoundsLangListHash = new ListHash<String, String>();
+
+
+       /**
+        * List of compounds names.
+        */
+       private ListHash<String, String> compoundsNameListHash = new ListHash<String, String>();
+
+
+
+       /**
+        * 素材製作台のレシピクラス
+        */
+       private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
+
+
+       /**
         * ツール&武器作成台の素材一覧のリスト
         */
        private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
@@ -102,6 +153,7 @@ public class ChemiCraftAPI {
        private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
 
 
+
        /**
         * ツール&武器作成台の不定形であるか
         */
@@ -110,48 +162,62 @@ public class ChemiCraftAPI {
 
 
        /**
-        * add compound.
-        * @param name compound name.
+        * 鉱石を追加します
+        * @param par1Name 鉱石名
+        * @param par2Atoms 元素
+        * @param par3Amounts 元素数
+        * @param par4Id ID
+        * @param par5Size 量
+        * @param par6Frequency 頻度
+        * @param par7PosY Y座標
         */
-       public void addCompound(String name){
-               addLangCompound("", name, "");
+       public void addAtomOres(String par1Name, Integer[] par2Atoms, Integer[] par3Amounts, int par4Id, int par5Size, int par6Frequency, int par7PosY){
+               atomOresList.add(new WorldGenAtomsOre(par4Id, getAtomOresMetaOfLastIndex(), par5Size, par6Frequency, par7PosY));
+               atomOresAtomsHash.put(par1Name, par2Atoms);
+               atomOresAmountsHash.put(par1Name, par3Amounts);
+               addAtomOresLanguage(par1Name, par1Name, "en_US");
+       }
+
+
+
+       public void addAtomOres(String par1Name, String[] par2Atoms, Integer[] par3Amounts, int par4Id, int par5Size, int par6Frequency, int par7PosY){
+               addAtomOres(par1Name, ChemiCraftData.toAtoms(par2Atoms), par3Amounts, par7PosY, par7PosY, par7PosY, par7PosY);
        }
 
 
 
        /**
-        * add compound corresponding to the language.
-        * @param lang Language to the corresponding
-        * @param englishName compound name
-        * @param langName compound name(specified language)
+        * 既に登録した鉱石の新しい名前・言語を追加します
+        * @param par1Name 英語名
+        * @param par2NewName 新しい名前
+        * @param par3Language 言語
         */
-       public void addLangCompound(String lang, String englishName, String langName){
-               compoundsNameList.add(englishName);
-               compoundsLangNameList.add(langName);
-               compoundsLangList.add(lang);
-               compoundHash.put(englishName, compoundHash.size());
+       public void addAtomOresLanguage(String par1Name, String par2NewName, String par3Language){
+               atomOresNameListHash.add(par1Name, par2NewName);
+               atomOresLangListHash.add(par1Name, par3Language);
        }
 
 
 
-       public int getCompound(String key){
-               if(compoundHash.get(key) != null){
-                       return compoundHash.get(key);
-               } else {
-                       return -1;
-               }
+       /**
+        * 電池を追加します
+        * @param par1Name
+        */
+       public void addChemicalCell(Item par1ChemicalCell, String par2Name, int par3OperationTime){
+               chemicalCellsFuelList.put(new ItemStack(par1ChemicalCell, 0, chemicalCellsNameListHash.sizeKeysList()), par3OperationTime);
+               addChemicalCellLanguage(par2Name, "en_US", par2Name);
        }
 
 
-
        /**
-        * setting compound handler.
-        * @param handlerItemName
-        * @param compoundHandler
+        * 既に登録した電池の新しい名前・言語を追加します
+        * @param par1Name 英語名
+        * @param par2NewName 新しい名前
+        * @param par3Language 言語
         */
-       public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
-               compoundHandlers.add(compoundHandler);
-               compoundHandlerItemNames.add(handlerItemName);
+       public void addChemicalCellLanguage(String par1Name, String par3NewLanguage, String par2NewName){
+               chemicalCellsNameListHash.add(par1Name, par2NewName);
+               chemicalCellsLangListHash.add(par1Name, par3NewLanguage);
        }
 
 
@@ -170,17 +236,33 @@ public class ChemiCraftAPI {
 
 
        /**
-        * 分解台のレシピを追加します
-        * @param material 素材
-        * @param results 原子の元素番号の配列
-        * @param stacks 原子のできる数の配列
+        * add compound.
+        * @param name compound name.
         */
-       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 addCompound(String name){
+               compoundsNameListHash.add(name, name);
+               compoundsLangListHash.add(name, "en_US");
+               compoundHash.put(name, compoundHash.size());
+       }
+
+
+
+       /**
+        * add compound corresponding to the language.
+        * @param lang Language to the corresponding
+        * @param englishName compound name
+        * @param langName compound name(specified language)
+        */
+       public void addCompound(String lang, String englishName, String langName){
+               addCompound(englishName);
+               addCompoundLanguage(lang, englishName, langName);
+       }
+
+
+
+       public void addCompoundLanguage(String lang, String englishName, String langName){
+               compoundsNameListHash.add(englishName, langName);
+               compoundsLangListHash.add(englishName, lang);
        }
 
 
@@ -195,28 +277,30 @@ public class ChemiCraftAPI {
        }
 
 
-
        /**
-        * ツール&武器作成台のレシピを追加します
-        * @param materials 素材
-        * @param result 結果
+        * 分解台のレシピを追加します
+        * @param material 素材
+        * @param integers 原子の元素番号の配列
+        * @param integers2 原子のできる数の配列
         */
-       public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
-               toolAndWeaponMaterials.add(materials);
-               toolAndWeaponResult.add(result);
-               toolAndWeaponSharpless.add(false);
+       public void addDecompositionRecipe(ItemStack material, Integer[] integers, Integer[] integers2) {
+               ItemStack[] itemstacks = new ItemStack[integers.length];
+               for (int i = 0; i < itemstacks.length; i++) {
+                       itemstacks[i] = new ItemStack(ChemiCraft.instance.itemAtoms,integers2[i], integers[i]);
+               }
+               TileEntityPyrolysisTable.addRecipe(material, itemstacks);
        }
 
 
+
        /**
-        * ツール&武器作成台の不定形レシピを追加します
+        * 素材作成台のレシピを追加します
         * @param materials 素材
         * @param result 結果
+        * @param nbtRecipe NBT(Nullの場合はなし)
         */
-       public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
-               toolAndWeaponMaterials.add(materials);
-               toolAndWeaponResult.add(result);
-               toolAndWeaponSharpless.add(true);
+       public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
+               materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
        }
 
 
@@ -234,54 +318,86 @@ public class ChemiCraftAPI {
 
 
        /**
-        * 素材作成台のレシピを追加します
+        * ツール&武器作成台の不定形レシピを追加します
         * @param materials 素材
         * @param result 結果
-        * @param nbtRecipe NBT(Nullの場合はなし)
         */
-       public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
-               materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
+       public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
+               toolAndWeaponMaterials.add(materials);
+               toolAndWeaponResult.add(result);
+               toolAndWeaponSharpless.add(true);
+       }
+
+
+       /**
+        * ツール&武器作成台のレシピを追加します
+        * @param materials 素材
+        * @param result 結果
+        */
+       public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
+               toolAndWeaponMaterials.add(materials);
+               toolAndWeaponResult.add(result);
+               toolAndWeaponSharpless.add(false);
        }
+
+
+       public ArrayList<WorldGenAtomsOre> getAtomOres(){
+               return atomOresList;
+       }
+
+       
        //以下システム関連//////////////////////////////////////////////////////
 
-       public ArrayList<ICompoundHandler> getCompoundHandler(){
-               compoundHandlers.trimToSize();
-               return compoundHandlers;
+       public HashMap<String, Integer[]> getAtomOresAmounts(){
+               return atomOresAmountsHash;
+       }
+
 
+
+       public HashMap<String, Integer[]> getAtomOresAtoms(){
+               return atomOresAtomsHash;
        }
 
 
 
-       public ArrayList<String> getCompoundHandlerItemName(){
-               compoundHandlerItemNames.trimToSize();
-               return compoundHandlerItemNames;
+       public ListHash<String, String> getAtomOresLanguage(){
+               return atomOresLangListHash;
        }
 
 
 
-       public ArrayList<String> getCompoundsName(){
-               compoundsNameList.trimToSize();
-               return compoundsNameList;
+       public int getAtomOresLastIndex(){
+               return atomOresNameListHash.sizeKeysList() / 16;
        }
 
 
 
-       public ArrayList<String> getCompoundsLangName(){
-               compoundsLangNameList.trimToSize();
-               return compoundsLangNameList;
+       public int getAtomOresMetaOfLastIndex(){
+               return atomOresNameListHash.sizeKeysList() - getAtomOresLastIndex() * 16;
        }
 
 
 
-       public ArrayList<String> getCompoundsLang(){
-               compoundsLangList.trimToSize();
-               return compoundsLangList;
+       public ListHash<String, String> getAtomOresName(){
+               return atomOresNameListHash;
        }
 
 
 
-       public ArrayList<String[]> getChemicalCombinationAtoms(){
-               return chemicalCombinationAtoms;
+       public HashMap<ItemStack, Integer> getChemicalCellsFuelList(){
+               return chemicalCellsFuelList;
+       }
+
+
+
+       public ListHash<String, String> getChemicalCellsLanguage(){
+               return chemicalCellsLangListHash;
+       }
+
+
+
+       public ListHash<String, String> getChemicalCellsName(){
+               return chemicalCellsNameListHash;
        }
 
 
@@ -292,12 +408,61 @@ public class ChemiCraftAPI {
 
 
 
+       public ArrayList<String[]> getChemicalCombinationAtoms(){
+               return chemicalCombinationAtoms;
+       }
+
+
+
        public ArrayList<ItemStack> getChemicalCombinationResult(){
                return chemicalCombinationResult;
        }
 
 
 
+       public int getCompound(String key){
+               if(compoundHash.get(key) != null){
+                       return compoundHash.get(key);
+               } else {
+                       return -1;
+               }
+       }
+
+
+
+       public ArrayList<ICompoundHandler> getCompoundHandler(){
+               compoundHandlers.trimToSize();
+               return compoundHandlers;
+
+       }
+
+
+
+       public ArrayList<String> getCompoundHandlerItemName(){
+               compoundHandlerItemNames.trimToSize();
+               return compoundHandlerItemNames;
+       }
+
+
+
+       public ListHash<String, String> getCompoundsLang(){
+               return compoundsLangListHash;
+       }
+
+
+
+       public ListHash<String, String> getCompoundsName(){
+               return compoundsNameListHash;
+       }
+
+
+
+       public ChemiCraftCraftingManager getCraftingManager(){
+               return chemiCraftCraftingManager;
+       }
+
+
+
        public ArrayList<MaterialRecipe> getMaterialRecipe(){
                return materialRecipe;
        }
@@ -322,14 +487,14 @@ public class ChemiCraftAPI {
 
 
 
-       public ChemiCraftCraftingManager getCraftingManager(){
-               return chemiCraftCraftingManager;
-       }
-
-
-
-       public static ChemiCraftAPI getInstance(){
-               return instance;
+       /**
+        * setting compound handler.
+        * @param handlerItemName
+        * @param compoundHandler
+        */
+       public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
+               compoundHandlers.add(compoundHandler);
+               compoundHandlerItemNames.add(handlerItemName);
        }
 
 }