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 public static final 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<ItemStack[]> chemicalCombinationMaterials = new ArrayList<ItemStack[]>();
83 private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
89 private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
93 * ChemiCraftの化学作業台類のレシピのマネージャー
95 private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
101 * @param name compound name.
103 public void addCompound(String name){
104 compoundsNameList.add(name);
105 compoundsLangNameList.add("");
106 compoundsLangList.add("");
112 * add compound corresponding to the language.
113 * @param lang Language to the corresponding
114 * @param englishName compound name
115 * @param langName compound name(specified language)
117 public void addLangCompound(String lang, String englishName, String langName){
118 compoundsNameList.add(englishName);
119 compoundsLangNameList.add(langName);
120 compoundsLangList.add(lang);
125 public int getDamageByName(String englishName){
126 for(int i = 0;i < compoundsNameList.size();i++){
127 if(englishName.equals(compoundsNameList.get(i))){
128 compoundHash.put(englishName, i);
137 public int getCompound(String key){
138 if(compoundHash.get(key) != null){
139 return compoundHash.get(key);
148 * setting compound handler.
149 * @param handlerItemName
150 * @param compoundHandler
152 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
153 compoundHandlers.add(compoundHandler);
154 compoundHandlerItemNames.add(handlerItemName);
160 * 分解レシピを追加します。resultの要素数は0<= n <= 16にしてください。
164 public void addDecompositionRecipe(ItemStack material, ItemStack[] result){
165 if(result.length <= 16){
166 decompositionMaterial.add(material);
167 decompositionResults.add(result);
169 System.err.println("ChemiCraft内でエラー:addDecompositionRecipeの引数resultの要素数が16を超えています。" + "Material:" + material + " Result:" + result);
176 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
180 public void addChemicalCombinationRecipe(ItemStack[] material, ItemStack result){
181 if(material.length <= 16){
182 chemicalCombinationMaterials.add(material);
183 chemicalCombinationResult.add(result);
185 System.err.println("ChemiCraft内でエラー:addChemicalCombinationRecipeの引数materialの要素数が16を超えています。" + "Material:" + material + " Result:" + result);
191 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
192 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
195 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
196 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
198 //以下システム関連//////////////////////////////////////////////////////
200 public ArrayList<ICompoundHandler> getCompoundHandler(){
201 compoundHandlers.trimToSize();
202 return compoundHandlers;
208 public ArrayList<String> getCompoundHandlerItemName(){
209 compoundHandlerItemNames.trimToSize();
210 return compoundHandlerItemNames;
215 public ArrayList<String> getCompoundsName(){
216 compoundsNameList.trimToSize();
217 return compoundsNameList;
222 public ArrayList<String> getCompoundsLangName(){
223 compoundsLangNameList.trimToSize();
224 return compoundsLangNameList;
229 public ArrayList<String> getCompoundsLang(){
230 compoundsLangList.trimToSize();
231 return compoundsLangList;
236 public ArrayList<ItemStack> getDecompositionMaterial(){
237 return decompositionMaterial;
242 public ArrayList<ItemStack[]> getDecompositionResult(){
243 return decompositionResults;
248 public ArrayList<ItemStack[]> getChemicalCombinationMaterial(){
249 return chemicalCombinationMaterials;
254 public ArrayList<ItemStack> getChemicalCombinationResult(){
255 return chemicalCombinationResult;
258 public ArrayList<MaterialRecipe> getMaterialRecipe(){
259 return materialRecipe;
262 public ChemiCraftCraftingManager getCraftingManager(){
263 return chemiCraftCraftingManager;