import { system, world } from '@minecraft/server';
import { decrementStack, getOppositeDirection, DirectionType, cardinalSides, randomFunction } from './utils/helper';
import { directionToVector3 } from './utils/math';

world.beforeEvents.worldInitialize.subscribe(initEvent => {
  initEvent.blockComponentRegistry.registerCustomComponent('rk_block:trigger', {
  onPlayerDestroy: e => { e.dimension.runCommand(`execute positioned ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} run function rk_break_block_trigger`); },
});

initEvent.blockComponentRegistry.registerCustomComponent('rk_blue_berry_eaten:trigger', {
  onTick: e => { e.dimension.runCommand(`execute positioned ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} run function rk_berry_grow2`); },
});

initEvent.blockComponentRegistry.registerCustomComponent('rk_blue_berry:trigger', {
  onTick: e => { e.dimension.runCommand(`execute positioned ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} run function berry_tick`); },
onPlayerInteract: e => { e.dimension.runCommand(`execute positioned ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} run function rk_berry_player_destroy`); },
});

initEvent.blockComponentRegistry.registerCustomComponent('rk_blue_berry_grown:trigger', {
  onTick: e => { e.dimension.runCommand(`execute positioned ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} run function rk_berry_grow1`); },
});

initEvent.blockComponentRegistry.registerCustomComponent('rk_mold_killer:trigger', {
  onTick: e => { e.dimension.runCommand(`execute positioned ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} run function rk_mold_cleanse`); },
});

});
