OSDN Git Service

39e38cf1774ca94ad87797433e042be195a9e860
[chemicraft/chemicraft.git] / common / pcc / chemicraft / ChemiCraftAPI.java
1 package pcc.chemicraft;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5
6 import net.minecraft.item.ItemStack;
7 import pcc.chemicraft.system.ChemiCraftCraftingManager;
8 import pcc.chemicraft.tileentity.TileEntityPyrolysisTable;
9 import pcc.chemicraft.util.ChemicalNBTRecipe;
10 import pcc.chemicraft.util.ICompoundHandler;
11 import pcc.chemicraft.util.MaterialRecipe;
12
13
14 /**
15  * ChemiCraftのAPI
16  * 基本的にAddonはこのクラスのインスタンスを使う
17  * @author mozipi
18  *
19  */
20 public class ChemiCraftAPI {
21
22         /**
23          * Instance of the ChemiCraftAPI.
24          */
25         private static ChemiCraftAPI instance = new ChemiCraftAPI();
26
27
28         /**
29          * List of compounds names.
30          */
31         private ArrayList<String> compoundsNameList = new ArrayList<String>();
32
33
34         /**
35          * List of compounds names(Some kind of language).
36          */
37         private ArrayList<String> compoundsLangNameList = new ArrayList<String>();
38
39
40         /**
41          * List of compounds the language names.
42          */
43         private ArrayList<String> compoundsLangList = new ArrayList<String>();
44
45
46         /**
47          * List of compounds handlers.
48          */
49         private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
50
51
52         /**
53          * 化合物の文字列をダメージ値に変換します。
54          */
55         private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
56
57
58         /**
59          * List of item name of handler to compounds.
60          */
61         private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
62
63
64         /**
65          * 化合台の原子の種類のリスト
66          */
67         private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
68
69
70         /**
71          * 化合台の原子の数のリスト
72          */
73         private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
74
75
76         /**
77          * 化合台の結果のリスト
78          */
79         private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
80
81
82         /**
83          * 素材製作台のレシピクラス
84          */
85         private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
86
87
88         /**
89          * ChemiCraftの化学作業台類のレシピのマネージャー
90          */
91         private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
92
93
94
95         private ArrayList<Integer> atomsOreIDList = new ArrayList<Integer>();
96
97
98         private ArrayList<Integer> atomsOreMetaList = new ArrayList<Integer>();
99
100
101         private ArrayList<Integer> atomsOreSizeList = new ArrayList<Integer>();
102
103
104         private ArrayList<Integer> atomsOreFrequencyList = new ArrayList<Integer>();
105
106
107         private ArrayList<Integer> atomsOrePosYList = new ArrayList<Integer>();
108
109
110
111         /**
112          * ツール&武器作成台の素材一覧のリスト
113          */
114         private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
115
116
117         /**
118          * ツール&武器作成台の結果のリスト
119          */
120         private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
121
122
123         /**
124          * ツール&武器作成台の不定形であるか
125          */
126         private ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
127
128
129
130         /**
131          * add compound.
132          * @param name compound name.
133          */
134         public void addCompound(String name){
135                 addLangCompound("", name, "");
136         }
137
138
139
140         /**
141          * add compound corresponding to the language.
142          * @param lang Language to the corresponding
143          * @param englishName compound name
144          * @param langName compound name(specified language)
145          */
146         public void addLangCompound(String lang, String englishName, String langName){
147                 compoundsNameList.add(englishName);
148                 compoundsLangNameList.add(langName);
149                 compoundsLangList.add(lang);
150                 compoundHash.put(englishName, compoundHash.size());
151         }
152
153
154
155         public int getCompound(String key){
156                 if(compoundHash.get(key) != null){
157                         return compoundHash.get(key);
158                 } else {
159                         return -1;
160                 }
161         }
162
163
164
165         /**
166          * setting compound handler.
167          * @param handlerItemName
168          * @param compoundHandler
169          */
170         public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
171                 compoundHandlers.add(compoundHandler);
172                 compoundHandlerItemNames.add(handlerItemName);
173         }
174
175
176
177         /**
178          * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
179          * @param material 素材
180          * @param result 結果
181          */
182         public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
183                 chemicalCombinationAtoms.add(atoms);
184                 chemicalCombinationAmounts.add(amounts);
185                 chemicalCombinationResult.add(result);
186         }
187
188
189
190         /**
191          * 分解台のレシピを追加します
192          * @param material 素材
193          * @param results 原子の元素番号の配列
194          * @param stacks 原子のできる数の配列
195          */
196         public void addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
197                 ItemStack[] itemstacks = new ItemStack[results.length];
198                 for (int i = 0; i < itemstacks.length; i++) {
199                         itemstacks[i] = new ItemStack(ChemiCraft.instance.itemAtoms,stacks[i], results[i]);
200                 }
201                 TileEntityPyrolysisTable.addRecipe(material, itemstacks);
202         }
203
204
205
206         /**
207          * 分解台の燃料を追加します
208          * @param itemstack 燃料のItemStack
209          * @param burnTime 燃焼時間(tick * rate)
210          */
211         public void addDecompositionFuel(ItemStack itemstack, int burnTime) {
212                 TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
213         }
214
215
216
217         /**
218          * ツール&武器作成台のレシピを追加します
219          * @param materials 素材
220          * @param result 結果
221          */
222         public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
223                 toolAndWeaponMaterials.add(materials);
224                 toolAndWeaponResult.add(result);
225                 toolAndWeaponSharpless.add(false);
226         }
227
228
229         /**
230          * ツール&武器作成台の不定形レシピを追加します
231          * @param materials 素材
232          * @param result 結果
233          */
234         public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
235                 toolAndWeaponMaterials.add(materials);
236                 toolAndWeaponResult.add(result);
237                 toolAndWeaponSharpless.add(true);
238         }
239
240
241
242         /**
243          * 素材作成台の不定形レシピを追加します
244          * @param materials 素材
245          * @param result 結果
246          * @param nbtRecipe NBT(Nullの場合はなし)
247          */
248         public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
249                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
250         }
251
252
253
254         /**
255          * 素材作成台のレシピを追加します
256          * @param materials 素材
257          * @param result 結果
258          * @param nbtRecipe NBT(Nullの場合はなし)
259          */
260         public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
261                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
262         }
263
264
265
266         public void addAtomsOre(int id, int size, int frequency, int posY){
267                 addAtomsOre(id, 0, size, frequency, posY);
268         }
269
270
271         public void addAtomsOre(int id, int meta, int size, int frequency, int posY){
272                 atomsOreIDList.add(id);
273                 atomsOreMetaList.add(meta);
274                 atomsOreSizeList.add(size);
275                 atomsOreFrequencyList.add(frequency);
276                 atomsOrePosYList.add(posY);
277         }
278         //以下システム関連//////////////////////////////////////////////////////
279
280         public ArrayList<ICompoundHandler> getCompoundHandler(){
281                 compoundHandlers.trimToSize();
282                 return compoundHandlers;
283
284         }
285
286
287
288         public ArrayList<String> getCompoundHandlerItemName(){
289                 compoundHandlerItemNames.trimToSize();
290                 return compoundHandlerItemNames;
291         }
292
293
294
295         public ArrayList<String> getCompoundsName(){
296                 compoundsNameList.trimToSize();
297                 return compoundsNameList;
298         }
299
300
301
302         public ArrayList<String> getCompoundsLangName(){
303                 compoundsLangNameList.trimToSize();
304                 return compoundsLangNameList;
305         }
306
307
308
309         public ArrayList<String> getCompoundsLang(){
310                 compoundsLangList.trimToSize();
311                 return compoundsLangList;
312         }
313
314
315
316         public ArrayList<String[]> getChemicalCombinationAtoms(){
317                 return chemicalCombinationAtoms;
318         }
319
320
321
322         public ArrayList<Integer[]> getChemicalCombinationAmounts(){
323                 return chemicalCombinationAmounts;
324         }
325
326
327
328         public ArrayList<ItemStack> getChemicalCombinationResult(){
329                 return chemicalCombinationResult;
330         }
331
332
333
334         public ArrayList<MaterialRecipe> getMaterialRecipe(){
335                 return materialRecipe;
336         }
337
338
339
340         public ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
341                 return toolAndWeaponMaterials;
342         }
343
344
345
346         public ArrayList<ItemStack> getToolAndWeaponResult() {
347                 return toolAndWeaponResult;
348         }
349
350
351
352         public ArrayList<Boolean> getToolAndWeaponSharpless() {
353                 return toolAndWeaponSharpless;
354         }
355
356
357
358         public ChemiCraftCraftingManager getCraftingManager(){
359                 return chemiCraftCraftingManager;
360         }
361
362
363
364         public ArrayList<Integer> getAtomsOreIDList(){
365                 return atomsOreIDList;
366         }
367
368
369
370         public ArrayList<Integer> getAtomsOreMetaList(){
371                 return atomsOreMetaList;
372         }
373
374
375
376         public ArrayList<Integer> getAtomsOreSizeList(){
377                 return atomsOreSizeList;
378         }
379
380
381
382         public ArrayList<Integer> getAtomsOreFrequencyList(){
383                 return atomsOreFrequencyList;
384         }
385
386
387
388         public ArrayList<Integer> getAtomsOrePosYList(){
389                 return atomsOrePosYList;
390         }
391
392
393
394         public static ChemiCraftAPI instance(){
395                 return instance;
396         }
397
398 }