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<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
72 private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
78 private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
84 private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
88 * ChemiCraftの化学作業台類のレシピのマネージャー
90 private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
96 * @param name compound name.
98 public void addCompound(String name){
99 addLangCompound("", name, "");
105 * add compound corresponding to the language.
106 * @param lang Language to the corresponding
107 * @param englishName compound name
108 * @param langName compound name(specified language)
110 public void addLangCompound(String lang, String englishName, String langName){
111 compoundsNameList.add(englishName);
112 compoundsLangNameList.add(langName);
113 compoundsLangList.add(lang);
114 compoundHash.put(englishName, compoundHash.size());
119 public int getCompound(String key){
120 if(compoundHash.get(key) != null){
121 return compoundHash.get(key);
130 * setting compound handler.
131 * @param handlerItemName
132 * @param compoundHandler
134 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
135 compoundHandlers.add(compoundHandler);
136 compoundHandlerItemNames.add(handlerItemName);
142 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
146 public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
147 chemicalCombinationAtoms.add(atoms);
148 chemicalCombinationAmounts.add(amounts);
149 chemicalCombinationResult.add(result);
154 public void addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
155 ItemStack[] itemstacks = new ItemStack[results.length];
156 for (int i = 0; i < itemstacks.length; i++) {
157 itemstacks[i] = new ItemStack(ChemiCraft.instance.itemAtoms,stacks[i], results[i]);
159 TileEntityPyrolysisTable.addRecipe(material, itemstacks);
164 public void addDecompositionFuel(ItemStack itemstack, int burnTime) {
165 TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
170 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
171 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
176 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
177 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
179 //以下システム関連//////////////////////////////////////////////////////
181 public ArrayList<ICompoundHandler> getCompoundHandler(){
182 compoundHandlers.trimToSize();
183 return compoundHandlers;
189 public ArrayList<String> getCompoundHandlerItemName(){
190 compoundHandlerItemNames.trimToSize();
191 return compoundHandlerItemNames;
196 public ArrayList<String> getCompoundsName(){
197 compoundsNameList.trimToSize();
198 return compoundsNameList;
203 public ArrayList<String> getCompoundsLangName(){
204 compoundsLangNameList.trimToSize();
205 return compoundsLangNameList;
210 public ArrayList<String> getCompoundsLang(){
211 compoundsLangList.trimToSize();
212 return compoundsLangList;
217 public ArrayList<String[]> getChemicalCombinationAtoms(){
218 return chemicalCombinationAtoms;
223 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
224 return chemicalCombinationAmounts;
229 public ArrayList<ItemStack> getChemicalCombinationResult(){
230 return chemicalCombinationResult;
235 public ArrayList<MaterialRecipe> getMaterialRecipe(){
236 return materialRecipe;
241 public ChemiCraftCraftingManager getCraftingManager(){
242 return chemiCraftCraftingManager;
247 public static ChemiCraftAPI getInstance(){