OSDN Git Service

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