import java.util.Arrays;
import java.util.HashMap;
-import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import pcc.chemicraft.ChemiCraftData;
+import pcc.chemicraft.EnumLoggingType;
+import pcc.chemicraft.core.nbt.ChemicalNBTRecipe;
import pcc.chemicraft.core.system.ChemiCraftCraftingManager;
-import pcc.chemicraft.util.ChemicalNBTRecipe;
import pcc.chemicraft.util.Formula;
import pcc.chemicraft.util.ICompoundHandler;
import pcc.chemicraft.util.ListHash;
/**
- * ChemiCraftのAPI
- * 基本的にAddonはこのクラスのインスタンスを使う
+ * ChemiCraftのAPIを提供するクラスです<br>
+ * ChemiCraftのAPIを作成する場合はこのクラスを使用します<br>
* @author mozipi
*
*/
public class ChemiCraftAPI {
/**
- * Instance of the ChemiCraftAPI.
+ * APIのインスタンス
*/
private static ChemiCraftAPI instance = new ChemiCraftAPI();
+ /**
+ * APIのインスタンスを返します
+ * @return APIのインスタンス
+ */
public static ChemiCraftAPI instance(){
return instance;
}
/**
- * 電池
- */
- private HashMap<ItemStack, Integer> chemicalCellsList = new HashMap<ItemStack, Integer>();
-
-
- /**
- * 電池名リスト
- */
- private ListHash<String, String> chemicalCellsNameListHash = new ListHash<String, String>();
-
-
- /**
* 化合台の原子の数のリスト
*/
- private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
-
+ private static ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
/**
* 化合台の原子の種類のリスト
*/
- private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
+ private static ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
/**
* 化合台の結果のリスト
*/
- private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
+ private static ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
/**
* ChemiCraftの化学作業台類のレシピのマネージャー
*/
- private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
+ private static ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
/**
* List of item name of handler to compounds.
*/
- private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
-
+ private static ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
/**
* List of compounds handlers.
*/
- private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
-
+ private static ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
/**
* 化合物の文字列をダメージ値に変換します。
*/
- private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
+ private static HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
/**
* List of compounds names.
*/
- private ListHash<String, String> compoundsNameListHash = new ListHash<String, String>();
+ private static ListHash<String, String> compoundsNameListHash = new ListHash<String, String>();
+
+
+ /**
+ * 電気分解燃料のリスト。
+ */
+ private static HashMap<ItemStack, Integer> electrolysisFuelList = new HashMap<ItemStack, Integer>();
/**
* 電気分解レシピのリスト
*/
- private HashMap<ItemStack, ItemStack[]> electrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
+ private static HashMap<ItemStack, ItemStack[]> electrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
/**
* 素材製作台のレシピクラス
*/
- private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
+ private static ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
/**
* 熱分解燃料のリスト。
*/
- private HashMap<ItemStack, Integer> pyrolysisFuelList = new HashMap<ItemStack, Integer>();
+ private static HashMap<ItemStack, Integer> pyrolysisFuelList = new HashMap<ItemStack, Integer>();
/**
* 熱分解レシピのリスト
*/
- private HashMap<ItemStack, ItemStack[]> pyrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
+ private static HashMap<ItemStack, ItemStack[]> pyrolysisRecipeList = new HashMap<ItemStack, ItemStack[]>();
/**
* ツール&武器作成台の素材一覧のリスト
*/
- private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
+ private static ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
/**
* ツール&武器作成台の結果のリスト
*/
- private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
-
+ private static ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
/**
* ツール&武器作成台の不定形であるか
*/
- private ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
-
-
- /**
- * 電池を追加します
- * @param par1Name
- */
- public void addChemicalCell(Item par1ChemicalCell, String par2Name, int par3OperationTime){
- chemicalCellsList.put(
- new ItemStack(
- par1ChemicalCell,
- 1,
- chemicalCellsNameListHash.sizeKeysList()),
- par3OperationTime);
- addChemicalCellLanguage(
- "en_US",
- par2Name);
- }
-
-
- /**
- * 既に登録した電池の新しい名前・言語を追加します
- * @param par1Name 英語名
- * @param par2NewName 新しい名前
- * @param par3Language 言語
- */
- public void addChemicalCellLanguage(String par1NewLanguage, String par2NewName){
- chemicalCellsNameListHash.add(par1NewLanguage, par2NewName);
- }
+ private static ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
* @param material 素材
* @param result 結果
*/
- public void addChemicalCombinationRecipe(ItemStack result, Formula formula){
+ public static void addChemicalCombinationRecipe(ItemStack result, Formula formula){
+ ChemiCraftCore.logger.write("addChemicalCombinationRecipe:" + "Result-" + result.getItemName() + "/Material-" + Arrays.toString(formula.getAtoms())
+ , EnumLoggingType.INFO);
chemicalCombinationAtoms.add(formula.getAtoms());
chemicalCombinationAmounts.add(formula.getAmonts());
chemicalCombinationResult.add(result);
/**
- * add compound.
- * @param name compound name.
+ * 化合物を追加します
+ * @param name 化合物の名前
*/
- public void addCompound(String name){
+ public static void addCompound(String name){
+ ChemiCraftCore.logger.write("addCompound:" + name
+ , EnumLoggingType.INFO);
compoundsNameListHash.add("en_US", name);
compoundHash.put(name, compoundHash.size());
}
/**
- * add compound corresponding to the language.
- * @param lang Language to the corresponding
- * @param englishName compound name
- * @param langName compound name(specified language)
+ * 既に登録された化合物に対して別の言語をを追加します
+ * @param lang 別言語名
+ * @param englishName 英語名
+ * @param langName 別言語への名前
*/
- public void addCompound(String lang, String englishName, String langName){
+ public static void addCompound(String lang, String englishName, String langName){
+ ChemiCraftCore.logger.write("addCompound(MultiLang):" + "lang-" + lang + "/name-" + englishName + "/langToName-" + langName
+ , EnumLoggingType.INFO);
addCompound(englishName);
addCompoundLanguage(lang, langName);
}
- public void addCompoundLanguage(String lang, String langName){
+ /**
+ * 単体で使用すると異常が発生するため、API以外での使用を固く非推奨する
+ * @param lang 言語名
+ * @param langName 言語への名前
+ */
+ @Deprecated
+ private static void addCompoundLanguage(String lang, String langName){
compoundsNameListHash.add(
lang,
langName);
- public void addElectrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
- for (ItemStack item : material)
- {
- if (item != null){
- addElectrolysisDecompositionRecipe(item, formula);
- }
- }
- }
-
-
+ /**
+ * 電気分解台のレシピを追加します
+ * @param material 素材
+ * @param formula 化学式(結果)
+ */
+ public static void addElectrolysisDecompositionRecipe(ItemStack material, Formula formula) {
+ ChemiCraftCore.logger.write("addElectrolysisRecipe:" + "Material-" + material.getItemName() + "/Result-" + Arrays.toString(formula.getAtoms()),
+ EnumLoggingType.INFO);
- public void addElectrolysisDecompositionRecipe(ItemStack material, Formula formula) {
ItemStack[] itemstacks =
new ItemStack[formula.getAtoms().length];
for (int i = 0; i < itemstacks.length; i++) {
formula.getAmonts()[i],
ChemiCraftData.toAtoms(formula.getAtoms()[i]));
}
- this.electrolysisRecipeList.put(
+ electrolysisRecipeList.put(
material,
itemstacks);
}
/**
- * 素材作成台のレシピを追加します
- * @param materials 素材
- * @param result 結果
- * @param nbtRecipe NBT(Nullの場合はなし)
- */
- public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
- materialRecipe.add(
- new MaterialRecipe(
- result,
- materials,
- nbtRecipe,
- false));
- }
-
-
-
- /**
- * 電気分解台の燃料を追加します
- * @param itemstack 燃料のItemStack
- * @param burnTime 燃焼時間(tick * rate)
+ * 電気分解台のレシピを追加します
+ * @param material 素材 (すべて結果は同じになります)
+ * @param formula 化学式(結果)
*/
- public void addPyrolysisDecompositionFuel(ItemStack itemstack, int burnTime) {
- this.pyrolysisFuelList.put(
- itemstack,
- burnTime);
- }
-
-
-
- public void addPyrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
- for (ItemStack item : material)
- {
- if (item != null){
- addPyrolysisDecompositionRecipe(item, formula);
- return;
+ public static void addElectrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
+ for (ItemStack item : material) {
+ if (item != null) {
+ addElectrolysisDecompositionRecipe(item, formula);
}
- }
+ }
}
/**
- * 電気分解台のレシピを追加します
+ * 熱分解台のレシピを追加します
* @param material 素材
- * @param integers 原子の元素番号の配列
- * @param integers2 原子のできる数の配列
+ * @param formula 化学式(結果)
*/
- public void addPyrolysisDecompositionRecipe(ItemStack material, Formula formula) {
+ public static void addPyrolysisDecompositionRecipe(ItemStack material, Formula formula) {
+ ChemiCraftCore.logger.write("addPyrolysisRecipe:" + "Material-" + material.getItemName() + "/Result-" + Arrays.toString(formula.getAtoms()),
+ EnumLoggingType.INFO);
+
ItemStack[] itemstacks =
new ItemStack[formula.getAtoms().length];
for (int i = 0; i < itemstacks.length; i++) {
formula.getAmonts()[i],
ChemiCraftData.toAtoms(formula.getAtoms()[i]));
}
- this.pyrolysisRecipeList.put(
+ pyrolysisRecipeList.put(
material,
itemstacks);
}
- public void addReversible(ItemStack result, Formula formula){
- addChemicalCombinationRecipe(result, formula);
- addPyrolysisDecompositionRecipe(result, formula);
- addElectrolysisDecompositionRecipe(result, formula);
+ /**
+ * 熱分解台のレシピを追加します
+ * @param material 素材 (すべて結果は同じになります)
+ * @param formula 化学式(結果)
+ */
+ public static void addPyrolysisDecompositionRecipe(ArrayList<ItemStack> material, Formula formula) {
+ for (ItemStack item : material) {
+ if (item != null) {
+ addPyrolysisDecompositionRecipe(item, formula);
+ return;
+ }
+ }
+ }
+
+
+
+ /**
+ * 化合,熱分解,電気分解ができるレシピを追加します
+ * @param materialAndResult 素材(分解)と結果(化合)
+ * @param formula 化学式(分解なら結果に。化合なら素材に)
+ */
+ public static void addReversible(ItemStack materialAndResult, Formula formula){
+ addChemicalCombinationRecipe(materialAndResult, formula);
+ addPyrolysisDecompositionRecipe(materialAndResult, formula);
+ addElectrolysisDecompositionRecipe(materialAndResult, formula);
}
- public void addReversibleOfElectrolysis(ItemStack result, Formula formula){
+
+ /**
+ * 化合,電気分解ができるレシピを追加します
+ * @param materialAndResult 素材(分解)と結果(化合)
+ * @param formula 化学式(分解なら結果に。化合なら素材に)
+ */
+ public static void addReversibleOfElectrolysis(ItemStack result, Formula formula){
addChemicalCombinationRecipe(result, formula);
addElectrolysisDecompositionRecipe(result, formula);
}
- public void addReversibleOfPyrolysis(ItemStack result, Formula formula){
+ /**
+ * 化合,熱分解ができるレシピを追加します
+ * @param materialAndResult 素材(分解)と結果(化合)
+ * @param formula 化学式(分解なら結果に。化合なら素材に)
+ */
+ public static void addReversibleOfPyrolysis(ItemStack result, Formula formula){
addChemicalCombinationRecipe(result, formula);
addPyrolysisDecompositionRecipe(result, formula);
}
/**
- * 素材作成台の不定形レシピを追加します
+ * 電気分解台の燃料を追加します
+ * @param itemstack 燃料のItemStack
+ * @param burnTime 燃焼時間(tick * rate)
+ */
+ public static void addElectrolysisDecompositionFuel(ItemStack itemstack, int burnTime) {
+ ChemiCraftCore.logger.write("addElectrolysisFuel:" + "Fuel-" + itemstack.getItemName() + "/BurnTime-" + burnTime,
+ EnumLoggingType.INFO);
+
+ electrolysisFuelList.put(
+ itemstack,
+ burnTime);
+ }
+
+
+
+ /**
+ * 熱分解台の燃料を追加します
+ * @param itemstack 燃料のItemStack
+ * @param burnTime 燃焼時間(tick * rate)
+ */
+ public static void addPyrolysisDecompositionFuel(ItemStack itemstack, int burnTime) {
+ ChemiCraftCore.logger.write("addPyrolysisFuel:" + "Fuel-" + itemstack.getItemName() + "/BurnTime-" + burnTime,
+ EnumLoggingType.INFO);
+
+ pyrolysisFuelList.put(
+ itemstack,
+ burnTime);
+ }
+
+
+
+ /**
+ * 素材作成台のレシピを追加します
* @param materials 素材
* @param result 結果
* @param nbtRecipe NBT(Nullの場合はなし)
*/
- public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
+ public static void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
+ ChemiCraftCore.logger.write("addMaterialRecipe:" + "Materials-" + Arrays.toString(materials) + "/Result-" + result.getItemName() + "/NBT-" + nbtRecipe,
+ EnumLoggingType.INFO);
+
materialRecipe.add(
new MaterialRecipe(
result,
materials,
nbtRecipe,
- true));
+ false));
}
/**
- * ツール&武器作成台の不定形レシピを追加します
+ * 素材作成台の不定形レシピを追加します
* @param materials 素材
* @param result 結果
+ * @param nbtRecipe NBT(Nullの場合はなし)
*/
- public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
- toolAndWeaponMaterials.add(materials);
- toolAndWeaponResult.add(result);
- toolAndWeaponSharpless.add(true);
+ public static void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
+ ChemiCraftCore.logger.write("addMaterialRecipe:" + "Materials-" + Arrays.toString(materials) + "/Result-" + result.getItemName() + "/NBT-" + nbtRecipe,
+ EnumLoggingType.INFO);
+
+ materialRecipe.add(
+ new MaterialRecipe(
+ result,
+ materials,
+ nbtRecipe,
+ true));
+ }
+
+
+
+ /**
+ * 化合物のハンドラーを設定します。<br>
+ * CompoundHandlerを実装したクラスをcompoundHandlerに入れることによってhandlerItemNameで指定した<br>
+ * 化合物にハンドラーをつけることができます。
+ * @param handlerItemName ハンドラーをつける化合物の英語名
+ * @param compoundHandler ハンドラー
+ */
+ public static void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
+ ChemiCraftCore.logger.write("settingCompoundHandler:" + "Name-" + handlerItemName + "/CompoundHandler-" + compoundHandler,
+ EnumLoggingType.INFO);
+
+ compoundHandlers.add(compoundHandler);
+ compoundHandlerItemNames.add(handlerItemName);
}
/**
- * ツール&武器作成台のレシピを追加します
+ * ツール&武器作成台のレシピを追加します<br>
+ * 未作成であり、動作しません
* @param materials 素材
* @param result 結果
*/
- public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
+ @Deprecated
+ public static void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
toolAndWeaponMaterials.add(materials);
toolAndWeaponResult.add(result);
toolAndWeaponSharpless.add(false);
- public HashMap<ItemStack, Integer> getChemicalCellsList(){
- return chemicalCellsList;
+ /**
+ * ツール&武器作成台の不定形レシピを追加します<br>
+ * * 未作成であり、動作しません
+ * @param materials 素材
+ * @param result 結果
+ */
+ @Deprecated
+ public static void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
+ toolAndWeaponMaterials.add(materials);
+ toolAndWeaponResult.add(result);
+ toolAndWeaponSharpless.add(true);
}
- public ListHash<String, String> getChemicalCellsName(){
- return chemicalCellsNameListHash;
- }
-
//以下システム関連//////////////////////////////////////////////////////
- public ArrayList<Integer[]> getChemicalCombinationAmounts(){
+ public static ArrayList<Integer[]> getChemicalCombinationAmounts() {
return chemicalCombinationAmounts;
}
- public ArrayList<String[]> getChemicalCombinationAtoms(){
+ public static ArrayList<String[]> getChemicalCombinationAtoms() {
return chemicalCombinationAtoms;
}
- public ArrayList<ItemStack> getChemicalCombinationResult(){
+ public static ArrayList<ItemStack> getChemicalCombinationResult() {
return chemicalCombinationResult;
}
- public int getCompound(String key){
- if(compoundHash.get(key) != null){
+ public static int getCompound(String key) {
+ if (compoundHash.get(key) != null) {
return compoundHash.get(key);
} else {
return -1;
- public ArrayList<ICompoundHandler> getCompoundHandler(){
+ public static ArrayList<ICompoundHandler> getCompoundHandler() {
compoundHandlers.trimToSize();
return compoundHandlers;
-
}
- public ArrayList<String> getCompoundHandlerItemName(){
+ public static ArrayList<String> getCompoundHandlerItemName() {
compoundHandlerItemNames.trimToSize();
return compoundHandlerItemNames;
}
- public ListHash<String, String> getCompoundsName(){
+ public static ListHash<String, String> getCompoundsName() {
return compoundsNameListHash;
}
- public ChemiCraftCraftingManager getCraftingManager(){
+ public static ChemiCraftCraftingManager getCraftingManager() {
return chemiCraftCraftingManager;
}
- public HashMap<ItemStack, ItemStack[]> getElectrolysisRecipeList()
- {
+ public static HashMap<ItemStack, Integer> getElectrolysisFuelList() {
+ return electrolysisFuelList;
+ }
+
+
+
+ public static HashMap<ItemStack, ItemStack[]> getElectrolysisRecipeList() {
return electrolysisRecipeList;
}
- public ArrayList<MaterialRecipe> getMaterialRecipe(){
+ public static ArrayList<MaterialRecipe> getMaterialRecipe() {
return materialRecipe;
}
- public HashMap<ItemStack, Integer> getPyrolysisFuelList()
- {
+ public static HashMap<ItemStack, Integer> getPyrolysisFuelList() {
return pyrolysisFuelList;
}
- public HashMap<ItemStack, ItemStack[]> getPyrolysisRecipeList()
- {
+ public static HashMap<ItemStack, ItemStack[]> getPyrolysisRecipeList() {
return pyrolysisRecipeList;
}
- public ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
+ public static ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
return toolAndWeaponMaterials;
}
- public ArrayList<ItemStack> getToolAndWeaponResult() {
+ public static ArrayList<ItemStack> getToolAndWeaponResult() {
return toolAndWeaponResult;
}
- public ArrayList<Boolean> getToolAndWeaponSharpless() {
+ public static ArrayList<Boolean> getToolAndWeaponSharpless() {
return toolAndWeaponSharpless;
}
-
-
- /**
- * setting compound handler.
- * @param handlerItemName
- * @param compoundHandler
- */
- public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
- compoundHandlers.add(compoundHandler);
- compoundHandlerItemNames.add(handlerItemName);
- }
-
}