OSDN Git Service

修正・変更
[chemicraft/chemicraft.git] / common / pcc / chemicraft / system / ChemiCraftCraftingManager.java
index 86e8bbc..899fe83 100644 (file)
@@ -2,21 +2,65 @@ package pcc.chemicraft.system;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import pcc.chemicraft.ChemiCraft;
 import pcc.chemicraft.ChemiCraftAPI;
 import pcc.chemicraft.inventory.InventoryChemicalCraftingMaterial;
 import pcc.chemicraft.inventory.InventoryChemicalCraftingNBT;
 import pcc.chemicraft.inventory.InventoryChemicalCraftingResult;
+import pcc.chemicraft.inventory.InventoryToolAndWeaponCraftingTableMaterial;
 import pcc.chemicraft.util.ChemicalNBTRecipe;
 import pcc.chemicraft.util.ComparatorFormulaPart;
+import pcc.chemicraft.util.ComparatorItemStack;
 import pcc.chemicraft.util.FormulaPart;
 
-import net.minecraft.inventory.IInventory;
-import net.minecraft.item.ItemStack;
 
 public class ChemiCraftCraftingManager {
 
-       public ItemStack[] getDecompositionResults(IInventory par1IInventory){
+       public ItemStack getToolAndWeaponCraftingResult(InventoryToolAndWeaponCraftingTableMaterial par1IInventory){
+               ChemiCraftAPI api = ChemiCraftAPI.instance();
+               ArrayList<ItemStack[]> materials = api.getToolAndWeaponMaterials();
+               ArrayList<ItemStack> result = api.getToolAndWeaponResult();
+               ArrayList<Boolean> sharpless = api.getToolAndWeaponSharpless();
+
+               ItemStack[] slotItems = new ItemStack[par1IInventory.getSizeInventory()];
+               for (int i = 0; i < par1IInventory.getSizeInventory(); i++) {
+                       slotItems[i] = (par1IInventory.getStackInSlot(i));
+               }
+
+               label1 :
+                       for (int i = 0; i < materials.size(); i++) {
+                               if (sharpless.get(i)) {
+                                       slotItems = ChemiCraft.instance.arrayAuxiliary.deleteNull(slotItems);
+                                       Collections.sort(materials, new ComparatorItemStack());
+                                       Arrays.sort(slotItems, new ComparatorItemStack());
+                                       if (materials.size() != slotItems.length) continue label1;
+
+                                       for (int j = 0; j < materials.size(); j++) {
+                                               if (materials.get(i)[j].itemID != slotItems[j].itemID) {
+                                                       if (materials.get(i)[j].getItemDamage() != slotItems[j].getItemDamage()) {
+                                                               continue label1;
+                                                       }
+                                               }
+                                       }
+                                       return result.get(i);
+                               } else {
+                                       slotItems = ChemiCraft.instance.arrayAuxiliary.deleteNull(slotItems);
+                                       if (materials.get(i).length != slotItems.length) continue label1;
+
+                                       for (int j = 0; j < materials.size(); j++) {
+                                               if (materials.get(i)[j].itemID != slotItems[j].itemID) {
+                                                       if (materials.get(i)[j].getItemDamage() != slotItems[j].getItemDamage()) {
+                                                               continue label1;
+                                                       }
+                                               }
+                                       }
+                                       return result.get(i);
+                               }
+                       }
                return null;
        }