3 import java.util.ArrayList;
4 import java.util.HashMap;
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;
15 * 基本的にAddonはこのクラスのインスタンスを使う
19 public class ChemiCraftAPI {
22 * Instance of the ChemiCraftAPI.
24 private static ChemiCraftAPI instance = new ChemiCraftAPI();
28 * List of compounds names.
30 private ArrayList<String> compoundsNameList = new ArrayList<String>();
34 * List of compounds names(Some kind of language).
36 private ArrayList<String> compoundsLangNameList = new ArrayList<String>();
40 * List of compounds the language names.
42 private ArrayList<String> compoundsLangList = new ArrayList<String>();
46 * List of compounds handlers.
48 private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
52 * 化合物の文字列をダメージ値に変換します。
54 private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
58 * List of item name of handler to compounds.
60 private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
66 private ArrayList<ItemStack> decompositionMaterial = new ArrayList<ItemStack>();
72 private ArrayList<ItemStack[]> decompositionResults = new ArrayList<ItemStack[]>();
78 private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
84 private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
90 private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
96 private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
100 * ChemiCraftの化学作業台類のレシピのマネージャー
102 private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
108 * @param name compound name.
110 public void addCompound(String name){
111 addLangCompound("", name, "");
117 * add compound corresponding to the language.
118 * @param lang Language to the corresponding
119 * @param englishName compound name
120 * @param langName compound name(specified language)
122 public void addLangCompound(String lang, String englishName, String langName){
123 compoundsNameList.add(englishName);
124 compoundsLangNameList.add(langName);
125 compoundsLangList.add(lang);
126 compoundHash.put(englishName, compoundHash.size());
131 public int getCompound(String key){
132 if(compoundHash.get(key) != null){
133 return compoundHash.get(key);
142 * setting compound handler.
143 * @param handlerItemName
144 * @param compoundHandler
146 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
147 compoundHandlers.add(compoundHandler);
148 compoundHandlerItemNames.add(handlerItemName);
154 * 分解レシピを追加します。resultの要素数は0<= n <= 16にしてください。
158 public void addDecompositionRecipe(ItemStack material, ItemStack[] result){
159 if(result.length <= 16){
160 decompositionMaterial.add(material);
161 decompositionResults.add(result);
163 System.err.println("ChemiCraft内でエラー:addDecompositionRecipeの引数resultの要素数が16を超えています。" + "Material:" + material + " Result:" + result);
170 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
174 public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
175 chemicalCombinationAtoms.add(atoms);
176 chemicalCombinationAmounts.add(amounts);
177 chemicalCombinationResult.add(result);
182 public void addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
183 ItemStack[] itemstacks = new ItemStack[results.length];
184 for (int i = 0; i < itemstacks.length; i++) {
185 itemstacks[i] = new ItemStack(ChemiCraft.instance.atomsID,stacks[i], results[i]);
187 TileEntityPyrolysisTable.addRecipe(material, itemstacks);
192 public void addDecompositionRecipe(ItemStack itemstack, int burnTime) {
193 TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
198 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
199 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
204 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
205 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
207 //以下システム関連//////////////////////////////////////////////////////
209 public ArrayList<ICompoundHandler> getCompoundHandler(){
210 compoundHandlers.trimToSize();
211 return compoundHandlers;
217 public ArrayList<String> getCompoundHandlerItemName(){
218 compoundHandlerItemNames.trimToSize();
219 return compoundHandlerItemNames;
224 public ArrayList<String> getCompoundsName(){
225 compoundsNameList.trimToSize();
226 return compoundsNameList;
231 public ArrayList<String> getCompoundsLangName(){
232 compoundsLangNameList.trimToSize();
233 return compoundsLangNameList;
238 public ArrayList<String> getCompoundsLang(){
239 compoundsLangList.trimToSize();
240 return compoundsLangList;
245 public ArrayList<ItemStack> getDecompositionMaterial(){
246 return decompositionMaterial;
251 public ArrayList<ItemStack[]> getDecompositionResult(){
252 return decompositionResults;
257 public ArrayList<String[]> getChemicalCombinationAtoms(){
258 return chemicalCombinationAtoms;
263 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
264 return chemicalCombinationAmounts;
269 public ArrayList<ItemStack> getChemicalCombinationResult(){
270 return chemicalCombinationResult;
275 public ArrayList<MaterialRecipe> getMaterialRecipe(){
276 return materialRecipe;
281 public ChemiCraftCraftingManager getCraftingManager(){
282 return chemiCraftCraftingManager;
287 public static ChemiCraftAPI getInstance(){