import {world} from "@minecraft/server"

world.afterEvents.itemUse.subscribe(eventData => {
    const item = eventData.itemStack
    const player = eventData.source
    const type_id = item.typeId;

    if (type_id.includes('book')) {
        player.runCommand(`execute if entity @s[scores={cubc_mo_en_book_cd=0}] run function cubc/mo_en/book/previous_page`);
        player.runCommand(`scoreboard players set @s[scores={cubc_mo_en_book_cd=0}] cubc_mo_en_book_cd 6`);
    }
})
