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={book_cd=0}] run function book/next_page`);
        player.runCommand(`scoreboard players set @s[scores={book_cd=0}] book_cd 6`);
    }
})
