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))){
142 public void addCompoundHash(String key, int value){
143 compoundHash.put(key, value);
148 public void addCompoundHash(Object[] object){
149 for(int i = 0;i < compoundsNameList.size();i++){
150 if(object[i].equals(compoundsNameList.get(i))){
151 compoundHash.put((String) object[i], i);
158 public int getCompound(String key){
159 if(compoundHash.get(key) != null){
160 return compoundHash.get(key);
169 * setting compound handler.
170 * @param handlerItemName
171 * @param compoundHandler
173 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
174 compoundHandlers.add(compoundHandler);
175 compoundHandlerItemNames.add(handlerItemName);
181 * 分解レシピを追加します。resultの要素数は0<= n <= 16にしてください。
185 public void addDecompositionRecipe(ItemStack material, ItemStack[] result){
186 if(result.length <= 16){
187 decompositionMaterial.add(material);
188 decompositionResults.add(result);
190 System.err.println("ChemiCraft内でエラー:addDecompositionRecipeの引数resultの要素数が16を超えています。" + "Material:" + material + " Result:" + result);
197 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
201 public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
202 chemicalCombinationAtoms.add(atoms);
203 chemicalCombinationAmounts.add(amounts);
204 chemicalCombinationResult.add(result);
209 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
210 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
213 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
214 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
216 //以下システム関連//////////////////////////////////////////////////////
218 public ArrayList<ICompoundHandler> getCompoundHandler(){
219 compoundHandlers.trimToSize();
220 return compoundHandlers;
226 public ArrayList<String> getCompoundHandlerItemName(){
227 compoundHandlerItemNames.trimToSize();
228 return compoundHandlerItemNames;
233 public ArrayList<String> getCompoundsName(){
234 compoundsNameList.trimToSize();
235 return compoundsNameList;
240 public ArrayList<String> getCompoundsLangName(){
241 compoundsLangNameList.trimToSize();
242 return compoundsLangNameList;
247 public ArrayList<String> getCompoundsLang(){
248 compoundsLangList.trimToSize();
249 return compoundsLangList;
254 public ArrayList<ItemStack> getDecompositionMaterial(){
255 return decompositionMaterial;
260 public ArrayList<ItemStack[]> getDecompositionResult(){
261 return decompositionResults;
266 public ArrayList<String[]> getChemicalCombinationAtoms(){
267 return chemicalCombinationAtoms;
272 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
273 return chemicalCombinationAmounts;
278 public ArrayList<ItemStack> getChemicalCombinationResult(){
279 return chemicalCombinationResult;
284 public ArrayList<MaterialRecipe> getMaterialRecipe(){
285 return materialRecipe;
290 public ChemiCraftCraftingManager getCraftingManager(){
291 return chemiCraftCraftingManager;
296 public static ChemiCraftAPI getInstance(){