3 import java.util.ArrayList;
4 import java.util.HashMap;
6 import net.minecraft.src.ItemStack;
7 import chemicraft.system.ChemiCraftCraftingManager;
8 import chemicraft.util.ChemicalNBTRecipe;
9 import chemicraft.util.ICompoundHandler;
10 import chemicraft.util.MaterialRecipe;
14 * 基本的にAddonはこのクラスのインスタンスを使う
18 public class ChemiCraftAPI {
21 * Instance of the ChemiCraftAPI.
23 private static ChemiCraftAPI instance = new ChemiCraftAPI();
27 * List of compounds names.
29 private ArrayList<String> compoundsNameList = new ArrayList<String>();
33 * List of compounds names(Some kind of language).
35 private ArrayList<String> compoundsLangNameList = new ArrayList<String>();
39 * List of compounds the language names.
41 private ArrayList<String> compoundsLangList = new ArrayList<String>();
45 * List of compounds handlers.
47 private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
51 * 化合物の文字列をダメージ値に変換します。
53 private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
57 * List of item name of handler to compounds.
59 private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
65 private ArrayList<ItemStack> decompositionMaterial = new ArrayList<ItemStack>();
71 private ArrayList<ItemStack[]> decompositionResults = new ArrayList<ItemStack[]>();
77 private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
83 private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
89 private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
95 private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
99 * ChemiCraftの化学作業台類のレシピのマネージャー
101 private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
107 * @param name compound name.
109 public void addCompound(String name){
110 compoundsNameList.add(name);
111 compoundsLangNameList.add("");
112 compoundsLangList.add("");
118 * add compound corresponding to the language.
119 * @param lang Language to the corresponding
120 * @param englishName compound name
121 * @param langName compound name(specified language)
123 public void addLangCompound(String lang, String englishName, String langName){
124 compoundsNameList.add(englishName);
125 compoundsLangNameList.add(langName);
126 compoundsLangList.add(lang);
131 public int getDamageByName(String englishName){
132 for(int i = 0;i < compoundsNameList.size();i++){
133 if(englishName.equals(compoundsNameList.get(i))){
134 compoundHash.put(englishName, i);
143 public int getCompound(String key){
144 if(compoundHash.get(key) != null){
145 return compoundHash.get(key);
154 * setting compound handler.
155 * @param handlerItemName
156 * @param compoundHandler
158 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
159 compoundHandlers.add(compoundHandler);
160 compoundHandlerItemNames.add(handlerItemName);
166 * 分解レシピを追加します。resultの要素数は0<= n <= 16にしてください。
170 public void addDecompositionRecipe(ItemStack material, ItemStack[] result){
171 if(result.length <= 16){
172 decompositionMaterial.add(material);
173 decompositionResults.add(result);
175 System.err.println("ChemiCraft内でエラー:addDecompositionRecipeの引数resultの要素数が16を超えています。" + "Material:" + material + " Result:" + result);
182 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
186 public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
187 chemicalCombinationAtoms.add(atoms);
188 chemicalCombinationAmounts.add(amounts);
189 chemicalCombinationResult.add(result);
194 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
195 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
198 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
199 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
201 //以下システム関連//////////////////////////////////////////////////////
203 public ArrayList<ICompoundHandler> getCompoundHandler(){
204 compoundHandlers.trimToSize();
205 return compoundHandlers;
211 public ArrayList<String> getCompoundHandlerItemName(){
212 compoundHandlerItemNames.trimToSize();
213 return compoundHandlerItemNames;
218 public ArrayList<String> getCompoundsName(){
219 compoundsNameList.trimToSize();
220 return compoundsNameList;
225 public ArrayList<String> getCompoundsLangName(){
226 compoundsLangNameList.trimToSize();
227 return compoundsLangNameList;
232 public ArrayList<String> getCompoundsLang(){
233 compoundsLangList.trimToSize();
234 return compoundsLangList;
239 public ArrayList<ItemStack> getDecompositionMaterial(){
240 return decompositionMaterial;
245 public ArrayList<ItemStack[]> getDecompositionResult(){
246 return decompositionResults;
251 public ArrayList<String[]> getChemicalCombinationAtoms(){
252 return chemicalCombinationAtoms;
257 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
258 return chemicalCombinationAmounts;
263 public ArrayList<ItemStack> getChemicalCombinationResult(){
264 return chemicalCombinationResult;
269 public ArrayList<MaterialRecipe> getMaterialRecipe(){
270 return materialRecipe;
275 public ChemiCraftCraftingManager getCraftingManager(){
276 return chemiCraftCraftingManager;
281 public static ChemiCraftAPI getInstance(){