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(){
40 private ListHash<String, String> chemicalCellsLangListHash = new ListHash<String, String>();
46 private HashMap<ItemStack, Integer> chemicalCellsList = new HashMap<ItemStack, Integer>();
52 private ListHash<String, String> chemicalCellsNameListHash = new ListHash<String, String>();
58 private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
65 private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
71 private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
75 * ChemiCraftの化学作業台類のレシピのマネージャー
77 private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
81 * List of item name of handler to compounds.
83 private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
88 * List of compounds handlers.
90 private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
95 * 化合物の文字列をダメージ値に変換します。
97 private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
101 * List of compounds the language names.
103 private ListHash<String, String> compoundsLangListHash = new ListHash<String, String>();
107 * List of compounds names.
109 private ListHash<String, String> compoundsNameListHash = new ListHash<String, String>();
115 private HashMap<ItemStack, ItemStack[]> electrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
121 private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
127 private HashMap<ItemStack, Integer> pyrolysisFuelList = new HashMap<ItemStack, Integer>();
133 private HashMap<ItemStack, ItemStack[]> pyrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
139 private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
145 private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
152 private ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
159 public void addChemicalCell(Item par1ChemicalCell, String par2Name, int par3OperationTime){
160 chemicalCellsList.put(
164 chemicalCellsNameListHash.sizeKeysList()),
166 addChemicalCellLanguage(
174 * 既に登録した電池の新しい名前・言語を追加します
175 * @param par1Name 英語名
176 * @param par2NewName 新しい名前
177 * @param par3Language 言語
179 public void addChemicalCellLanguage(String par1Name, String par3NewLanguage, String par2NewName){
180 chemicalCellsNameListHash.add(par1Name, par2NewName);
181 chemicalCellsLangListHash.add(par1Name, par3NewLanguage);
187 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
191 public void addChemicalCombinationRecipe(ItemStack result, Formula formula){
192 chemicalCombinationAtoms.add(formula.getAtoms());
193 chemicalCombinationAmounts.add(formula.getAmonts());
194 chemicalCombinationResult.add(result);
201 * @param name compound name.
203 public void addCompound(String name){
204 compoundsNameListHash.add(name, name);
205 compoundsLangListHash.add(name, "en_US");
206 compoundHash.put(name, compoundHash.size());
211 * add compound corresponding to the language.
212 * @param lang Language to the corresponding
213 * @param englishName compound name
214 * @param langName compound name(specified language)
216 public void addCompound(String lang, String englishName, String langName){
217 addCompound(englishName);
218 addCompoundLanguage(lang, englishName, langName);
223 public void addCompoundLanguage(String lang, String englishName, String langName){
224 compoundsNameListHash.add(
227 compoundsLangListHash.add(
234 public void addElectrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
235 for (ItemStack item : material)
238 addElectrolysisDecompositionRecipe(item, formula);
245 public void addElectrolysisDecompositionRecipe(ItemStack material, Formula formula) {
246 ItemStack[] itemstacks =
247 new ItemStack[formula.getAtoms().length];
248 for (int i = 0; i < itemstacks.length; i++) {
251 ChemiCraftCore.instance.itemAtoms,
252 ChemiCraftData.toAtoms(formula.getAtoms()[i]),
253 formula.getAmonts()[i]);
255 this.electrolysisRecipeList.put(
264 * @param materials 素材
266 * @param nbtRecipe NBT(Nullの場合はなし)
268 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
281 * @param itemstack 燃料のItemStack
282 * @param burnTime 燃焼時間(tick * rate)
284 public void addPyrolysisDecompositionFuel(ItemStack itemstack, int burnTime) {
285 this.pyrolysisFuelList.put(
292 public void addPyrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
293 for (ItemStack item : material)
296 addPyrolysisDecompositionRecipe(item, formula);
307 * @param integers 原子の元素番号の配列
308 * @param integers2 原子のできる数の配列
310 public void addPyrolysisDecompositionRecipe(ItemStack material, Formula formula) {
311 ItemStack[] itemstacks =
312 new ItemStack[formula.getAtoms().length];
313 for (int i = 0; i < itemstacks.length; i++) {
316 ChemiCraftCore.instance.itemAtoms,
317 ChemiCraftData.toAtoms(formula.getAtoms()[i]),
318 formula.getAmonts()[i]);
320 this.pyrolysisRecipeList.put(
327 public void addReversible(ItemStack result, Formula formula){
328 addChemicalCombinationRecipe(result, formula);
329 addPyrolysisDecompositionRecipe(result, formula);
330 addElectrolysisDecompositionRecipe(result, formula);
334 public void addReversibleOfElectrolysis(ItemStack result, Formula formula){
335 addChemicalCombinationRecipe(result, formula);
336 addElectrolysisDecompositionRecipe(result, formula);
341 public void addReversibleOfPyrolysis(ItemStack result, Formula formula){
342 addChemicalCombinationRecipe(result, formula);
343 addPyrolysisDecompositionRecipe(result, formula);
350 * @param materials 素材
352 * @param nbtRecipe NBT(Nullの場合はなし)
354 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
366 * ツール&武器作成台の不定形レシピを追加します
367 * @param materials 素材
370 public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
371 toolAndWeaponMaterials.add(materials);
372 toolAndWeaponResult.add(result);
373 toolAndWeaponSharpless.add(true);
379 * ツール&武器作成台のレシピを追加します
380 * @param materials 素材
383 public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
384 toolAndWeaponMaterials.add(materials);
385 toolAndWeaponResult.add(result);
386 toolAndWeaponSharpless.add(false);
391 public ListHash<String, String> getChemicalCellsLanguage(){
392 return chemicalCellsLangListHash;
397 public HashMap<ItemStack, Integer> getChemicalCellsList(){
398 return chemicalCellsList;
402 public ListHash<String, String> getChemicalCellsName(){
403 return chemicalCellsNameListHash;
407 //以下システム関連//////////////////////////////////////////////////////
409 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
410 return chemicalCombinationAmounts;
415 public ArrayList<String[]> getChemicalCombinationAtoms(){
416 return chemicalCombinationAtoms;
421 public ArrayList<ItemStack> getChemicalCombinationResult(){
422 return chemicalCombinationResult;
427 public int getCompound(String key){
428 if(compoundHash.get(key) != null){
429 return compoundHash.get(key);
437 public ArrayList<ICompoundHandler> getCompoundHandler(){
438 compoundHandlers.trimToSize();
439 return compoundHandlers;
445 public ArrayList<String> getCompoundHandlerItemName(){
446 compoundHandlerItemNames.trimToSize();
447 return compoundHandlerItemNames;
452 public ListHash<String, String> getCompoundsLang(){
453 return compoundsLangListHash;
458 public ListHash<String, String> getCompoundsName(){
459 return compoundsNameListHash;
464 public ChemiCraftCraftingManager getCraftingManager(){
465 return chemiCraftCraftingManager;
470 public HashMap<ItemStack, ItemStack[]> getElectrolysisRecipeList()
472 return electrolysisRecipeList;
477 public ArrayList<MaterialRecipe> getMaterialRecipe(){
478 return materialRecipe;
483 public HashMap<ItemStack, Integer> getPyrolysisFuelList()
485 return pyrolysisFuelList;
490 public HashMap<ItemStack, ItemStack[]> getPyrolysisRecipeList()
492 return pyrolysisRecipeList;
497 public ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
498 return toolAndWeaponMaterials;
503 public ArrayList<ItemStack> getToolAndWeaponResult() {
504 return toolAndWeaponResult;
509 public ArrayList<Boolean> getToolAndWeaponSharpless() {
510 return toolAndWeaponSharpless;
516 * setting compound handler.
517 * @param handlerItemName
518 * @param compoundHandler
520 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
521 compoundHandlers.add(compoundHandler);
522 compoundHandlerItemNames.add(handlerItemName);