OSDN Git Service

競合修正
[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.tileentity.TileEntityPyrolysisTable;
9 import chemicraft.util.ChemicalNBTRecipe;
10 import chemicraft.util.ICompoundHandler;
11 import 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          * add compound.
96          * @param name compound name.
97          */
98         public void addCompound(String name){
99                 addLangCompound("", name, "");
100         }
101
102
103
104         /**
105          * add compound corresponding to the language.
106          * @param lang Language to the corresponding
107          * @param englishName compound name
108          * @param langName compound name(specified language)
109          */
110         public void addLangCompound(String lang, String englishName, String langName){
111                 compoundsNameList.add(englishName);
112                 compoundsLangNameList.add(langName);
113                 compoundsLangList.add(lang);
114                 compoundHash.put(englishName, compoundHash.size());
115         }
116
117
118
119         public int getCompound(String key){
120                 if(compoundHash.get(key) != null){
121                         return compoundHash.get(key);
122                 } else {
123                         return -1;
124                 }
125         }
126
127
128
129         /**
130          * setting compound handler.
131          * @param handlerItemName
132          * @param compoundHandler
133          */
134         public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
135                 compoundHandlers.add(compoundHandler);
136                 compoundHandlerItemNames.add(handlerItemName);
137         }
138
139
140
141         /**
142          * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
143          * @param material 素材
144          * @param result 結果
145          */
146         public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
147                 chemicalCombinationAtoms.add(atoms);
148                 chemicalCombinationAmounts.add(amounts);
149                 chemicalCombinationResult.add(result);
150         }
151
152
153
154         public void addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
155                 ItemStack[] itemstacks = new ItemStack[results.length];
156                 for (int i = 0; i < itemstacks.length; i++) {
157                         itemstacks[i] = new ItemStack(ChemiCraft.instance.itemAtoms,stacks[i], results[i]);
158                 }
159                 TileEntityPyrolysisTable.addRecipe(material, itemstacks);
160         }
161
162
163
164         public void addDecompositionFuel(ItemStack itemstack, int burnTime) {
165                 TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
166         }
167
168
169
170         public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
171                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
172         }
173
174
175
176         public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
177                 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
178         }
179         //以下システム関連//////////////////////////////////////////////////////
180
181         public ArrayList<ICompoundHandler> getCompoundHandler(){
182                 compoundHandlers.trimToSize();
183                 return compoundHandlers;
184
185         }
186
187
188
189         public ArrayList<String> getCompoundHandlerItemName(){
190                 compoundHandlerItemNames.trimToSize();
191                 return compoundHandlerItemNames;
192         }
193
194
195
196         public ArrayList<String> getCompoundsName(){
197                 compoundsNameList.trimToSize();
198                 return compoundsNameList;
199         }
200
201
202
203         public ArrayList<String> getCompoundsLangName(){
204                 compoundsLangNameList.trimToSize();
205                 return compoundsLangNameList;
206         }
207
208
209
210         public ArrayList<String> getCompoundsLang(){
211                 compoundsLangList.trimToSize();
212                 return compoundsLangList;
213         }
214
215
216
217         public ArrayList<String[]> getChemicalCombinationAtoms(){
218                 return chemicalCombinationAtoms;
219         }
220
221
222
223         public ArrayList<Integer[]> getChemicalCombinationAmounts(){
224                 return chemicalCombinationAmounts;
225         }
226
227
228
229         public ArrayList<ItemStack> getChemicalCombinationResult(){
230                 return chemicalCombinationResult;
231         }
232
233
234
235         public ArrayList<MaterialRecipe> getMaterialRecipe(){
236                 return materialRecipe;
237         }
238
239
240
241         public ChemiCraftCraftingManager getCraftingManager(){
242                 return chemiCraftCraftingManager;
243         }
244
245
246
247         public static ChemiCraftAPI getInstance(){
248                 return instance;
249         }
250
251 }