package com.acethewildfire.acesbs.villager;

import com.acethewildfire.acesbs.AcesBS;
import com.acethewildfire.acesbs.block.ModBlocks;
import com.google.common.collect.ImmutableSet;
import net.fabricmc.fabric.api.object.builder.v1.world.poi.PointOfInterestHelper;
import net.minecraft.block.Block;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.village.VillagerProfession;
import net.minecraft.world.poi.PointOfInterestType;

public class ModVillagers {

    public static final RegistryKey<PointOfInterestType> BURNING_POI_KEY = registerPoiKey("burning_poi");
    public static final PointOfInterestType BURNING_POI = registerPOI("burning_poi", ModBlocks.INFERNAL_ASHES_BLOCK);

    public static final RegistryKey<VillagerProfession> BURNING_WIZARD_KEY =
            RegistryKey.of(RegistryKeys.VILLAGER_PROFESSION, Identifier.of(AcesBS.MOD_ID, "burning_wizard"));
    public static final VillagerProfession BURNING_WIZARD = registerProfession("burning_wizard", BURNING_POI_KEY);


    private static VillagerProfession registerProfession(String name, RegistryKey<PointOfInterestType> type) {
        return Registry.register(Registries.VILLAGER_PROFESSION, Identifier.of(AcesBS.MOD_ID, name),
                new VillagerProfession(Text.of(name),entry -> entry.matchesKey(type), entry -> entry.matchesKey(type),
                        ImmutableSet.of(), ImmutableSet.of(), SoundEvents.ENTITY_VILLAGER_WORK_LIBRARIAN));
    }

    private static PointOfInterestType registerPOI(String name, Block block) {
        return PointOfInterestHelper.register(Identifier.of(AcesBS.MOD_ID, name),
                1, 1, block);
    }

    private static RegistryKey<PointOfInterestType> registerPoiKey(String name) {
        return RegistryKey.of(RegistryKeys.POINT_OF_INTEREST_TYPE, Identifier.of(AcesBS.MOD_ID, name));
    }


    public static void registerVillagers (){
        AcesBS.LOGGER.info("Registering Mod Villagers for " + AcesBS.MOD_ID);
    }

}
