package mariculture.plugins;

import static mariculture.core.helpers.RecipeHelper.addShapeless;

import java.util.Arrays;
import java.util.Iterator;
import java.util.Map.Entry;

import mariculture.api.fishery.Fishing;
import mariculture.api.fishery.RodType;
import mariculture.api.fishery.fish.FishSpecies;
import mariculture.core.Core;
import mariculture.core.lib.MaterialsMeta;
import mariculture.core.lib.Modules;
import mariculture.plugins.Plugins.Plugin;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import rebelkeithy.mods.aquaculture.items.AquacultureItems;
import rebelkeithy.mods.aquaculture.items.ItemFish.Fish;

public class PluginAquaculture extends Plugin {
    public PluginAquaculture(String name) {
        super(name);
    }

    @Override
    public void preInit() {
        return;
    }

    @Override
    public void init() {
        if (Modules.isActive(Modules.fishery)) {
            Fishing.fishing.addBait(new ItemStack(AquacultureItems.fish, 1, 19), 25);
            Fishing.fishing.addBaitForQuality(new ItemStack(AquacultureItems.fish, 1, 19), Arrays.asList(RodType.DIRE, RodType.FLUX));
        }
    }

    @Override
    public void postInit() {
        if (Modules.isActive(Modules.fishery)) {
            //Remove Fish Fillet Recipes, We readd them later with a new recipe
            remove(getItem("item.loot"), 3);

            for (Entry<Integer, FishSpecies> list : FishSpecies.species.entrySet()) {
                FishSpecies species = list.getValue();
                if (species.getFishMealSize() > 0) {
                    addShapeless(new ItemStack(getItem("item.loot"), species.getFishMealSize(), 3), new Object[] { species.getRawForm(1), "foodSalt" });
                }
            }
        }

        for (int i = 0; i < AquacultureItems.fish.fish.size(); i++) {
            Fish f = AquacultureItems.fish.fish.get(i);
            if (f.filletAmount != 0) {
                addShapeless(AquacultureItems.fishFillet.getItemStack(f.filletAmount), new Object[] { new ItemStack(AquacultureItems.fish, 1, i), "foodSalt" });
                addShapeless(new ItemStack(Core.materials, f.filletAmount, MaterialsMeta.FISH_MEAL), new Object[] { new ItemStack(AquacultureItems.fish, 1, i) });
            }
        }
    }

    public void remove(Item item, int meta) {
        for (Iterator<IRecipe> iterator = CraftingManager.getInstance().getRecipeList().iterator(); iterator.hasNext();) {
            IRecipe recipe = iterator.next();
            if (recipe.getRecipeOutput() != null) {
                if (recipe.getRecipeOutput().getItem() == item && recipe.getRecipeOutput().getItemDamage() == meta) {
                    iterator.remove();
                }
            }
        }
    }
}

@@ -1848,27 +1848,34 @@
   %7D%0A        
-%7D%0A%0A
+    %0A%0A    
         for 
@@ -1940,24 +1940,28 @@
             
+  
+  
 Fish f = Aqu
@@ -2000,24 +2000,28 @@
             
+    
 if (f.fillet
@@ -2031,24 +2031,28 @@
 unt != 0) %7B%0A
+    
             
@@ -2208,32 +2208,36 @@
                 
+ 
+   
 addShapeless(new
@@ -2363,24 +2363,42 @@
 , 1, i) %7D);%0A
+                %7D%0A
             

Move the fillets back inside the if... DOH