OSDN Git Service

2110f73e46586411b4d84d96c484f4a2ed0a15de
[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  * ChemiCraftのAPI
15  * 基本的にAddonはこのクラスのインスタンスを使う
16  * @author mozipi
17  *
18  */
19 public class ChemiCraftAPI {
20
21         /**
22          * Instance of the ChemiCraftAPI.
23          */
24         private static ChemiCraftAPI instance = new ChemiCraftAPI();
25
26
27         /**
28          * List of compounds names.
29          */
30         private ArrayList<String> compoundsNameList = new ArrayList<String>();
31
32
33         /**
34          * List of compounds names(Some kind of language).
35          */
36         private ArrayList<String> compoundsLangNameList = new ArrayList<String>();
37
38
39         /**
40          * List of compounds the language names.
41          */
42         private ArrayList<String> compoundsLangList = new ArrayList<String>();
43
44
45         /**
46          * List of compounds handlers.
47          */
48         private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
49
50
51         /**
52          * 化合物の文字列をダメージ値に変換します。
53          */
54         private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
55
56
57         /**
58          * List of item name of handler to compounds.
59          */
60         private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
61
62
63         /**
64          * 化合台の原子の種類のリスト
65          */
66         private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
67
68
69         /**
70          * 化合台の原子の数のリスト
71          */
72         private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
73
74
75         /**
76          * 化合台の結果のリスト
77          */
78         private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
79
80
81         /**
82          * 素材製作台のレシピクラス
83          */
84         private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
85
86
87         /**
88          * ChemiCraftの化学作業台類のレシピのマネージャー
89          */
90         private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
91
92
93         /**
94          * ツール&武器作成台の素材一覧のリスト
95          */
96         private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
97
98
99         /**
100          * ツール&武器作成台の結果のリスト
101          */
102         private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
103
104
105         /**
106          * ツール&武器作成台の不定形であるか
107          */
108         private ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
109
110
111
112         /**
113          * add compound.
114          * @param name compound name.
115          */
116         public void addCompound(String name){
117                 addLangCompound("", name, "");
118         }
119
120
121
122         /**
123          * add compound corresponding to the language.
124          * @param lang Language to the corresponding
125          * @param englishName compound name
126          * @param langName compound name(specified language)
127          */
128         public void addLangCompound(String lang, String englishName, String langName){
129                 compoundsNameList.add(englishName);
130                 compoundsLangNameList.add(langName);
131                 compoundsLangList.add(lang);
132                 compoundHash.put(englishName, compoundHash.size());
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          * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
161          * @param material 素材
162          * @param result 結果
163          */
164         public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
165                 chemicalCombinationAtoms.add(atoms);
166                 chemicalCombinationAmounts.add(amounts);
167                 chemicalCombinationResult.add(result);
168         }
169
170
171
172         /**
173          * 分解台のレシピを追加します
174          * @param material 素材
175          * @param results 原子の元素番号の配列
176          * @param stacks 原子のできる数の配列
177          */
178         public void addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
179                 ItemStack[] itemstacks = new ItemStack[results.length];
180                 for (int i = 0; i < itemstacks.length; i++) {
181                         itemstacks[i] = new ItemStack(ChemiCraft.instance.itemAtoms,stacks[i], results[i]);
182                 }
183                 TileEntityPyrolysisTable.addRecipe(material, itemstacks);
184         }
185
186
187
188         /**
189          * 分解台の燃料を追加します
190          * @param itemstack 燃料のItemStack
191          * @param burnTime 燃焼時間(tick * rate)
192          */
193         public void addDecompositionFuel(ItemStack itemstack, int burnTime) {
194                 TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
195         }
196
197
198
199         /**
200          * ツール&武器作成台のレシピを追加します
201          * @param materials 素材
202          * @param result 結果
203          */
204         public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
205                 toolAndWeaponMaterials.add(materials);
206                 toolAndWeaponResult.add(result);
207                 toolAndWeaponSharpless.add(false);
208         }
209
210
211         /**
212          * ツール&武器作成台の不定形レシピを追加します
213          * @param materials 素材
214          * @param result 結果
215          */
216         public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
217                 toolAndWeaponMaterials.add(materials);
218                 toolAndWeaponResult.add(result);
219                 toolAndWeaponSharpless.add(true);
220         }
221
222
223
224         /**
225          * 素材作成台の不定形レシピを追加します
226          * @param materials 素材
227          * @param result 結果
228          * @param nbtRecipe NBT(Nullの場合はなし)
229          */
230         public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
231                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
232         }
233
234
235
236         /**
237          * 素材作成台のレシピを追加します
238          * @param materials 素材
239          * @param result 結果
240          * @param nbtRecipe NBT(Nullの場合はなし)
241          */
242         public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
243                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
244         }
245         //以下システム関連//////////////////////////////////////////////////////
246
247         public ArrayList<ICompoundHandler> getCompoundHandler(){
248                 compoundHandlers.trimToSize();
249                 return compoundHandlers;
250
251         }
252
253
254
255         public ArrayList<String> getCompoundHandlerItemName(){
256                 compoundHandlerItemNames.trimToSize();
257                 return compoundHandlerItemNames;
258         }
259
260
261
262         public ArrayList<String> getCompoundsName(){
263                 compoundsNameList.trimToSize();
264                 return compoundsNameList;
265         }
266
267
268
269         public ArrayList<String> getCompoundsLangName(){
270                 compoundsLangNameList.trimToSize();
271                 return compoundsLangNameList;
272         }
273
274
275
276         public ArrayList<String> getCompoundsLang(){
277                 compoundsLangList.trimToSize();
278                 return compoundsLangList;
279         }
280
281
282
283         public ArrayList<String[]> getChemicalCombinationAtoms(){
284                 return chemicalCombinationAtoms;
285         }
286
287
288
289         public ArrayList<Integer[]> getChemicalCombinationAmounts(){
290                 return chemicalCombinationAmounts;
291         }
292
293
294
295         public ArrayList<ItemStack> getChemicalCombinationResult(){
296                 return chemicalCombinationResult;
297         }
298
299
300
301         public ArrayList<MaterialRecipe> getMaterialRecipe(){
302                 return materialRecipe;
303         }
304
305
306
307         public ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
308                 return toolAndWeaponMaterials;
309         }
310
311
312
313         public ArrayList<ItemStack> getToolAndWeaponResult() {
314                 return toolAndWeaponResult;
315         }
316
317
318
319         public ArrayList<Boolean> getToolAndWeaponSharpless() {
320                 return toolAndWeaponSharpless;
321         }
322
323
324
325         public ChemiCraftCraftingManager getCraftingManager(){
326                 return chemiCraftCraftingManager;
327         }
328
329
330
331         public static ChemiCraftAPI getInstance(){
332                 return instance;
333         }
334
335 }