# Item cooldown
scoreboard objectives add cubc_ra_su_item_cooldown dummy
scoreboard players add @a cubc_ra_su_item_cooldown 0
scoreboard players add @a[scores={cubc_ra_su_item_cooldown=1..}] cubc_ra_su_item_cooldown -1

# Check who has a book
tag @a remove cubc_ra_su_has_book
function cubc/ra_su/book/has_book

# Claim a book
tag @e[type=cubc_ra_su:book] remove cubc_ra_su_claimed
execute as @a[tag=cubc_ra_su_has_book] at @s anchored eyes positioned ^^^0.5 if entity @e[r=5, c=1, type=cubc_ra_su:book, tag=!cubc_ra_su_claimed] run function cubc/ra_su/book/claim
execute as @a[tag=cubc_ra_su_has_book] at @s anchored eyes positioned ^^^0.5 unless entity @e[r=5, c=1, type=cubc_ra_su:book, tag=cubc_ra_su_claimed] run function cubc/ra_su/book/summon

# Delete useless books
event entity @e[type=cubc_ra_su:book, tag=!cubc_ra_su_claimed] cubc_ra_su:despawn

# Go next page
title @a[tag=cubc_ra_su_has_book] actionbar Attack: §3Previous§f | Interact: §6Next§f