import { world, system } from '@minecraft/server';
import { blockTicks } from './ticksConfig.js';
import { functionTicks } from './ticksConfig.js';

system.beforeEvents.startup.subscribe((data) => {
    data.blockComponentRegistry.registerCustomComponent('thini:verification', {

        onTick: ((e) => {
            const { block } = e;
            const { x, y, z } = block.location;

            for (let i = 0; i < blockTicks.length; i++) {
                if (block.typeId == blockTicks[i]) {
                    block.dimension.runCommand(`execute positioned ${x} ${y} ${z} run function ${functionTicks[i]}`);
                };
            };

        })

    });
});