package com.acethewildfire.acesbs.enchantment;

import com.acethewildfire.acesbs.AcesBS;
import com.acethewildfire.acesbs.enchantment.custom.LightningStrikeEnchantmentEffect;
import net.minecraft.component.EnchantmentEffectComponentTypes;
import net.minecraft.component.type.AttributeModifierSlot;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.effect.EnchantmentEffectTarget;
import net.minecraft.registry.Registerable;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.util.Identifier;


public class ModEnchantments {

    public static final RegistryKey<Enchantment> LIGHTNING_STRIKE =
            RegistryKey.of(RegistryKeys.ENCHANTMENT, Identifier.of(AcesBS.MOD_ID, "lightning_strike"));

    public static void bootstrap(Registerable<Enchantment> registerable){
        var enchantments = registerable.getRegistryLookup(RegistryKeys.ENCHANTMENT);
        var items = registerable.getRegistryLookup(RegistryKeys.ITEM);

        register(registerable, LIGHTNING_STRIKE, Enchantment.builder(Enchantment.definition(
            items.getOrThrow(ItemTags.BOW_ENCHANTABLE),
            5,
            2,
            Enchantment.leveledCost(5, 7),
            Enchantment.leveledCost(25, 9),
            2,
            AttributeModifierSlot.MAINHAND
        ))
            .addEffect(
                EnchantmentEffectComponentTypes.POST_ATTACK,
                EnchantmentEffectTarget.ATTACKER, EnchantmentEffectTarget.VICTIM,
                new LightningStrikeEnchantmentEffect()));
    }

    private static void register(Registerable<Enchantment> registry, RegistryKey<Enchantment> key, Enchantment.Builder builder){
        registry.register(key, builder.build(key.getValue()));
    }

//    public static void registerModEnchantments(){
//        AcesBS.LOGGER.info("Registering Mod Enchantments for " + AcesBS.MOD_ID);
//    }
}
