#Execute command while crouching if you have a specific item at hand

1 messages · Page 1 of 1 (latest)

tacit basalt
#

I'm creating a custom katana, and I'd like to know how to make it so that crouching, having the katana in hand, and using it (right-click) executes a command. I also want to make it so that using the katana without crouching executes a different command. Oh, and of course, I want the crouching attack to have a 20-second cooldown before it can be used again. Does anyone know how to do that?

visual trout
#
player.isSneaking
#
world.afterEvents.itemUse.subscribe((ev) => {
    const { itemStack,source } = ev
    if(itemStack.typeId == "minecraft:stick" && source.isSneaking) {
        console.log(`Used stick while crouching`)
    } 
})