package net.halbear.aotg.registries;

import net.halbear.aotg.AgeoftheGods;
import net.halbear.aotg.custom.blocks.RockCoveredGrassBlock;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.neoforged.neoforge.registries.DeferredBlock;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.util.function.Function;

public class ModBlocks {
    public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(AgeoftheGods.MODID);

    public static final DeferredBlock<Block> LIMESTONE_BLOCK = RegisterBlock("limestone_block",
            properties -> new RockCoveredGrassBlock(properties.strength(1.5f)
                    .requiresCorrectToolForDrops()
                    .explosionResistance(6.0f)
                    .sound(SoundType.STONE)
                    .lightLevel(state -> 0)
            ));
    public static final DeferredBlock<Block> LIMESTONE_GRASS_BLOCK = RegisterBlock("limestone_grass_block",
            properties -> new RockCoveredGrassBlock(properties.strength(1.5f)
                    .requiresCorrectToolForDrops()
                    .explosionResistance(6.0f)
                    .sound(SoundType.GRASS)
                    .lightLevel(state -> 0)
            ));

    public static final DeferredBlock<Block> SHALE_BLOCK = RegisterBlock("shale_block",
            properties -> new RockCoveredGrassBlock(properties.strength(1.5f)
                    .requiresCorrectToolForDrops()
                    .explosionResistance(6.0f)
                    .sound(SoundType.STONE)
                    .lightLevel(state -> 0)
            ));
    public static final DeferredBlock<Block> SHALE_GRASS_BLOCK = RegisterBlock("shale_grass_block",
            properties -> new RockCoveredGrassBlock(properties.strength(1.5f)
                    .requiresCorrectToolForDrops()
                    .explosionResistance(6.0f)
                    .sound(SoundType.GRASS)
                    .lightLevel(state -> 0)
            ));

    private static <T extends Block> DeferredBlock<T> RegisterBlock(String Name, Function<BlockBehaviour.Properties, T> function){
        DeferredBlock<T> newBlock = BLOCKS.registerBlock(Name, function);
      //  RegisterBlockItem(Name, newBlock);
        return newBlock;
    }

    private static <T extends Block> void RegisterBlockItem(String Name, DeferredBlock<T> block){
        ModItems.ITEMS.registerItem(Name, p -> new BlockItem(block.get(), p.useBlockDescriptionPrefix()));
    }

}
