OSDN Git Service

素材製作台のレシピついかはできるようにした
authormozipi <mozipi@users.sourceforge.jp>
Fri, 21 Dec 2012 08:23:40 +0000 (17:23 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Fri, 21 Dec 2012 08:23:40 +0000 (17:23 +0900)
common/chemicraft/ChemiCraft.java
common/chemicraft/ChemiCraftAPI.java
common/chemicraft/ChemiCraftCraftingManager.java

index 19971f7..4536408 100644 (file)
@@ -206,14 +206,6 @@ public class ChemiCraft {
                // GUIを追加します\r
                NetworkRegistry.instance().registerGuiHandler(instance, proxy);\r
 \r
-               //分解レシピを追加します\r
-               ChemiCraftAPI.instance.addDecompositionRecipe(new ItemStack(Block.dirt, 1, 0), new ItemStack[]{new ItemStack(Block.stone, 16, 0),new ItemStack(Block.dispenser)});\r
-               ChemiCraftAPI.instance.addDecompositionRecipe(new ItemStack(Block.stone, 1, 0), new ItemStack[]{new ItemStack(Block.stone, 16, 0)});\r
-\r
-               //化合レシピを追加します\r
-               ChemiCraftAPI.instance.addChemicalCombinationRecipe(new ItemStack[]{new ItemStack(Block.dirt), new ItemStack(Block.stone)}, new ItemStack(Block.stone));\r
-               ChemiCraftAPI.instance.addChemicalCombinationRecipe(new ItemStack[]{new ItemStack(Block.stone)}, new ItemStack(Block.dirt));\r
-\r
                //Textureをpreloadします\r
                proxy.registerTextures();\r
        }\r
index d4bc948..8111626 100644 (file)
@@ -74,6 +74,41 @@ public class ChemiCraftAPI {
 
 
        /**
+        * 素材製作台の効果添付素材のリスト
+        */
+       private ArrayList<ItemStack[]> materialEffectMaterials = new ArrayList<ItemStack[]>();
+
+
+
+       /**
+        * 素材製作台の素材のリスト
+        */
+       private ArrayList<ItemStack[]> materialMaterials = new ArrayList<ItemStack[]>();
+
+
+
+       /**
+        * 素材製作台の結果のリスト
+        */
+       private ArrayList<ItemStack> materialResult = new ArrayList<ItemStack>();
+
+
+
+       /**
+        * 素材製作台の効果のキーリスト
+        */
+       private ArrayList<String[]> materialEffectKey = new ArrayList<String[]>();
+
+
+
+       /**
+        * 素材製作台の効果のリスト
+        */
+       private ArrayList<Object[]> materialEffectValue = new ArrayList<Object[]>();
+
+
+
+       /**
         * ChemiCraftの化学作業台類のレシピのマネージャー
         */
        private ChemiCraftCraftingManager chemiCraftCraftingManager = new ChemiCraftCraftingManager();
@@ -147,6 +182,23 @@ public class ChemiCraftAPI {
                        System.err.println("ChemiCraft内でエラー:addChemicalCombinationRecipeの引数materialの要素数が16を超えています。" + "Material:" + material + "  Result:" + result);
                }
        }
+
+
+
+       public void addMaterialRecipe(ItemStack[] materials, ItemStack[] effectMaterials,ItemStack result, String[] key, Object[] value){
+               if(materials.length <= 9){
+                       if(effectMaterials.length <= 3){
+                               materialMaterials.add(materials);
+                               materialResult.add(result);
+                               materialEffectKey.add(key);
+                               materialEffectValue.add(value);
+                       }else{
+                               System.err.println("ChemiCraft内でエラー:addMaterialRecipeの引数effectMaterialsの要素数が3を超えています。" + "Material:" + materials + " Result:" + result + " key" + key + " value:" + value);
+                       }
+               }else{
+                       System.err.println("ChemiCraft内でエラー:addMaterialRecipeの引数materialsの要素数が9を超えています。" + "Material:" + materials + " Result:" + result + " key" + key + " value:" + value);
+               }
+       }
        //以下システム関連//////////////////////////////////////////////////////
 
        public ArrayList<ICompoundHandler> getCompoundHandler(){
index 7ea81cc..d7d0e30 100644 (file)
@@ -9,55 +9,88 @@ import net.minecraft.src.ItemStack;
 public class ChemiCraftCraftingManager {
 
        public ItemStack[] getDecompositionResults(IInventory par1IInventory){
+               //Setting to Flag.
                ((InventoryDecomposition)par1IInventory).setFlag(false);
+
+               //variable of results.
                ItemStack[] results = null;
+
+               //Just loop of amount of added recipe.
                for(int i1 = 0;i1 < ChemiCraftAPI.instance.getDecompositionMaterial().size();i1++){
+                       //Recipe the match?
                        boolean match = true;
-                       ArrayList<Integer> materialID = new ArrayList<Integer>();
-                       ArrayList<Integer> materialDamage = new ArrayList<Integer>();
+                       //Reset the results.
                        results  = new ItemStack[ChemiCraftAPI.instance.getDecompositionResult().get(i1).length];
+                       //Recipe ID & Damage.
+                       //Material ID & Damage.
+                       int materialID = par1IInventory.getStackInSlot(16).itemID;
+                       int materialDamage = par1IInventory.getStackInSlot(16).getItemDamage();
+                       int recipeID = ChemiCraftAPI.instance.getDecompositionMaterial().get(i1).itemID;
+                       int recipeDamage = ChemiCraftAPI.instance.getDecompositionMaterial().get(i1).getItemDamage();
 
-                       materialID.add(ChemiCraftAPI.instance.getDecompositionMaterial().get(i1).itemID);
-                       materialDamage.add(ChemiCraftAPI.instance.getDecompositionMaterial().get(i1).getItemDamage());
+                       //Check of null of the Material Slot.
                        if(par1IInventory.getStackInSlot(16) == null){ this.clearResults(par1IInventory, 16); return new ItemStack[16];}
-                       if(materialID.get(0) != par1IInventory.getStackInSlot(16).itemID){ match = false;}
-                       if(materialDamage.get(0) != par1IInventory.getStackInSlot(16).getItemDamage()){ match = false;}
+                       //ID check.
+                       if(materialID != recipeID){ match = false;}
+                       //Damage check.
+                       if(materialDamage != recipeDamage){ match = false;}
 
+                       //if "match == true"
                        if(match){
+                               //Just loop of recipe size of recipe index i1.
                                for(int i = 0;i < ChemiCraftAPI.instance.getDecompositionResult().get(i1).length;i++){
+                                       //Assignment to the results.
                                        results[i] = new ItemStack(
                                                        ChemiCraftAPI.instance.getDecompositionResult().get(i1)[i].itemID,
                                                        ChemiCraftAPI.instance.getDecompositionResult().get(i1)[i].stackSize,
                                                        ChemiCraftAPI.instance.getDecompositionResult().get(i1)[i].getItemDamage()
                                                        );
                                }
+                               //return the results.
                                return results;
                        }
                }
+               //return the null.
                return null;
        }
 
 
 
        public ItemStack getChemicalCombinationResult(IInventory par1IInventory){
+               //Setting to flag.
                ((InventoryChemicalCombination) par1IInventory).setFlag(false);
+
+               //variable of result.
                ItemStack result = null;
+
+               //Just loop of amount of added recipe.
                for(int i = 0;i < ChemiCraftAPI.instance.getChemicalCombinationMaterial().size();i++){
+
+                       //Recipe the match?
                        boolean match = true;
+                       //materialID & recipeID
                        ArrayList<Integer> materialID = new ArrayList<Integer>();
                        ArrayList<Integer> materialDamage = new ArrayList<Integer>();
                        ArrayList<Integer> recipeID = new ArrayList<Integer>();
                        ArrayList<Integer> recipeDamage = new ArrayList<Integer>();
+
+                       //Just loop of recipe size of recipe index i.
                        for(int j = 0;j < ChemiCraftAPI.instance.getChemicalCombinationMaterial().get(i).length;j++){
-                               materialID.add(ChemiCraftAPI.instance.getChemicalCombinationMaterial().get(i)[j].itemID);
-                               materialDamage.add(ChemiCraftAPI.instance.getChemicalCombinationMaterial().get(i)[j].getItemDamage());
+                               //Adding the recipe ID & Damage.
+                               recipeID.add(ChemiCraftAPI.instance.getChemicalCombinationMaterial().get(i)[j].itemID);
+                               recipeDamage.add(ChemiCraftAPI.instance.getChemicalCombinationMaterial().get(i)[j].getItemDamage());
                        }
+                       //Just loop of 16.
                        for(int j = 0;j < 16;j++){
+                               //Null check
                                if(par1IInventory.getStackInSlot(j) != null){
-                                       recipeID.add(par1IInventory.getStackInSlot(j).itemID);
-                                       recipeDamage.add(par1IInventory.getStackInSlot(j).getItemDamage());
+                                       //Adding the materialID & Damage.
+                                       materialID.add(par1IInventory.getStackInSlot(j).itemID);
+                                       materialDamage.add(par1IInventory.getStackInSlot(j).getItemDamage());
                                }
                        }
+
+                       //trimToSize & sorting.
                        materialID.trimToSize();
                        materialDamage.trimToSize();
                        recipeID.trimToSize();
@@ -66,23 +99,31 @@ public class ChemiCraftCraftingManager {
                        Collections.sort(materialDamage);
                        Collections.sort(recipeID);
                        Collections.sort(recipeDamage);
+
+                       //Size check.
                        if(materialID.size() != recipeID.size()){ match = false;}
+                       //Just loop of materialID.size().
                        for(int j = 0;j < materialID.size();j++){
-                               if(recipeID.size() <= j){match = false; break;}
+                               //ID check.
                                if(materialID.get(j) != recipeID.get(j)){ match = false;}
+                               //Damage check.
                                if(materialDamage.get(j) != recipeDamage.get(j)){ match = false;}
                        }
 
+                       //if "match == true"
                        if(match){
+                               //Assignment to the result.
                                result =
                                                new ItemStack(
                                                                ChemiCraftAPI.instance.getChemicalCombinationResult().get(i).itemID,
                                                                ChemiCraftAPI.instance.getChemicalCombinationResult().get(i).stackSize,
                                                                ChemiCraftAPI.instance.getChemicalCombinationResult().get(i).getItemDamage()
                                                                );
+                               //return the result.
                                return result;
                        }
                }
+               //return the null.
                return null;
        }