OSDN Git Service

「ItemAtomsGrenade」へ変名。
[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                                 return i;
135                         }
136                 }
137                 return -1;
138         }
139
140
141
142         public void addCompoundHash(String key, int value){
143                 compoundHash.put(key, value);
144         }
145
146
147
148         public void addCompoundHash(Object[] object){
149                 for(int i = 0;i < compoundsNameList.size();i++){
150                         if(object[i].equals(compoundsNameList.get(i))){
151                                 compoundHash.put((String) object[i], i);
152                         }
153                 }
154         }
155
156
157
158         public int getCompound(String key){
159                 if(compoundHash.get(key) != null){
160                         return compoundHash.get(key);
161                 } else {
162                         return -1;
163                 }
164         }
165
166
167
168         /**
169          * setting compound handler.
170          * @param handlerItemName
171          * @param compoundHandler
172          */
173         public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
174                 compoundHandlers.add(compoundHandler);
175                 compoundHandlerItemNames.add(handlerItemName);
176         }
177
178
179
180         /**
181          * 分解レシピを追加します。resultの要素数は0<= n <= 16にしてください。
182          * @param material 素材
183          * @param result 結果
184          */
185         public void addDecompositionRecipe(ItemStack material, ItemStack[] result){
186                 if(result.length <= 16){
187                         decompositionMaterial.add(material);
188                         decompositionResults.add(result);
189                 }else{
190                         System.err.println("ChemiCraft内でエラー:addDecompositionRecipeの引数resultの要素数が16を超えています。" + "Material:" + material + "  Result:" + result);
191                 }
192         }
193
194
195
196         /**
197          * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
198          * @param material 素材
199          * @param result 結果
200          */
201         public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
202                 chemicalCombinationAtoms.add(atoms);
203                 chemicalCombinationAmounts.add(amounts);
204                 chemicalCombinationResult.add(result);
205         }
206
207
208
209         public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
210                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
211         }
212
213         public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
214                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
215         }
216         //以下システム関連//////////////////////////////////////////////////////
217
218         public ArrayList<ICompoundHandler> getCompoundHandler(){
219                 compoundHandlers.trimToSize();
220                 return compoundHandlers;
221
222         }
223
224
225
226         public ArrayList<String> getCompoundHandlerItemName(){
227                 compoundHandlerItemNames.trimToSize();
228                 return compoundHandlerItemNames;
229         }
230
231
232
233         public ArrayList<String> getCompoundsName(){
234                 compoundsNameList.trimToSize();
235                 return compoundsNameList;
236         }
237
238
239
240         public ArrayList<String> getCompoundsLangName(){
241                 compoundsLangNameList.trimToSize();
242                 return compoundsLangNameList;
243         }
244
245
246
247         public ArrayList<String> getCompoundsLang(){
248                 compoundsLangList.trimToSize();
249                 return compoundsLangList;
250         }
251
252
253
254         public ArrayList<ItemStack> getDecompositionMaterial(){
255                 return decompositionMaterial;
256         }
257
258
259
260         public ArrayList<ItemStack[]> getDecompositionResult(){
261                 return decompositionResults;
262         }
263
264
265
266         public ArrayList<String[]> getChemicalCombinationAtoms(){
267                 return chemicalCombinationAtoms;
268         }
269
270
271
272         public ArrayList<Integer[]> getChemicalCombinationAmounts(){
273                 return chemicalCombinationAmounts;
274         }
275
276
277
278         public ArrayList<ItemStack> getChemicalCombinationResult(){
279                 return chemicalCombinationResult;
280         }
281
282
283
284         public ArrayList<MaterialRecipe> getMaterialRecipe(){
285                 return materialRecipe;
286         }
287
288
289
290         public ChemiCraftCraftingManager getCraftingManager(){
291                 return chemiCraftCraftingManager;
292         }
293
294
295
296         public static ChemiCraftAPI getInstance(){
297                 return instance;
298         }
299
300 }