OSDN Git Service

330e1c01985d2d18ed576619133b32ae0c3104a2
[chemicraft/chemicraft.git] / common / chemicraft / ChemiCraftAPI.java
1 package chemicraft;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5
6 import net.minecraft.src.ItemStack;
7 import chemicraft.system.ChemiCraftCraftingManager;
8 import chemicraft.util.ChemicalNBTRecipe;
9 import chemicraft.util.ICompoundHandler;
10 import chemicraft.util.MaterialRecipe;
11
12 /**
13  * ChemiCraftのAPI
14  * 基本的にAddonはこのクラスのインスタンスを使う
15  * @author mozipi
16  *
17  */
18 public class ChemiCraftAPI {
19
20         /**
21          * Instance of the ChemiCraftAPI.
22          */
23         private static ChemiCraftAPI instance = new ChemiCraftAPI();
24
25
26         /**
27          * List of compounds names.
28          */
29         private ArrayList<String> compoundsNameList = new ArrayList<String>();
30
31
32         /**
33          * List of compounds names(Some kind of language).
34          */
35         private ArrayList<String> compoundsLangNameList = new ArrayList<String>();
36
37
38         /**
39          * List of compounds the language names.
40          */
41         private ArrayList<String> compoundsLangList = new ArrayList<String>();
42
43
44         /**
45          * List of compounds handlers.
46          */
47         private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
48
49
50         /**
51          * 化合物の文字列をダメージ値に変換します。
52          */
53         private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
54
55
56         /**
57          * List of item name of handler to compounds.
58          */
59         private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
60
61
62         /**
63          * 分解台の素材のリスト
64          */
65         private ArrayList<ItemStack> decompositionMaterial = new ArrayList<ItemStack>();
66
67
68         /**
69          * 分解台の結果のリスト
70          */
71         private ArrayList<ItemStack[]> decompositionResults = new ArrayList<ItemStack[]>();
72
73
74         /**
75          * 化合台の原子の種類のリスト
76          */
77         private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
78
79
80         /**
81          * 化合台の原子の数のリスト
82          */
83         private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
84
85
86         /**
87          * 化合台の結果のリスト
88          */
89         private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
90
91
92         /**
93          * 素材製作台のレシピクラス
94          */
95         private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
96
97
98         /**
99          * ChemiCraftの化学作業台類のレシピのマネージャー
100          */
101         private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
102
103
104
105         /**
106          * add compound.
107          * @param name compound name.
108          */
109         public void addCompound(String name){
110                 compoundsNameList.add(name);
111                 compoundsLangNameList.add("");
112                 compoundsLangList.add("");
113         }
114
115
116
117         /**
118          * add compound corresponding to the language.
119          * @param lang Language to the corresponding
120          * @param englishName compound name
121          * @param langName compound name(specified language)
122          */
123         public void addLangCompound(String lang, String englishName, String langName){
124                 compoundsNameList.add(englishName);
125                 compoundsLangNameList.add(langName);
126                 compoundsLangList.add(lang);
127         }
128
129
130
131         public int getDamageByName(String englishName){
132                 for(int i = 0;i < compoundsNameList.size();i++){
133                         if(englishName.equals(compoundsNameList.get(i))){
134                                 compoundHash.put(englishName, i);
135                                 return i;
136                         }
137                 }
138                 return -1;
139         }
140
141
142
143         public int getCompound(String key){
144                 if(compoundHash.get(key) != null){
145                         return compoundHash.get(key);
146                 } else {
147                         return -1;
148                 }
149         }
150
151
152
153         /**
154          * setting compound handler.
155          * @param handlerItemName
156          * @param compoundHandler
157          */
158         public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
159                 compoundHandlers.add(compoundHandler);
160                 compoundHandlerItemNames.add(handlerItemName);
161         }
162
163
164
165         /**
166          * 分解レシピを追加します。resultの要素数は0<= n <= 16にしてください。
167          * @param material 素材
168          * @param result 結果
169          */
170         public void addDecompositionRecipe(ItemStack material, ItemStack[] result){
171                 if(result.length <= 16){
172                         decompositionMaterial.add(material);
173                         decompositionResults.add(result);
174                 }else{
175                         System.err.println("ChemiCraft内でエラー:addDecompositionRecipeの引数resultの要素数が16を超えています。" + "Material:" + material + "  Result:" + result);
176                 }
177         }
178
179
180
181         /**
182          * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
183          * @param material 素材
184          * @param result 結果
185          */
186         public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
187                 chemicalCombinationAtoms.add(atoms);
188                 chemicalCombinationAmounts.add(amounts);
189                 chemicalCombinationResult.add(result);
190         }
191
192
193
194         public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
195                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
196         }
197
198         public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
199                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
200         }
201         //以下システム関連//////////////////////////////////////////////////////
202
203         public ArrayList<ICompoundHandler> getCompoundHandler(){
204                 compoundHandlers.trimToSize();
205                 return compoundHandlers;
206
207         }
208
209
210
211         public ArrayList<String> getCompoundHandlerItemName(){
212                 compoundHandlerItemNames.trimToSize();
213                 return compoundHandlerItemNames;
214         }
215
216
217
218         public ArrayList<String> getCompoundsName(){
219                 compoundsNameList.trimToSize();
220                 return compoundsNameList;
221         }
222
223
224
225         public ArrayList<String> getCompoundsLangName(){
226                 compoundsLangNameList.trimToSize();
227                 return compoundsLangNameList;
228         }
229
230
231
232         public ArrayList<String> getCompoundsLang(){
233                 compoundsLangList.trimToSize();
234                 return compoundsLangList;
235         }
236
237
238
239         public ArrayList<ItemStack> getDecompositionMaterial(){
240                 return decompositionMaterial;
241         }
242
243
244
245         public ArrayList<ItemStack[]> getDecompositionResult(){
246                 return decompositionResults;
247         }
248
249
250
251         public ArrayList<String[]> getChemicalCombinationAtoms(){
252                 return chemicalCombinationAtoms;
253         }
254
255
256
257         public ArrayList<Integer[]> getChemicalCombinationAmounts(){
258                 return chemicalCombinationAmounts;
259         }
260
261
262
263         public ArrayList<ItemStack> getChemicalCombinationResult(){
264                 return chemicalCombinationResult;
265         }
266
267
268
269         public ArrayList<MaterialRecipe> getMaterialRecipe(){
270                 return materialRecipe;
271         }
272
273
274
275         public ChemiCraftCraftingManager getCraftingManager(){
276                 return chemiCraftCraftingManager;
277         }
278
279
280
281         public static ChemiCraftAPI getInstance(){
282                 return instance;
283         }
284
285 }