package moe.hazu.tinkeringabnormally.data.material;

import com.teamabnormals.atmospheric.core.other.tags.AtmosphericItemTags;
import com.teamabnormals.atmospheric.core.registry.AtmosphericBlocks;
import com.teamabnormals.caverns_and_chasms.core.other.tags.CCItemTags;
import com.teamabnormals.caverns_and_chasms.core.registry.CCBlocks;
import com.teamabnormals.environmental.core.other.tags.EnvironmentalBlockTags;
import com.teamabnormals.environmental.core.other.tags.EnvironmentalItemTags;
import com.teamabnormals.environmental.core.registry.EnvironmentalBlocks;
import com.teamabnormals.upgrade_aquatic.core.UpgradeAquatic;
import com.teamabnormals.upgrade_aquatic.core.registry.UABlocks;
import moe.hazu.tinkeringabnormally.TinkeringAbnormally;
import net.minecraft.core.Registry;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.Ingredient;
import slimeknights.mantle.recipe.helper.ItemOutput;
import slimeknights.tconstruct.library.data.recipe.IMaterialRecipeHelper;

import java.util.function.Consumer;

public class MaterialRecipeProvider extends RecipeProvider implements IMaterialRecipeHelper {
    public MaterialRecipeProvider(DataGenerator generator) {
        super(generator);
    }

    @Override
    public String getName() {
        return "Tinkering Abnormally Material Recipe";
    }

    @Override
    public String getModId() {
        return TinkeringAbnormally.MODID;
    }

    @Override
    protected void buildCraftingRecipes(Consumer<FinishedRecipe> consumer) {
        addMaterialItems(consumer);
    }

    private void addMaterialItems(Consumer<FinishedRecipe> consumer) {
        String folder = "tools/materials/";
        materialRecipe(consumer, MaterialIds.willow, Ingredient.of(EnvironmentalBlocks.WILLOW_PLANKS.get()), 1, 1, folder + "wood/planks/willow");
        materialRecipe(consumer, MaterialIds.pine, Ingredient.of(EnvironmentalBlocks.PINE_PLANKS.get()), 1, 1, folder + "wood/planks/pine");
        materialRecipe(consumer, MaterialIds.cherry, Ingredient.of(EnvironmentalBlocks.CHERRY_PLANKS.get()), 1, 1, folder + "wood/planks/cherry");
        materialRecipe(consumer, MaterialIds.wisteria, Ingredient.of(EnvironmentalBlocks.WISTERIA_PLANKS.get()), 1, 1, folder + "wood/planks/wisteria");
        materialRecipe(consumer, MaterialIds.rosewood, Ingredient.of(AtmosphericBlocks.ROSEWOOD_PLANKS.get()), 1, 1, folder + "wood/planks/rosewood");
        materialRecipe(consumer, MaterialIds.morado, Ingredient.of(AtmosphericBlocks.MORADO_PLANKS.get()), 1, 1, folder + "wood/planks/morado");
        materialRecipe(consumer, MaterialIds.yucca, Ingredient.of(AtmosphericBlocks.YUCCA_PLANKS.get()), 1, 1, folder + "wood/planks/yucca");
        materialRecipe(consumer, MaterialIds.aspen, Ingredient.of(AtmosphericBlocks.ASPEN_PLANKS.get()), 1, 1, folder + "wood/planks/aspen");
        materialRecipe(consumer, MaterialIds.laurel, Ingredient.of(AtmosphericBlocks.LAUREL_PLANKS.get()), 1, 1, folder + "wood/planks/laurel");
        materialRecipe(consumer, MaterialIds.kousa, Ingredient.of(AtmosphericBlocks.KOUSA_PLANKS.get()), 1, 1, folder + "wood/planks/kousa");
        materialRecipe(consumer, MaterialIds.grimwood, Ingredient.of(AtmosphericBlocks.GRIMWOOD_PLANKS.get()), 1, 1, folder + "wood/planks/grimwood");
        materialRecipe(consumer, MaterialIds.driftwood, Ingredient.of(UABlocks.DRIFTWOOD_PLANKS.get()), 1, 1, folder + "wood/planks/driftwood");
        materialRecipe(consumer, MaterialIds.river, Ingredient.of(UABlocks.RIVER_PLANKS.get()), 1, 1, folder + "wood/planks/river");
        materialRecipe(consumer, MaterialIds.azalea, Ingredient.of(CCBlocks.AZALEA_PLANKS.get()), 1, 1, folder + "wood/planks/azalea");
        materialRecipe(consumer, MaterialIds.willow, Ingredient.of(EnvironmentalItemTags.WILLOW_LOGS), 4, 1, ItemOutput.fromItem(EnvironmentalBlocks.WILLOW_PLANKS.get()), folder + "wood/logs/willow");
        materialRecipe(consumer, MaterialIds.pine, Ingredient.of(EnvironmentalItemTags.PINE_LOGS), 4, 1, ItemOutput.fromItem(EnvironmentalBlocks.PINE_PLANKS.get()), folder + "wood/logs/pine");
        materialRecipe(consumer, MaterialIds.cherry, Ingredient.of(EnvironmentalItemTags.CHERRY_LOGS), 4, 1, ItemOutput.fromItem(EnvironmentalBlocks.CHERRY_PLANKS.get()), folder + "wood/logs/cherry");;
        materialRecipe(consumer, MaterialIds.wisteria, Ingredient.of(EnvironmentalItemTags.WISTERIA_LOGS), 4, 1, ItemOutput.fromItem(EnvironmentalBlocks.WISTERIA_PLANKS.get()), folder + "wood/logs/wisteria");
        materialRecipe(consumer, MaterialIds.rosewood, Ingredient.of(AtmosphericItemTags.ROSEWOOD_LOGS), 4, 1, ItemOutput.fromItem(AtmosphericBlocks.ROSEWOOD_PLANKS.get()), folder + "wood/logs/rosewood");
        materialRecipe(consumer, MaterialIds.morado, Ingredient.of(AtmosphericItemTags.MORADO_LOGS), 4, 1, ItemOutput.fromItem(AtmosphericBlocks.MORADO_PLANKS.get()), folder + "wood/logs/morado");
        materialRecipe(consumer, MaterialIds.yucca, Ingredient.of(AtmosphericItemTags.YUCCA_LOGS), 4, 1, ItemOutput.fromItem(AtmosphericBlocks.YUCCA_PLANKS.get()), folder + "wood/logs/yucca");
        materialRecipe(consumer, MaterialIds.aspen, Ingredient.of(AtmosphericItemTags.ASPEN_LOGS), 4, 1, ItemOutput.fromItem(AtmosphericBlocks.ASPEN_PLANKS.get()), folder + "wood/logs/aspen");
        materialRecipe(consumer, MaterialIds.laurel, Ingredient.of(AtmosphericItemTags.LAUREL_LOGS), 4, 1, ItemOutput.fromItem(AtmosphericBlocks.LAUREL_PLANKS.get()), folder + "wood/logs/laurel");
        materialRecipe(consumer, MaterialIds.kousa, Ingredient.of(AtmosphericItemTags.KOUSA_LOGS), 4, 1, ItemOutput.fromItem(AtmosphericBlocks.KOUSA_PLANKS.get()), folder + "wood/logs/kousa");
        materialRecipe(consumer, MaterialIds.grimwood, Ingredient.of(AtmosphericItemTags.GRIMWOOD_LOGS), 4, 1, ItemOutput.fromItem(AtmosphericBlocks.GRIMWOOD_PLANKS.get()), folder + "wood/logs/grimwood");
        materialRecipe(consumer, MaterialIds.driftwood, Ingredient.of(TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(UpgradeAquatic.MOD_ID, "driftwood_logs"))), 4, 1, ItemOutput.fromItem(EnvironmentalBlocks.WILLOW_PLANKS.get()), folder + "wood/logs/driftwood");
        materialRecipe(consumer, MaterialIds.river, Ingredient.of(TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(UpgradeAquatic.MOD_ID, "river_logs"))), 4, 1, ItemOutput.fromItem(EnvironmentalBlocks.WILLOW_PLANKS.get()), folder + "wood/logs/river");
        materialRecipe(consumer, MaterialIds.azalea, Ingredient.of(CCItemTags.AZALEA_LOGS), 4, 1, ItemOutput.fromItem(CCBlocks.AZALEA_PLANKS.get()), folder + "wood/logs/azalea");
    }
}
