OSDN Git Service

とりあえずコミット
[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         /**
96          * 鉱石名リスト
97          */
98         private ArrayList<String> atomsOreNameList = new ArrayList<String>();
99
100
101         /**
102          * 鉱石IDリスト
103          */
104         private ArrayList<Integer> atomsOreIDList = new ArrayList<Integer>();
105
106
107         /**
108          * 鉱石メタデータリスト
109          */
110         private ArrayList<Integer> atomsOreMetaList = new ArrayList<Integer>();
111
112
113         /**
114          * 鉱石量リスト
115          */
116         private ArrayList<Integer> atomsOreSizeList = new ArrayList<Integer>();
117
118
119         /**
120          * 鉱石頻度リスト
121          */
122         private ArrayList<Integer> atomsOreFrequencyList = new ArrayList<Integer>();
123
124
125         /**
126          * 鉱石Y座標リスト
127          */
128         private ArrayList<Integer> atomsOrePosYList = new ArrayList<Integer>();
129
130
131
132         /**
133          * ツール&武器作成台の素材一覧のリスト
134          */
135         private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
136
137
138         /**
139          * ツール&武器作成台の結果のリスト
140          */
141         private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
142
143
144         /**
145          * ツール&武器作成台の不定形であるか
146          */
147         private ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
148
149
150
151         /**
152          * add compound.
153          * @param name compound name.
154          */
155         public void addCompound(String name){
156                 addLangCompound("", name, "");
157         }
158
159
160
161         /**
162          * add compound corresponding to the language.
163          * @param lang Language to the corresponding
164          * @param englishName compound name
165          * @param langName compound name(specified language)
166          */
167         public void addLangCompound(String lang, String englishName, String langName){
168                 compoundsNameList.add(englishName);
169                 compoundsLangNameList.add(langName);
170                 compoundsLangList.add(lang);
171                 compoundHash.put(englishName, compoundHash.size());
172         }
173
174
175
176         public int getCompound(String key){
177                 if(compoundHash.get(key) != null){
178                         return compoundHash.get(key);
179                 } else {
180                         return -1;
181                 }
182         }
183
184
185
186         /**
187          * setting compound handler.
188          * @param handlerItemName
189          * @param compoundHandler
190          */
191         public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
192                 compoundHandlers.add(compoundHandler);
193                 compoundHandlerItemNames.add(handlerItemName);
194         }
195
196
197
198         /**
199          * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
200          * @param material 素材
201          * @param result 結果
202          */
203         public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
204                 chemicalCombinationAtoms.add(atoms);
205                 chemicalCombinationAmounts.add(amounts);
206                 chemicalCombinationResult.add(result);
207         }
208
209
210
211         /**
212          * 分解台のレシピを追加します
213          * @param material 素材
214          * @param results 原子の元素番号の配列
215          * @param stacks 原子のできる数の配列
216          */
217         public void addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
218                 ItemStack[] itemstacks = new ItemStack[results.length];
219                 for (int i = 0; i < itemstacks.length; i++) {
220                         itemstacks[i] = new ItemStack(ChemiCraft.instance.itemAtoms,stacks[i], results[i]);
221                 }
222                 TileEntityPyrolysisTable.addRecipe(material, itemstacks);
223         }
224
225
226
227         /**
228          * 分解台の燃料を追加します
229          * @param itemstack 燃料のItemStack
230          * @param burnTime 燃焼時間(tick * rate)
231          */
232         public void addDecompositionFuel(ItemStack itemstack, int burnTime) {
233                 TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
234         }
235
236
237
238         /**
239          * ツール&武器作成台のレシピを追加します
240          * @param materials 素材
241          * @param result 結果
242          */
243         public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
244                 toolAndWeaponMaterials.add(materials);
245                 toolAndWeaponResult.add(result);
246                 toolAndWeaponSharpless.add(false);
247         }
248
249
250         /**
251          * ツール&武器作成台の不定形レシピを追加します
252          * @param materials 素材
253          * @param result 結果
254          */
255         public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
256                 toolAndWeaponMaterials.add(materials);
257                 toolAndWeaponResult.add(result);
258                 toolAndWeaponSharpless.add(true);
259         }
260
261
262
263         /**
264          * 素材作成台の不定形レシピを追加します
265          * @param materials 素材
266          * @param result 結果
267          * @param nbtRecipe NBT(Nullの場合はなし)
268          */
269         public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
270                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
271         }
272
273
274
275         /**
276          * 素材作成台のレシピを追加します
277          * @param materials 素材
278          * @param result 結果
279          * @param nbtRecipe NBT(Nullの場合はなし)
280          */
281         public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
282                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
283         }
284
285
286
287         /**
288          * 鉱石を追加します
289          * @param name 鉱石名
290          * @param id 鉱石ID
291          * @param meta 鉱石メタデータ
292          * @param size 一度に生成される量
293          * @param frequency 生成頻度
294          * @param posY Y座標
295          */
296         public void addAtomsOre(String name, int id, int size, int frequency, int posY){
297                 addAtomsOre(name, id, 0, size, frequency, posY);
298         }
299
300
301         public void addAtomsOre(String name, int id, int meta, int size, int frequency, int posY){
302                 atomsOreNameList.add(name);
303                 atomsOreIDList.add(id);
304                 atomsOreMetaList.add(meta);
305                 atomsOreSizeList.add(size);
306                 atomsOreFrequencyList.add(frequency);
307                 atomsOrePosYList.add(posY);
308         }
309
310
311         
312         //以下システム関連//////////////////////////////////////////////////////
313
314         public ArrayList<ICompoundHandler> getCompoundHandler(){
315                 compoundHandlers.trimToSize();
316                 return compoundHandlers;
317
318         }
319
320
321
322         public ArrayList<String> getCompoundHandlerItemName(){
323                 compoundHandlerItemNames.trimToSize();
324                 return compoundHandlerItemNames;
325         }
326
327
328
329         public ArrayList<String> getCompoundsName(){
330                 compoundsNameList.trimToSize();
331                 return compoundsNameList;
332         }
333
334
335
336         public ArrayList<String> getCompoundsLangName(){
337                 compoundsLangNameList.trimToSize();
338                 return compoundsLangNameList;
339         }
340
341
342
343         public ArrayList<String> getCompoundsLang(){
344                 compoundsLangList.trimToSize();
345                 return compoundsLangList;
346         }
347
348
349
350         public ArrayList<String[]> getChemicalCombinationAtoms(){
351                 return chemicalCombinationAtoms;
352         }
353
354
355
356         public ArrayList<Integer[]> getChemicalCombinationAmounts(){
357                 return chemicalCombinationAmounts;
358         }
359
360
361
362         public ArrayList<ItemStack> getChemicalCombinationResult(){
363                 return chemicalCombinationResult;
364         }
365
366
367
368         public ArrayList<MaterialRecipe> getMaterialRecipe(){
369                 return materialRecipe;
370         }
371
372
373
374         public ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
375                 return toolAndWeaponMaterials;
376         }
377
378
379
380         public ArrayList<ItemStack> getToolAndWeaponResult() {
381                 return toolAndWeaponResult;
382         }
383
384
385
386         public ArrayList<Boolean> getToolAndWeaponSharpless() {
387                 return toolAndWeaponSharpless;
388         }
389
390
391
392         public ChemiCraftCraftingManager getCraftingManager(){
393                 return chemiCraftCraftingManager;
394         }
395
396
397
398         public ArrayList<String> getAtomsOreNameList(){
399                 return atomsOreNameList;
400         }
401
402
403
404         public ArrayList<Integer> getAtomsOreIDList(){
405                 return atomsOreIDList;
406         }
407
408
409
410         public ArrayList<Integer> getAtomsOreMetaList(){
411                 return atomsOreMetaList;
412         }
413
414
415
416         public ArrayList<Integer> getAtomsOreSizeList(){
417                 return atomsOreSizeList;
418         }
419
420
421
422         public ArrayList<Integer> getAtomsOreFrequencyList(){
423                 return atomsOreFrequencyList;
424         }
425
426
427
428         public ArrayList<Integer> getAtomsOrePosYList(){
429                 return atomsOrePosYList;
430         }
431
432
433
434         public static ChemiCraftAPI instance(){
435                 return instance;
436         }
437
438 }