1 package pcc.chemicraft;
3 import java.util.ArrayList;
4 import java.util.HashMap;
6 import net.minecraft.item.ItemStack;
7 import pcc.chemicraft.system.ChemiCraftCraftingManager;
8 import pcc.chemicraft.tileentity.TileEntityPyrolysisTable;
9 import pcc.chemicraft.util.ChemicalNBTRecipe;
10 import pcc.chemicraft.util.ICompoundHandler;
11 import pcc.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 private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
102 private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
108 private ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
114 * @param name compound name.
116 public void addCompound(String name){
117 addLangCompound("", name, "");
123 * add compound corresponding to the language.
124 * @param lang Language to the corresponding
125 * @param englishName compound name
126 * @param langName compound name(specified language)
128 public void addLangCompound(String lang, String englishName, String langName){
129 compoundsNameList.add(englishName);
130 compoundsLangNameList.add(langName);
131 compoundsLangList.add(lang);
132 compoundHash.put(englishName, compoundHash.size());
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 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
164 public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
165 chemicalCombinationAtoms.add(atoms);
166 chemicalCombinationAmounts.add(amounts);
167 chemicalCombinationResult.add(result);
175 * @param results 原子の元素番号の配列
176 * @param stacks 原子のできる数の配列
178 public void addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
179 ItemStack[] itemstacks = new ItemStack[results.length];
180 for (int i = 0; i < itemstacks.length; i++) {
181 itemstacks[i] = new ItemStack(ChemiCraft.instance.itemAtoms,stacks[i], results[i]);
183 TileEntityPyrolysisTable.addRecipe(material, itemstacks);
190 * @param itemstack 燃料のItemStack
191 * @param burnTime 燃焼時間(tick * rate)
193 public void addDecompositionFuel(ItemStack itemstack, int burnTime) {
194 TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
200 * ツール&武器作成台のレシピを追加します
201 * @param materials 素材
204 public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
205 toolAndWeaponMaterials.add(materials);
206 toolAndWeaponResult.add(result);
207 toolAndWeaponSharpless.add(false);
212 * ツール&武器作成台の不定形レシピを追加します
213 * @param materials 素材
216 public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
217 toolAndWeaponMaterials.add(materials);
218 toolAndWeaponResult.add(result);
219 toolAndWeaponSharpless.add(true);
226 * @param materials 素材
228 * @param nbtRecipe NBT(Nullの場合はなし)
230 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
231 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
238 * @param materials 素材
240 * @param nbtRecipe NBT(Nullの場合はなし)
242 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
243 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
245 //以下システム関連//////////////////////////////////////////////////////
247 public ArrayList<ICompoundHandler> getCompoundHandler(){
248 compoundHandlers.trimToSize();
249 return compoundHandlers;
255 public ArrayList<String> getCompoundHandlerItemName(){
256 compoundHandlerItemNames.trimToSize();
257 return compoundHandlerItemNames;
262 public ArrayList<String> getCompoundsName(){
263 compoundsNameList.trimToSize();
264 return compoundsNameList;
269 public ArrayList<String> getCompoundsLangName(){
270 compoundsLangNameList.trimToSize();
271 return compoundsLangNameList;
276 public ArrayList<String> getCompoundsLang(){
277 compoundsLangList.trimToSize();
278 return compoundsLangList;
283 public ArrayList<String[]> getChemicalCombinationAtoms(){
284 return chemicalCombinationAtoms;
289 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
290 return chemicalCombinationAmounts;
295 public ArrayList<ItemStack> getChemicalCombinationResult(){
296 return chemicalCombinationResult;
301 public ArrayList<MaterialRecipe> getMaterialRecipe(){
302 return materialRecipe;
307 public ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
308 return toolAndWeaponMaterials;
313 public ArrayList<ItemStack> getToolAndWeaponResult() {
314 return toolAndWeaponResult;
319 public ArrayList<Boolean> getToolAndWeaponSharpless() {
320 return toolAndWeaponSharpless;
325 public ChemiCraftCraftingManager getCraftingManager(){
326 return chemiCraftCraftingManager;
331 public static ChemiCraftAPI getInstance(){