OSDN Git Service

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