OSDN Git Service

ts
[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         public static final 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<ItemStack[]> chemicalCombinationMaterials = new ArrayList<ItemStack[]>();
78
79
80         /**
81          * 化合台の結果のリスト
82          */
83         private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
84
85
86         /**
87          * 素材製作台のレシピクラス
88          */
89         private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
90
91
92         /**
93          * ChemiCraftの化学作業台類のレシピのマネージャー
94          */
95         private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
96
97
98
99         /**
100          * add compound.
101          * @param name compound name.
102          */
103         public void addCompound(String name){
104                 compoundsNameList.add(name);
105                 compoundsLangNameList.add("");
106                 compoundsLangList.add("");
107         }
108
109
110
111         /**
112          * add compound corresponding to the language.
113          * @param lang Language to the corresponding
114          * @param englishName compound name
115          * @param langName compound name(specified language)
116          */
117         public void addLangCompound(String lang, String englishName, String langName){
118                 compoundsNameList.add(englishName);
119                 compoundsLangNameList.add(langName);
120                 compoundsLangList.add(lang);
121         }
122
123
124
125         public int getDamageByName(String englishName){
126                 for(int i = 0;i < compoundsNameList.size();i++){
127                         if(englishName.equals(compoundsNameList.get(i))){
128                                 compoundHash.put(englishName, i);
129                                 return i;
130                         }
131                 }
132                 return -1;
133         }
134
135
136
137         public int getCompound(String key){
138                 if(compoundHash.get(key) != null){
139                         return compoundHash.get(key);
140                 } else {
141                         return -1;
142                 }
143         }
144
145
146
147         /**
148          * setting compound handler.
149          * @param handlerItemName
150          * @param compoundHandler
151          */
152         public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
153                 compoundHandlers.add(compoundHandler);
154                 compoundHandlerItemNames.add(handlerItemName);
155         }
156
157
158
159         /**
160          * 分解レシピを追加します。resultの要素数は0<= n <= 16にしてください。
161          * @param material 素材
162          * @param result 結果
163          */
164         public void addDecompositionRecipe(ItemStack material, ItemStack[] result){
165                 if(result.length <= 16){
166                         decompositionMaterial.add(material);
167                         decompositionResults.add(result);
168                 }else{
169                         System.err.println("ChemiCraft内でエラー:addDecompositionRecipeの引数resultの要素数が16を超えています。" + "Material:" + material + "  Result:" + result);
170                 }
171         }
172
173
174
175         /**
176          * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
177          * @param material 素材
178          * @param result 結果
179          */
180         public void addChemicalCombinationRecipe(ItemStack[] material, ItemStack result){
181                 if(material.length <= 16){
182                         chemicalCombinationMaterials.add(material);
183                         chemicalCombinationResult.add(result);
184                 }else{
185                         System.err.println("ChemiCraft内でエラー:addChemicalCombinationRecipeの引数materialの要素数が16を超えています。" + "Material:" + material + "  Result:" + result);
186                 }
187         }
188
189
190
191         public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
192                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
193         }
194
195         public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
196                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
197         }
198         //以下システム関連//////////////////////////////////////////////////////
199
200         public ArrayList<ICompoundHandler> getCompoundHandler(){
201                 compoundHandlers.trimToSize();
202                 return compoundHandlers;
203
204         }
205
206
207
208         public ArrayList<String> getCompoundHandlerItemName(){
209                 compoundHandlerItemNames.trimToSize();
210                 return compoundHandlerItemNames;
211         }
212
213
214
215         public ArrayList<String> getCompoundsName(){
216                 compoundsNameList.trimToSize();
217                 return compoundsNameList;
218         }
219
220
221
222         public ArrayList<String> getCompoundsLangName(){
223                 compoundsLangNameList.trimToSize();
224                 return compoundsLangNameList;
225         }
226
227
228
229         public ArrayList<String> getCompoundsLang(){
230                 compoundsLangList.trimToSize();
231                 return compoundsLangList;
232         }
233
234
235
236         public ArrayList<ItemStack> getDecompositionMaterial(){
237                 return decompositionMaterial;
238         }
239
240
241
242         public ArrayList<ItemStack[]> getDecompositionResult(){
243                 return decompositionResults;
244         }
245
246
247
248         public ArrayList<ItemStack[]> getChemicalCombinationMaterial(){
249                 return chemicalCombinationMaterials;
250         }
251
252
253
254         public ArrayList<ItemStack> getChemicalCombinationResult(){
255                 return chemicalCombinationResult;
256         }
257
258         public ArrayList<MaterialRecipe> getMaterialRecipe(){
259                 return materialRecipe;
260         }
261
262         public ChemiCraftCraftingManager getCraftingManager(){
263                 return chemiCraftCraftingManager;
264         }
265
266 }