package nmd.primal.forgecraft.crafting.registery;

import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreIngredient;
import net.minecraftforge.registries.IForgeRegistry;
import nmd.primal.core.api.PrimalAPI;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.crafting.CrucibleCrafting;
import nmd.primal.forgecraft.init.ModItems;

@GameRegistry.ObjectHolder(ModInfo.MOD_ID)
@Mod.EventBusSubscriber
public final class RecipesCrucible {
    @SubscribeEvent
    public static void registerRecipes(RegistryEvent.Register<CrucibleCrafting> event) {
        PrimalAPI.logger(7, "Registering Recipes: " + CrucibleCrafting.RECIPE_PREFIX);
        final IForgeRegistry<CrucibleCrafting> recipes = event.getRegistry();


    //RecipeHandler.addSmelting(ModItems.softcrucible, new ItemStack(ModBlocks.nbtCrucible, 1));

    /***********************/
    /***CRUCIBLE CRAFTING***/
    /***********************/

    recipes.register (new CrucibleCrafting(
                new OreIngredient("oreIron"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(Blocks.IRON_ORE, 1),
                new ItemStack(ModItems.ironingotball, 1),
                1400,
                        1200,
                        800).setRecipeName("wroughtIron1"));

    recipes.register (new CrucibleCrafting(
            new OreIngredient("dustIron"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(Blocks.IRON_ORE, 1),
                new ItemStack(ModItems.ironingotball, 1),
                1250,
                        1100,
                        800).setRecipeName("wroughtIron2"));

    recipes.register (new CrucibleCrafting(
                Ingredient.fromStacks(new ItemStack(ModItems.brokenwroughtirontool, 1)),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
                new ItemStack(ModItems.ironingotball, 1),
                1250,
                        1100,
                        800).setRecipeName("wroughtIron3"));

    recipes.register (new CrucibleCrafting(
                new OreIngredient("dustIron"),
                new OreIngredient("slackLime"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.IRON_DUST, 1),
                new ItemStack(ModItems.ironcleaningotball, 1),
                1550,
                        1200,
                        800).setRecipeName("cleanIron1"));

        recipes.register (new CrucibleCrafting(
                Ingredient.fromStacks(new ItemStack(ModItems.brokencleanirontool, 1)),
            new OreIngredient("nuggetIron"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
                new ItemStack(ModItems.ironcleaningotball, 1),
                1550,
                        1200,
                        800).setRecipeName("cleanIron2"));

        recipes.register (new CrucibleCrafting(
                Ingredient.fromStacks(new ItemStack(ModItems.ironcleaningotball, 1)),
            Ingredient.fromStacks(new ItemStack(PrimalAPI.Items.CHARCOAL_HIGH, 1)),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(ModItems.ironcleaningotball, 1),
                new ItemStack(ModItems.steelingotball, 1),
                2100,
                        1500,
                        1000).setRecipeName("steel1"));

        recipes.register (new CrucibleCrafting(
                Ingredient.fromStacks(new ItemStack(ModItems.brokensteeltool, 1)),
            new OreIngredient("nuggetSteel"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
                new ItemStack(ModItems.steelingotball, 1),
                2100,
                        1500,
                        1000).setRecipeName("steel2"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("oreClusterMagnetite"),
                Ingredient.fromStacks(new ItemStack(PrimalAPI.Items.CHARCOAL_PURE, 1)),
                new OreIngredient("oreClusterMagnetite"),
                Ingredient.fromStacks(new ItemStack(PrimalAPI.Items.CHARCOAL_PURE, 1)),
                new OreIngredient("specialCarbon"),
                new ItemStack(PrimalAPI.Items.ORE_CLUSTER_MAGNETITE, 1),
                new ItemStack(ModItems.wootzingotball, 1),
                2100,
                1800,
                1500).setRecipeName("wootz2"));

        recipes.register (new CrucibleCrafting(
                Ingredient.fromStacks(new ItemStack(ModItems.brokenwootztool, 1)),
                new OreIngredient("nuggetWootz"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
                new ItemStack(ModItems.wootzingotball, 1),
                2100,
                        1800,
                        1500).setRecipeName("wootz3"));

    /***BRONZE***/
    NBTTagCompound tagBronzeDefault = new NBTTagCompound();
        tagBronzeDefault.setString("upgrades", "");
        tagBronzeDefault.setBoolean("hot", false);
    ItemStack defaultBronze = new ItemStack(ModItems.bronzeingotball, 1);
        defaultBronze.setTagCompound(tagBronzeDefault.copy());

        recipes.register (new CrucibleCrafting(
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustTin"),
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    defaultBronze,
            1100,
            800,
            600).setRecipeName("bronze1"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotBronze"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    defaultBronze,
            1100,
            800,
            600).setRecipeName("bronze2"));

    ItemStack redBronze = defaultBronze.copy();
        redBronze.getTagCompound().setString("upgrades", "redstone");
        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotBronze"),
                new OreIngredient("dustRedstone"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    redBronze,
            1100,
            800,
            600).setRecipeName("redBronze1"));

    ItemStack diamondBronze = defaultBronze.copy();
        diamondBronze.getTagCompound().setString("upgrades", "diamond");
        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotBronze"),
                new OreIngredient("flakeDiamond"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    diamondBronze,
            1100,
            800,
            600).setRecipeName("diamondBronze1"));

    ItemStack emeraldBronze = defaultBronze.copy();
        emeraldBronze.getTagCompound().setString("upgrades", "emerald");
        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotBronze"),
                new OreIngredient("flakeEmerald"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    emeraldBronze,
            1100,
            800,
            600).setRecipeName("emeraldBronze1"));

    ItemStack lapisBronze = defaultBronze.copy();
        lapisBronze.getTagCompound().setString("upgrades", "lapis");
        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotBronze"),
                new OreIngredient("gemLapis"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    lapisBronze,
            1100,
            800,
            600).setRecipeName("lapisBronze1"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustTin"),
                new OreIngredient("dustRedstone"),
                new ItemStack(PrimalAPI.Items.SLAG, 1),
    redBronze,
            1100,
            800,
            600).setRecipeName("redBronze2"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustTin"),
                new OreIngredient("flakeDiamond"),
                new ItemStack(PrimalAPI.Items.SLAG, 1),
    diamondBronze,
            1100,
            800,
            600).setRecipeName("diamondBronze2"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustTin"),
                new OreIngredient("flakeEmerald"),
                new ItemStack(PrimalAPI.Items.SLAG, 1),
    emeraldBronze,
            1100,
            800,
            600).setRecipeName("emeraldBronze2"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustCopper"),
                new OreIngredient("dustTin"),
                new OreIngredient("gemLapis"),
                new ItemStack(PrimalAPI.Items.SLAG, 1),
    lapisBronze,
            1100,
            800,
            600).setRecipeName("lapisBronze2"));


    /***COPPER***/
    NBTTagCompound tagCopperDefault = new NBTTagCompound();
        tagCopperDefault.setString("upgrades", "");
        tagCopperDefault.setBoolean("hot", false);
    ItemStack defaultCopper = new ItemStack(PrimalAPI.Items.COPPER_INGOT, 1);
        defaultCopper.setTagCompound(tagCopperDefault.copy());

        recipes.register (new CrucibleCrafting(
                new OreIngredient("oreCopper"),
                new OreIngredient("slackLime"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    defaultCopper,
            900,
            800,
            600).setRecipeName("copper1"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotCopper"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    defaultCopper,
            900,
            750,
            550).setRecipeName("copper2"));

    ItemStack redCopper = defaultCopper.copy();
        redCopper.getTagCompound().setString("upgrades", "redstone");
        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotCopper"),
                new OreIngredient("dustRedstone"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    redCopper,
            900,
            750,
            550).setRecipeName("redCopper1"));

    ItemStack diamondCopper = defaultCopper.copy();
        diamondCopper.getTagCompound().setString("upgrades", "diamond");
        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotCopper"),
                new OreIngredient("flakeDiamond"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    diamondCopper,
            900,
            750,
            550).setRecipeName("diamondCopper1"));

    ItemStack emeraldCopper = defaultCopper.copy();
        emeraldCopper.getTagCompound().setString("upgrades", "emerald");
        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotCopper"),
                new OreIngredient("flakeEmerald"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    emeraldCopper,
            900,
            750,
            550).setRecipeName("emeraldCopper1"));

    ItemStack lapisCopper = defaultCopper.copy();
        lapisCopper.getTagCompound().setString("upgrades", "lapis");
        recipes.register (new CrucibleCrafting(
                new OreIngredient("ingotCopper"),
                new OreIngredient("gemLapis"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    lapisCopper,
            900,
            750,
            550).setRecipeName("lapisCopper1"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("oreCopper"),
                new OreIngredient("slackLime"),
            new OreIngredient("dustRedstone"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    redCopper,
            900,
            750,
            550).setRecipeName("redCopper2"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("oreCopper"),
                new OreIngredient("slackLime"),
            new OreIngredient("flakeDiamond"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    diamondCopper,
            900,
            750,
            550).setRecipeName("diamondCopper2"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("oreCopper"),
                new OreIngredient("slackLime"),
            new OreIngredient("flakeEmerald"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    emeraldCopper,
            900,
            750,
            550).setRecipeName("emeraldCopper2"));

        recipes.register (new CrucibleCrafting(
                new OreIngredient("oreCopper"),
                new OreIngredient("slackLime"),
            new OreIngredient("gemLapis"),
    Ingredient.EMPTY,
    Ingredient.EMPTY,
            new ItemStack(PrimalAPI.Items.SLAG, 1),
    lapisCopper,
            900,
            750,
            550).setRecipeName("lapisCopper2"));

    }
}