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;
16 * 基本的にAddonはこのクラスのインスタンスを使う
20 public class ChemiCraftAPI {
23 * Instance of the ChemiCraftAPI.
25 private static ChemiCraftAPI instance = new ChemiCraftAPI();
29 * List of compounds names.
31 private ArrayList<String> compoundsNameList = new ArrayList<String>();
35 * List of compounds names(Some kind of language).
37 private ArrayList<String> compoundsLangNameList = new ArrayList<String>();
41 * List of compounds the language names.
43 private ArrayList<String> compoundsLangList = new ArrayList<String>();
47 * List of compounds handlers.
49 private ArrayList<ICompoundHandler> compoundHandlers = new ArrayList<ICompoundHandler>();
53 * 化合物の文字列をダメージ値に変換します。
55 private HashMap<String, Integer> compoundHash = new HashMap<String, Integer>();
59 * List of item name of handler to compounds.
61 private ArrayList<String> compoundHandlerItemNames = new ArrayList<String>();
67 private ArrayList<String[]> chemicalCombinationAtoms = new ArrayList<String[]>();
73 private ArrayList<Integer[]> chemicalCombinationAmounts = new ArrayList<Integer[]>();
79 private ArrayList<ItemStack> chemicalCombinationResult = new ArrayList<ItemStack>();
85 private ArrayList<MaterialRecipe> materialRecipe = new ArrayList<MaterialRecipe>();
89 * ChemiCraftの化学作業台類のレシピのマネージャー
91 private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
95 private ArrayList<Integer> atomsOreIDList = new ArrayList<Integer>();
98 private ArrayList<Integer> atomsOreMetaList = new ArrayList<Integer>();
101 private ArrayList<Integer> atomsOreSizeList = new ArrayList<Integer>();
104 private ArrayList<Integer> atomsOreFrequencyList = new ArrayList<Integer>();
107 private ArrayList<Integer> atomsOrePosYList = new ArrayList<Integer>();
114 private ArrayList<ItemStack[]> toolAndWeaponMaterials = new ArrayList<ItemStack[]>();
120 private ArrayList<ItemStack> toolAndWeaponResult = new ArrayList<ItemStack>();
126 private ArrayList<Boolean> toolAndWeaponSharpless = new ArrayList<Boolean>();
132 * @param name compound name.
134 public void addCompound(String name){
135 addLangCompound("", name, "");
141 * add compound corresponding to the language.
142 * @param lang Language to the corresponding
143 * @param englishName compound name
144 * @param langName compound name(specified language)
146 public void addLangCompound(String lang, String englishName, String langName){
147 compoundsNameList.add(englishName);
148 compoundsLangNameList.add(langName);
149 compoundsLangList.add(lang);
150 compoundHash.put(englishName, compoundHash.size());
155 public int getCompound(String key){
156 if(compoundHash.get(key) != null){
157 return compoundHash.get(key);
166 * setting compound handler.
167 * @param handlerItemName
168 * @param compoundHandler
170 public void settingCompoundHandler(String handlerItemName, ICompoundHandler compoundHandler){
171 compoundHandlers.add(compoundHandler);
172 compoundHandlerItemNames.add(handlerItemName);
178 * 化合レシピを追加します。materialの要素数は0<= n <= 16にしてください。
182 public void addChemicalCombinationRecipe(String[] atoms, Integer[] amounts, ItemStack result){
183 chemicalCombinationAtoms.add(atoms);
184 chemicalCombinationAmounts.add(amounts);
185 chemicalCombinationResult.add(result);
193 * @param results 原子の元素番号の配列
194 * @param stacks 原子のできる数の配列
196 public void addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
197 ItemStack[] itemstacks = new ItemStack[results.length];
198 for (int i = 0; i < itemstacks.length; i++) {
199 itemstacks[i] = new ItemStack(ChemiCraft.instance.itemAtoms,stacks[i], results[i]);
201 TileEntityPyrolysisTable.addRecipe(material, itemstacks);
208 * @param itemstack 燃料のItemStack
209 * @param burnTime 燃焼時間(tick * rate)
211 public void addDecompositionFuel(ItemStack itemstack, int burnTime) {
212 TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
218 * ツール&武器作成台のレシピを追加します
219 * @param materials 素材
222 public void addToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
223 toolAndWeaponMaterials.add(materials);
224 toolAndWeaponResult.add(result);
225 toolAndWeaponSharpless.add(false);
230 * ツール&武器作成台の不定形レシピを追加します
231 * @param materials 素材
234 public void addSharplessToolAndWeaponRecipe(ItemStack[] materials, ItemStack result) {
235 toolAndWeaponMaterials.add(materials);
236 toolAndWeaponResult.add(result);
237 toolAndWeaponSharpless.add(true);
244 * @param materials 素材
246 * @param nbtRecipe NBT(Nullの場合はなし)
248 public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
249 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
256 * @param materials 素材
258 * @param nbtRecipe NBT(Nullの場合はなし)
260 public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
261 materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
266 public void addAtomsOre(int id, int size, int frequency, int posY){
267 addAtomsOre(id, 0, size, frequency, posY);
271 public void addAtomsOre(int id, int meta, int size, int frequency, int posY){
272 atomsOreIDList.add(id);
273 atomsOreMetaList.add(meta);
274 atomsOreSizeList.add(size);
275 atomsOreFrequencyList.add(frequency);
276 atomsOrePosYList.add(posY);
278 //以下システム関連//////////////////////////////////////////////////////
280 public ArrayList<ICompoundHandler> getCompoundHandler(){
281 compoundHandlers.trimToSize();
282 return compoundHandlers;
288 public ArrayList<String> getCompoundHandlerItemName(){
289 compoundHandlerItemNames.trimToSize();
290 return compoundHandlerItemNames;
295 public ArrayList<String> getCompoundsName(){
296 compoundsNameList.trimToSize();
297 return compoundsNameList;
302 public ArrayList<String> getCompoundsLangName(){
303 compoundsLangNameList.trimToSize();
304 return compoundsLangNameList;
309 public ArrayList<String> getCompoundsLang(){
310 compoundsLangList.trimToSize();
311 return compoundsLangList;
316 public ArrayList<String[]> getChemicalCombinationAtoms(){
317 return chemicalCombinationAtoms;
322 public ArrayList<Integer[]> getChemicalCombinationAmounts(){
323 return chemicalCombinationAmounts;
328 public ArrayList<ItemStack> getChemicalCombinationResult(){
329 return chemicalCombinationResult;
334 public ArrayList<MaterialRecipe> getMaterialRecipe(){
335 return materialRecipe;
340 public ArrayList<ItemStack[]> getToolAndWeaponMaterials() {
341 return toolAndWeaponMaterials;
346 public ArrayList<ItemStack> getToolAndWeaponResult() {
347 return toolAndWeaponResult;
352 public ArrayList<Boolean> getToolAndWeaponSharpless() {
353 return toolAndWeaponSharpless;
358 public ChemiCraftCraftingManager getCraftingManager(){
359 return chemiCraftCraftingManager;
364 public ArrayList<Integer> getAtomsOreIDList(){
365 return atomsOreIDList;
370 public ArrayList<Integer> getAtomsOreMetaList(){
371 return atomsOreMetaList;
376 public ArrayList<Integer> getAtomsOreSizeList(){
377 return atomsOreSizeList;
382 public ArrayList<Integer> getAtomsOreFrequencyList(){
383 return atomsOreFrequencyList;
388 public ArrayList<Integer> getAtomsOrePosYList(){
389 return atomsOrePosYList;
394 public static ChemiCraftAPI instance(){