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('future_siliconium_chipset_block:trigger', {
  onPlayerDestroy: e => { const equippable = e.player.getComponent("minecraft:equippable");
    if (!equippable) return;

    const mainhand = equippable.getEquipmentSlot("Mainhand");
    if (!mainhand.hasItem()) return;

    const itemTags = mainhand.getTags();
    const toolTags = ["minecraft:is_pickaxe"];

    if (!itemTags.some(item => toolTags.includes(item))) return;
    
    e.dimension.runCommand(`execute positioned ${e.block.location.x} ${e.block.location.y} ${e.block.location.z} run loot spawn ~~~ loot "blocks/future_siliconium_chipset_block"`); },
});

});
