package net.halbear.aotg.registries;

import net.halbear.aotg.AgeoftheGods;
import net.halbear.aotg.custom.blocks.AlloyFurnace.AlloyFurnaceMultiBlock;
import net.halbear.aotg.custom.blocks.Forge.ForgeWorkbench;
import net.halbear.aotg.custom.blocks.RockCoveredGrassBlock;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RotatedPillarBlock;
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)
                    .explosionResistance(6.0f)
                    .sound(SoundType.GRASS)
                    .lightLevel(state -> 0)

            ));

    public static final DeferredBlock<Block> OLIVE_LOG = RegisterBlock("olive_log",
            properties -> new RotatedPillarBlock(properties.strength(0.5f)
                    .requiresCorrectToolForDrops()
                    .explosionResistance(1.0f)
                    .sound(SoundType.WOOD)
                    .lightLevel(state -> 0)
            ));


    public static final DeferredBlock<Block> OLIVE_LEAVES = RegisterBlock("olive_leaves",
            properties -> new RockCoveredGrassBlock(properties.strength(0.15f)
                    .requiresCorrectToolForDrops()
                    .explosionResistance(0.5f)
                    .sound(SoundType.GRASS)
                    .lightLevel(state -> 0)
                    .noOcclusion()
            ));

    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)
            ));
    public static final DeferredBlock<Block> ALLOY_FURNACE = RegisterBlock("alloy_furnace",
            properties -> new AlloyFurnaceMultiBlock(properties.strength(1.5f)
                    .requiresCorrectToolForDrops()
                    .explosionResistance(6.0f)
                    .sound(SoundType.DEEPSLATE_BRICKS)
                    .lightLevel(state -> 0)
            ));
    public static final DeferredBlock<Block> FORGE_WORKBENCH = RegisterBlock("forge",
            properties -> new ForgeWorkbench(properties.strength(1.5f)
                    .requiresCorrectToolForDrops()
                    .explosionResistance(6.0f)
                    .sound(SoundType.ANVIL)
                    .noOcclusion()
                    .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()));
    }

}
