import {
    world,
    system
} from "@minecraft/server";

// hint_switcher_off

world.beforeEvents.worldInitialize.subscribe((data) => {
    const { itemComponentRegistry } = data
    itemComponentRegistry.registerCustomComponent("pm_m8:hint_switcher", {
        onUse: (data) => {
            const { source: sourceEntity } = data;

            if (!sourceEntity.hasTag('hint_switcher_off')) {
                sourceEntity.addTag('hint_switcher_off');
                sourceEntity.sendMessage('Mission hints: §cOFF§r');
                sourceEntity.runCommand('playsound random.xp @a ~~~');
            } else {
                sourceEntity.removeTag('hint_switcher_off');
                sourceEntity.sendMessage('Mission hints: §aON§r');
                sourceEntity.runCommand('playsound random.xp @a ~~~');
            }
        }
    })
});

