import * as Minecraft from "mojang-minecraft"

Minecraft.world.events.tick.subscribe((tick) => {
    for (const player of Minecraft.world.getPlayers()) {
        if (player.isSneaking) {
            player.runCommand(`scoreboard players set @s r_sneak 1`)
        } else {
            player.runCommand(`scoreboard players set @s r_sneak 0`)
        }
    }
})

Minecraft.world.events.tick.subscribe((tick) => {
    for (const player of Minecraft.world.getPlayers()) {
        if (player.getComponent("minecraft:health").current == 0) {
            player.runCommand(`scoreboard players set @s r_die 1`)
        } else {
            player.runCommand(`scoreboard players set @s r_die 0`)
        }
    }
})

