3 import java.util.ArrayList;
4 import java.util.HashMap;
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;
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 addLangCompound("", name, "");
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)
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());
130 public int getCompound(String key){
131 if(compoundHash.get(key) != null){
132 return compoundHash.get(key);
141 * setting compound handler.
142 * @param handlerItemName
143 * @param compoundHandler
145 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
146 compoundHandlers.add(compoundHandler);
147 compoundHandlerItemNames.add(handlerItemName);
153 * 分解レシピを追加します。resultの要素数は0<= n <= 16にしてください。
157 public void addDecompositionRecipe(ItemStack material, ItemStack[] result){
158 if(result.length <= 16){
159 decompositionMaterial.add(material);
160 decompositionResults.add(result);
162 System.err.println("ChemiCraft内でエラー:addDecompositionRecipeの引数resultの要素数が16を超えています。" + "Material:" + material + " Result:" + result);
169 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
173 public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
174 chemicalCombinationAtoms.add(atoms);
175 chemicalCombinationAmounts.add(amounts);
176 chemicalCombinationResult.add(result);
181 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
182 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
185 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
186 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
188 //以下システム関連//////////////////////////////////////////////////////
190 public ArrayList<ICompoundHandler> getCompoundHandler(){
191 compoundHandlers.trimToSize();
192 return compoundHandlers;
198 public ArrayList<String> getCompoundHandlerItemName(){
199 compoundHandlerItemNames.trimToSize();
200 return compoundHandlerItemNames;
205 public ArrayList<String> getCompoundsName(){
206 compoundsNameList.trimToSize();
207 return compoundsNameList;
212 public ArrayList<String> getCompoundsLangName(){
213 compoundsLangNameList.trimToSize();
214 return compoundsLangNameList;
219 public ArrayList<String> getCompoundsLang(){
220 compoundsLangList.trimToSize();
221 return compoundsLangList;
226 public ArrayList<ItemStack> getDecompositionMaterial(){
227 return decompositionMaterial;
232 public ArrayList<ItemStack[]> getDecompositionResult(){
233 return decompositionResults;
238 public ArrayList<String[]> getChemicalCombinationAtoms(){
239 return chemicalCombinationAtoms;
244 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
245 return chemicalCombinationAmounts;
250 public ArrayList<ItemStack> getChemicalCombinationResult(){
251 return chemicalCombinationResult;
256 public ArrayList<MaterialRecipe> getMaterialRecipe(){
257 return materialRecipe;
262 public ChemiCraftCraftingManager getCraftingManager(){
263 return chemiCraftCraftingManager;
268 public static ChemiCraftAPI getInstance(){