import  { world, system } from '@minecraft/server';
import { blocosMissoes } from'./Mission_config.js';
import { functionMissoes } from'./Mission_config.js';


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

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

            if (entity.typeId == 'minecraft:player') {
                for (let i = 0; i < blocosMissoes.length; i++) {
                    if (block.typeId == blocosMissoes[i]) {
                        block.dimension.runCommand(`execute positioned ${x} ${y} ${z} run function ${functionMissoes[i]}`);
                    };
                };
            };
        })

    });
});