package com.r3944realms.leashedplayer.datagen.provider;

import com.r3944realms.leashedplayer.content.items.ModItemRegister;
import com.r3944realms.leashedplayer.content.items.repcipe.TippedLeashRopeArrowRecipe;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.RecipeOutput;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.data.recipes.SpecialRecipeBuilder;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.CompletableFuture;

public class ModRecipeProvider extends RecipeProvider {
    public ModRecipeProvider(HolderLookup.Provider registries, RecipeOutput output) {
        super(registries, output);
    }

    @Override
    protected void buildRecipes() {
        this.shapeless(RecipeCategory.MISC, ModItemRegister.LEASH_ROPE_ARROW.get(), 1)
                .requires(Items.LEAD)
                .requires(Items.ARROW)
                .unlockedBy("has_lead",has(Items.LEAD))
                .save(this.output);
        this.shapeless(RecipeCategory.MISC, ModItemRegister.SPECTRAL_LEASH_ROPE_ARROW.get(),1)
                .requires(Items.LEAD)
                .requires(Items.SPECTRAL_ARROW)
                .unlockedBy("has_lead",has(Items.LEAD))
                .unlockedBy("has_spectral_arrow",has(Items.SPECTRAL_ARROW))
                .save(this.output);
        this.shaped(RecipeCategory.MISC, ModItemRegister.SPECTRAL_LEASH_ROPE_ARROW.get(),1)
                .pattern(" $ ")
                .pattern("$#$")
                .pattern(" $ ")
                .define('#', ModItemRegister.LEASH_ROPE_ARROW.get())
                .define('$', Items.GLOWSTONE_DUST)
                .unlockedBy("has_lead",has(Items.LEAD))
                .unlockedBy("has_glowstone_dust",has(Items.GLOWSTONE_DUST))
                .save(this.output,"leash_rope_arrow_shape");
        this.shaped(RecipeCategory.MISC, ModItemRegister.AMETHYST_SHEARS.get(),1)
                .pattern("#%")
                .pattern("%#")
                .define('#', Items.AMETHYST_SHARD)
                .define('%', Items.STICK)
                .unlockedBy("has_amethyst_shard",has(Items.AMETHYST_SHARD))
                .save(this.output);
        SpecialRecipeBuilder.special(TippedLeashRopeArrowRecipe.TippedLeashRopeArrowARecipe::new).save(this.output, "tipped_leash_rope_arrow_a");
        SpecialRecipeBuilder.special(TippedLeashRopeArrowRecipe.TippedLeashRopeArrowBRecipe::new).save(this.output, "tipped_leash_rope_arrow_b");
    }
    public static class Runner extends RecipeProvider.Runner {

        public Runner(PackOutput pPackOutput, CompletableFuture<HolderLookup.Provider> providerCompletableFuture) {
            super(pPackOutput, providerCompletableFuture);
        }

        @Override
        @NotNull
        public RecipeProvider createRecipeProvider(HolderLookup.@NotNull Provider provider, @NotNull RecipeOutput output) {
            return new ModRecipeProvider(provider, output);
        }

        @Override
        public @NotNull String getName() {
            return "LeashedPlayer Recipes";
        }
    }


}