OSDN Git Service

素材製作台(減算処理・NBT処理抜き)を製作
[chemicraft/chemicraft.git] / common / chemicraft / system / ChemiCraftCraftingManager.java
index 6945d93..5ecf8c5 100644 (file)
@@ -11,6 +11,7 @@ import chemicraft.inventory.InventoryChemicalCraftingMaterial;
 import chemicraft.inventory.InventoryChemicalCraftingNBT;
 import chemicraft.inventory.InventoryChemicalCraftingResult;
 import chemicraft.inventory.InventoryDecomposition;
+import chemicraft.util.ChemicalNBTRecipe;
 
 public class ChemiCraftCraftingManager {
 
@@ -135,38 +136,24 @@ public class ChemiCraftCraftingManager {
 
 
 
-       public void chemicalCrafting(InventoryChemicalCraftingMaterial par1IInventory, InventoryChemicalCraftingResult par2IInventory, InventoryChemicalCraftingNBT par3IInventory){
+       public ChemicalNBTRecipe chemicalCrafting(InventoryChemicalCraftingMaterial par1IInventory, InventoryChemicalCraftingResult par2IInventory, InventoryChemicalCraftingNBT par3IInventory){
                ChemiCraftAPI api = ChemiCraftAPI.instance;
-               int[] materialID = new int[par1IInventory.getSizeInventory()];
-               int[] materialDamage = new int[par1IInventory.getSizeInventory()];
-               int[] resultID = new int[par2IInventory.getSizeInventory()];
-               int[] resultDamage = new int[par2IInventory.getSizeInventory()];
-               int[] nbtID = new int[par3IInventory.getSizeInventory()];
-               int[] nbtDamage = new int[par3IInventory.getSizeInventory()];
-               //ItemID,ItemDamageの格納
-               for(int j = 0;j < par1IInventory.getSizeInventory();j++){
-                       if(par1IInventory.getStackInSlot(j) != null){
-                               materialID[j] = par1IInventory.getStackInSlot(j).itemID;
-                               materialDamage[j] = par1IInventory.getStackInSlot(j).getItemDamage();
-                       }
-               }
-               for(int j = 0;j < par2IInventory.getSizeInventory();j++){
-                       if(par2IInventory.getStackInSlot(j) != null){
-                               resultID[j] = par2IInventory.getStackInSlot(j).itemID;
-                               resultDamage[j] = par2IInventory.getStackInSlot(j).getItemDamage();
-                       }
-               }
-               for(int j = 0;j < par3IInventory.getSizeInventory();j++){
-                       if(par3IInventory.getStackInSlot(j) != null){
-                               nbtID[j] = par3IInventory.getStackInSlot(j).itemID;
-                               nbtDamage[j] = par3IInventory.getStackInSlot(j).getItemDamage();
-                       }
-               }
-
+               ChemicalNBTRecipe returnObj = null;
                for(int i = 0;i < api.getMaterialRecipe().size();i++){
-                       api.getMaterialRecipe().get(i).match(par1IInventory);
+                       ItemStack result = api.getMaterialRecipe().get(i).match(par1IInventory);
+                       ItemStack resultArg = null;
+                       if(result != null){
+                               resultArg = new ItemStack(result.itemID, result.stackSize, result.getItemDamage());
+                               ItemStack[] nbtInv = new ItemStack[par3IInventory.getSizeInventory()];
+                               for(int j = 0;j < par3IInventory.getSizeInventory();j++){
+                                       nbtInv[j] = par3IInventory.getStackInSlot(j);
+                               }
+                               api.getMaterialRecipe().get(i).nbtMatch(par1IInventory).setNBT(nbtInv, resultArg);
+                               returnObj = api.getMaterialRecipe().get(i).nbtMatch(par1IInventory);
+                       }
+                       par2IInventory.setInventorySlotContents(0, resultArg);
                }
-               return;
+               return returnObj;
        }