package com.acethewildfire.acesbs.component;

import com.acethewildfire.acesbs.AcesBS;
import com.mojang.serialization.Codec;
import net.minecraft.component.ComponentType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;

import java.util.function.UnaryOperator;

public class ModDataComponentTypes {

    public static final ComponentType<BlockPos> COORDINATES =
            register("coordinates", blockPosBuilder -> blockPosBuilder.codec(BlockPos.CODEC));

    public static final ComponentType<Boolean> SMOKING =
            register("smoking", booleanBuilder -> booleanBuilder.codec(Codec.BOOL));

    private static <T>ComponentType<T> register(String name, UnaryOperator<ComponentType.Builder<T>> builderOperator){
        return Registry.register(Registries.DATA_COMPONENT_TYPE, Identifier.of(AcesBS.MOD_ID, name),
                builderOperator.apply(ComponentType.builder()).build());
    }

    public static void registerDataComponentsTypes(){
        AcesBS.LOGGER.info("Registering Data Components Types for" + AcesBS.MOD_ID);
    }
}
