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

function getScore(objectiveName, player) {
    return world.scoreboard.getObjective(objectiveName)?.getScore(player.scoreboardIdentity);
}

world.afterEvents.itemUse.subscribe((event) => {
    if (event.itemStack.typeId == "zk:sacrificiallamb") {
        const player = event.source;
        let cd = getScore('chaosbcd', player);

        if (cd >= 200) {
            player.runCommand("function chaoscleaver/sacrificiallamb");
        }
        else if (cd < 200) {
            player.runCommand("function chaoscleaver/ccfr");
        }
    }
});