1 package pcc.chemicraft.core;
3 import java.util.ArrayList;
4 import java.util.HashMap;
6 import net.minecraft.item.Item;
7 import net.minecraft.item.ItemStack;
8 import pcc.chemicraft.ChemiCraftData;
9 import pcc.chemicraft.core.system.ChemiCraftCraftingManager;
10 import pcc.chemicraft.util.ChemicalNBTRecipe;
11 import pcc.chemicraft.util.Formula;
12 import pcc.chemicraft.util.ICompoundHandler;
13 import pcc.chemicraft.util.ListHash;
14 import pcc.chemicraft.util.MaterialRecipe;
19 * 基本的にAddonはこのクラスのインスタンスを使う
23 public class ChemiCraftAPI {
26 * Instance of the ChemiCraftAPI.
28 private static ChemiCraftAPI instance = new ChemiCraftAPI();
31 public static ChemiCraftAPI instance(){
39 private HashMap<ItemStack, Integer> chemicalCellsList = new HashMap<ItemStack, Integer>();
45 private ListHash<String, String> chemicalCellsNameListHash = new ListHash<String, String>();
51 private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
58 private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
64 private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
68 * ChemiCraftの化学作業台類のレシピのマネージャー
70 private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
74 * List of item name of handler to compounds.
76 private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
81 * List of compounds handlers.
83 private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
88 * 化合物の文字列をダメージ値に変換します。
90 private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
94 * List of compounds names.
96 private ListHash<String, String> compoundsNameListHash = new ListHash<String, String>();
102 private HashMap<ItemStack, ItemStack[]> electrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
108 private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
114 private HashMap<ItemStack, Integer> pyrolysisFuelList = new HashMap<ItemStack, Integer>();
120 private HashMap<ItemStack, ItemStack[]> pyrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
126 private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
132 private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
139 private ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
146 public void addChemicalCell(Item par1ChemicalCell, String par2Name, int par3OperationTime){
147 chemicalCellsList.put(
151 chemicalCellsNameListHash.sizeKeysList()),
153 addChemicalCellLanguage(
160 * 既に登録した電池の新しい名前・言語を追加します
161 * @param par1Name 英語名
162 * @param par2NewName 新しい名前
163 * @param par3Language 言語
165 public void addChemicalCellLanguage(String par1NewLanguage, String par2NewName){
166 chemicalCellsNameListHash.add(par1NewLanguage, par2NewName);
172 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
176 public void addChemicalCombinationRecipe(ItemStack result, Formula formula){
177 chemicalCombinationAtoms.add(formula.getAtoms());
178 chemicalCombinationAmounts.add(formula.getAmonts());
179 chemicalCombinationResult.add(result);
186 * @param name compound name.
188 public void addCompound(String name){
189 compoundsNameListHash.add("en_US", name);
190 compoundHash.put(name, compoundHash.size());
195 * add compound corresponding to the language.
196 * @param lang Language to the corresponding
197 * @param englishName compound name
198 * @param langName compound name(specified language)
200 public void addCompound(String lang, String englishName, String langName){
201 addCompound(englishName);
202 addCompoundLanguage(lang, langName);
207 public void addCompoundLanguage(String lang, String langName){
208 compoundsNameListHash.add(
215 public void addElectrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
216 for (ItemStack item : material)
219 addElectrolysisDecompositionRecipe(item, formula);
226 public void addElectrolysisDecompositionRecipe(ItemStack material, Formula formula) {
227 ItemStack[] itemstacks =
228 new ItemStack[formula.getAtoms().length];
229 for (int i = 0; i < itemstacks.length; i++) {
232 ChemiCraftCore.instance.itemAtoms,
233 formula.getAmonts()[i],
234 ChemiCraftData.toAtoms(formula.getAtoms()[i]));
236 this.electrolysisRecipeList.put(
245 * @param materials 素材
247 * @param nbtRecipe NBT(Nullの場合はなし)
249 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
262 * @param itemstack 燃料のItemStack
263 * @param burnTime 燃焼時間(tick * rate)
265 public void addPyrolysisDecompositionFuel(ItemStack itemstack, int burnTime) {
266 this.pyrolysisFuelList.put(
273 public void addPyrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
274 for (ItemStack item : material)
277 addPyrolysisDecompositionRecipe(item, formula);
288 * @param integers 原子の元素番号の配列
289 * @param integers2 原子のできる数の配列
291 public void addPyrolysisDecompositionRecipe(ItemStack material, Formula formula) {
292 ItemStack[] itemstacks =
293 new ItemStack[formula.getAtoms().length];
294 for (int i = 0; i < itemstacks.length; i++) {
297 ChemiCraftCore.instance.itemAtoms,
298 formula.getAmonts()[i],
299 ChemiCraftData.toAtoms(formula.getAtoms()[i]));
301 this.pyrolysisRecipeList.put(
308 public void addReversible(ItemStack result, Formula formula){
309 addChemicalCombinationRecipe(result, formula);
310 addPyrolysisDecompositionRecipe(result, formula);
311 addElectrolysisDecompositionRecipe(result, formula);
315 public void addReversibleOfElectrolysis(ItemStack result, Formula formula){
316 addChemicalCombinationRecipe(result, formula);
317 addElectrolysisDecompositionRecipe(result, formula);
322 public void addReversibleOfPyrolysis(ItemStack result, Formula formula){
323 addChemicalCombinationRecipe(result, formula);
324 addPyrolysisDecompositionRecipe(result, formula);
331 * @param materials 素材
333 * @param nbtRecipe NBT(Nullの場合はなし)
335 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
347 * ツール&武器作成台の不定形レシピを追加します
348 * @param materials 素材
351 public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
352 toolAndWeaponMaterials.add(materials);
353 toolAndWeaponResult.add(result);
354 toolAndWeaponSharpless.add(true);
360 * ツール&武器作成台のレシピを追加します
361 * @param materials 素材
364 public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
365 toolAndWeaponMaterials.add(materials);
366 toolAndWeaponResult.add(result);
367 toolAndWeaponSharpless.add(false);
372 public HashMap<ItemStack, Integer> getChemicalCellsList(){
373 return chemicalCellsList;
377 public ListHash<String, String> getChemicalCellsName(){
378 return chemicalCellsNameListHash;
382 //以下システム関連//////////////////////////////////////////////////////
384 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
385 return chemicalCombinationAmounts;
390 public ArrayList<String[]> getChemicalCombinationAtoms(){
391 return chemicalCombinationAtoms;
396 public ArrayList<ItemStack> getChemicalCombinationResult(){
397 return chemicalCombinationResult;
402 public int getCompound(String key){
403 if(compoundHash.get(key) != null){
404 return compoundHash.get(key);
412 public ArrayList<ICompoundHandler> getCompoundHandler(){
413 compoundHandlers.trimToSize();
414 return compoundHandlers;
420 public ArrayList<String> getCompoundHandlerItemName(){
421 compoundHandlerItemNames.trimToSize();
422 return compoundHandlerItemNames;
427 public ListHash<String, String> getCompoundsName(){
428 return compoundsNameListHash;
433 public ChemiCraftCraftingManager getCraftingManager(){
434 return chemiCraftCraftingManager;
439 public HashMap<ItemStack, ItemStack[]> getElectrolysisRecipeList()
441 return electrolysisRecipeList;
446 public ArrayList<MaterialRecipe> getMaterialRecipe(){
447 return materialRecipe;
452 public HashMap<ItemStack, Integer> getPyrolysisFuelList()
454 return pyrolysisFuelList;
459 public HashMap<ItemStack, ItemStack[]> getPyrolysisRecipeList()
461 return pyrolysisRecipeList;
466 public ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
467 return toolAndWeaponMaterials;
472 public ArrayList<ItemStack> getToolAndWeaponResult() {
473 return toolAndWeaponResult;
478 public ArrayList<Boolean> getToolAndWeaponSharpless() {
479 return toolAndWeaponSharpless;
485 * setting compound handler.
486 * @param handlerItemName
487 * @param compoundHandler
489 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
490 compoundHandlers.add(compoundHandler);
491 compoundHandlerItemNames.add(handlerItemName);