package com.tiedup.remake.blocks.entity;

import com.tiedup.remake.blocks.ModBlocks;
import com.tiedup.remake.core.TiedUpMod;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

/**
 * Mod Block Entities Registration
 *
 *
 * Handles registration of all TiedUp block entities using DeferredRegister.
 */
public class ModBlockEntities {

    // DeferredRegister for block entity types
    public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES =
        DeferredRegister.create(
            ForgeRegistries.BLOCK_ENTITY_TYPES,
            TiedUpMod.MOD_ID
        );

    // TRAP BLOCK ENTITIES

    /**
     * Trap block entity - stores bondage items for rope trap.
     */
    public static final RegistryObject<BlockEntityType<TrapBlockEntity>> TRAP =
        BLOCK_ENTITIES.register("trap", () ->
            BlockEntityType.Builder.of(
                TrapBlockEntity::new,
                ModBlocks.ROPE_TRAP.get()
            ).build(null)
        );

    // LOW FIX: Removed BED BLOCK ENTITIES section - feature not implemented

    // BOMB BLOCK ENTITIES

    /**
     * Kidnap bomb block entity - stores bondage items for explosion effect.
     */
    public static final RegistryObject<
        BlockEntityType<KidnapBombBlockEntity>
    > KIDNAP_BOMB = BLOCK_ENTITIES.register("kidnap_bomb", () ->
        BlockEntityType.Builder.of(
            KidnapBombBlockEntity::new,
            ModBlocks.KIDNAP_BOMB.get()
        ).build(null)
    );

    // CHEST BLOCK ENTITIES

    /**
     * Trapped chest block entity - stores bondage items for when player opens it.
     */
    public static final RegistryObject<
        BlockEntityType<TrappedChestBlockEntity>
    > TRAPPED_CHEST = BLOCK_ENTITIES.register("trapped_chest", () ->
        BlockEntityType.Builder.of(
            TrappedChestBlockEntity::new,
            ModBlocks.TRAPPED_CHEST.get()
        ).build(null)
    );

    // CELL SYSTEM BLOCK ENTITIES

    /**
     * Marker block entity - stores cell UUID for cell system.
     */
    public static final RegistryObject<
        BlockEntityType<MarkerBlockEntity>
    > MARKER = BLOCK_ENTITIES.register("marker", () ->
        BlockEntityType.Builder.of(
            MarkerBlockEntity::new,
            ModBlocks.MARKER.get()
        ).build(null)
    );

    /**
     * Iron bar door block entity - stores lock state and key UUID.
     */
    public static final RegistryObject<
        BlockEntityType<IronBarDoorBlockEntity>
    > IRON_BAR_DOOR = BLOCK_ENTITIES.register("iron_bar_door", () ->
        BlockEntityType.Builder.of(
            IronBarDoorBlockEntity::new,
            ModBlocks.IRON_BAR_DOOR.get()
        ).build(null)
    );

    /**
     * Cell Core block entity - stores cell ID, spawn/delivery points, and disguise.
     */
    public static final RegistryObject<
        BlockEntityType<CellCoreBlockEntity>
    > CELL_CORE = BLOCK_ENTITIES.register("cell_core", () ->
        BlockEntityType.Builder.of(
            CellCoreBlockEntity::new,
            ModBlocks.CELL_CORE.get()
        ).build(null)
    );
}
