1 package pcc.chemicraft.core;
3 import java.util.ArrayList;
4 import java.util.Arrays;
5 import java.util.HashMap;
7 import net.minecraft.item.Item;
8 import net.minecraft.item.ItemStack;
9 import pcc.chemicraft.ChemiCraftData;
10 import pcc.chemicraft.core.system.ChemiCraftCraftingManager;
11 import pcc.chemicraft.util.ChemicalNBTRecipe;
12 import pcc.chemicraft.util.Formula;
13 import pcc.chemicraft.util.ICompoundHandler;
14 import pcc.chemicraft.util.ListHash;
15 import pcc.chemicraft.util.MaterialRecipe;
20 * 基本的にAddonはこのクラスのインスタンスを使う
24 public class ChemiCraftAPI {
27 * Instance of the ChemiCraftAPI.
29 private static ChemiCraftAPI instance = new ChemiCraftAPI();
32 public static ChemiCraftAPI instance(){
40 private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
47 private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
53 private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
57 * ChemiCraftの化学作業台類のレシピのマネージャー
59 private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
63 * List of item name of handler to compounds.
65 private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
70 * List of compounds handlers.
72 private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
77 * 化合物の文字列をダメージ値に変換します。
79 private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
83 * List of compounds names.
85 private ListHash<String, String> compoundsNameListHash = new ListHash<String, String>();
91 private HashMap<ItemStack, Integer> electrolysisFuelList = new HashMap<ItemStack, Integer>();
97 private HashMap<ItemStack, ItemStack[]> electrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
103 private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
109 private HashMap<ItemStack, Integer> pyrolysisFuelList = new HashMap<ItemStack, Integer>();
115 private HashMap<ItemStack, ItemStack[]> pyrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
121 private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
127 private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
134 private ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
139 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
143 public void addChemicalCombinationRecipe(ItemStack result, Formula formula){
144 chemicalCombinationAtoms.add(formula.getAtoms());
145 chemicalCombinationAmounts.add(formula.getAmonts());
146 chemicalCombinationResult.add(result);
153 * @param name compound name.
155 public void addCompound(String name){
156 compoundsNameListHash.add("en_US", name);
157 compoundHash.put(name, compoundHash.size());
162 * add compound corresponding to the language.
163 * @param lang Language to the corresponding
164 * @param englishName compound name
165 * @param langName compound name(specified language)
167 public void addCompound(String lang, String englishName, String langName){
168 addCompound(englishName);
169 addCompoundLanguage(lang, langName);
174 public void addCompoundLanguage(String lang, String langName){
175 compoundsNameListHash.add(
184 * @param itemstack 燃料のItemStack
185 * @param burnTime 燃焼時間(tick * rate)
187 public void addElectrolysisDecompositionFuel(ItemStack itemstack, int burnTime) {
188 this.electrolysisFuelList.put(
195 public void addElectrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
196 for (ItemStack item : material)
199 addElectrolysisDecompositionRecipe(item, formula);
206 public void addElectrolysisDecompositionRecipe(ItemStack material, Formula formula) {
207 ItemStack[] itemstacks =
208 new ItemStack[formula.getAtoms().length];
209 for (int i = 0; i < itemstacks.length; i++) {
212 ChemiCraftCore.instance.itemAtoms,
213 formula.getAmonts()[i],
214 ChemiCraftData.toAtoms(formula.getAtoms()[i]));
216 this.electrolysisRecipeList.put(
225 * @param materials 素材
227 * @param nbtRecipe NBT(Nullの場合はなし)
229 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
242 * @param materials 素材
244 * @param nbtRecipe NBT(Nullの場合はなし)
246 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
259 * @param itemstack 燃料のItemStack
260 * @param burnTime 燃焼時間(tick * rate)
262 public void addPyrolysisDecompositionFuel(ItemStack itemstack, int burnTime) {
263 this.pyrolysisFuelList.put(
270 public void addPyrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
271 for (ItemStack item : material)
274 addPyrolysisDecompositionRecipe(item, formula);
285 * @param integers 原子の元素番号の配列
286 * @param integers2 原子のできる数の配列
288 public void addPyrolysisDecompositionRecipe(ItemStack material, Formula formula) {
289 ItemStack[] itemstacks =
290 new ItemStack[formula.getAtoms().length];
291 for (int i = 0; i < itemstacks.length; i++) {
294 ChemiCraftCore.instance.itemAtoms,
295 formula.getAmonts()[i],
296 ChemiCraftData.toAtoms(formula.getAtoms()[i]));
298 this.pyrolysisRecipeList.put(
305 public void addReversible(ItemStack result, Formula formula){
306 addChemicalCombinationRecipe(result, formula);
307 addPyrolysisDecompositionRecipe(result, formula);
308 addElectrolysisDecompositionRecipe(result, formula);
312 public void addReversibleOfElectrolysis(ItemStack result, Formula formula){
313 addChemicalCombinationRecipe(result, formula);
314 addElectrolysisDecompositionRecipe(result, formula);
319 public void addReversibleOfPyrolysis(ItemStack result, Formula formula){
320 addChemicalCombinationRecipe(result, formula);
321 addPyrolysisDecompositionRecipe(result, formula);
327 * ツール&武器作成台の不定形レシピを追加します
328 * @param materials 素材
331 public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
332 toolAndWeaponMaterials.add(materials);
333 toolAndWeaponResult.add(result);
334 toolAndWeaponSharpless.add(true);
340 * ツール&武器作成台のレシピを追加します
341 * @param materials 素材
344 public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
345 toolAndWeaponMaterials.add(materials);
346 toolAndWeaponResult.add(result);
347 toolAndWeaponSharpless.add(false);
352 //以下システム関連//////////////////////////////////////////////////////
354 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
355 return chemicalCombinationAmounts;
360 public ArrayList<String[]> getChemicalCombinationAtoms(){
361 return chemicalCombinationAtoms;
366 public ArrayList<ItemStack> getChemicalCombinationResult(){
367 return chemicalCombinationResult;
372 public int getCompound(String key){
373 if(compoundHash.get(key) != null){
374 return compoundHash.get(key);
382 public ArrayList<ICompoundHandler> getCompoundHandler(){
383 compoundHandlers.trimToSize();
384 return compoundHandlers;
390 public ArrayList<String> getCompoundHandlerItemName(){
391 compoundHandlerItemNames.trimToSize();
392 return compoundHandlerItemNames;
397 public ListHash<String, String> getCompoundsName(){
398 return compoundsNameListHash;
403 public ChemiCraftCraftingManager getCraftingManager(){
404 return chemiCraftCraftingManager;
409 public HashMap<ItemStack, Integer> getElectrolysisFuelList()
411 return electrolysisFuelList;
416 public HashMap<ItemStack, ItemStack[]> getElectrolysisRecipeList()
418 return electrolysisRecipeList;
423 public ArrayList<MaterialRecipe> getMaterialRecipe(){
424 return materialRecipe;
429 public HashMap<ItemStack, Integer> getPyrolysisFuelList()
431 return pyrolysisFuelList;
436 public HashMap<ItemStack, ItemStack[]> getPyrolysisRecipeList()
438 return pyrolysisRecipeList;
443 public ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
444 return toolAndWeaponMaterials;
449 public ArrayList<ItemStack> getToolAndWeaponResult() {
450 return toolAndWeaponResult;
455 public ArrayList<Boolean> getToolAndWeaponSharpless() {
456 return toolAndWeaponSharpless;
462 * setting compound handler.
463 * @param handlerItemName
464 * @param compoundHandler
466 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
467 compoundHandlers.add(compoundHandler);
468 compoundHandlerItemNames.add(handlerItemName);