import {world} from "@minecraft/server";
import {BlockBehavior} from "../modules/blockModule";
import {VisualEffectBlock} from "../modules/class/blocks/visualEffectBlock";
import {ConditionCheckBlock} from '../modules/class/blocks/conditionCheckBlock';

export function registerBlocks() {
    BlockBehavior.registerSubclass("visualEffects", VisualEffectBlock)
    BlockBehavior.registerSubclass("conditionCheck", ConditionCheckBlock);
    BlockBehavior.register({
        id: "cubed:solarite_day",
        conditionCheck: {
            events: [
                {
                    event: (block) => {
                        if (world.getTimeOfDay() > 13000) {
                            block.dimension.setBlockType(block.location, "cubed:solarite_night");
                        }
                    },
                    condition: (block) => true
                }
            ]
        },
        visualEffects: {
            sound: {
                id: "cc:big_foot_growl",
                interval: 10,
                chance: 0.5,
            },
            particles: [
                {
                    id: "cc:beam",
                    chance: 1,
                    interval: 2,
                }
            ],
            conditions: (block) => true
        }
    });
    BlockBehavior.register({
        id: "cubed:solarite_night",
        conditionCheck: {
            events: [
                {
                    event: (block) => {
                        if (world.getTimeOfDay() <= 13000) {
                            block.dimension.setBlockType(block.location, "cubed:solarite_day");
                        }
                    },
                    condition: (block) => true
                }
            ]
        }
    });
    BlockBehavior.initialize();
}
