
# -> If table has paper already then return
execute if entity @s[tag=OverlyRealistic.Block.ScribingTable_HasPaper] run \
    return fail

# -> Sound
playsound overlyrealistic:block.scribing_table.paper_insert block @a ~ ~ ~ 0.5 1

# -> Add paper tag
tag @s add OverlyRealistic.Block.ScribingTable_HasPaper

# -> Set paper
execute on passengers run \
    item modify entity @s[tag=OverlyRealistic.Block.ScribingTable_Base] contents overly_realistic:scribing_table/set_model/set_paper

# -> Set writing position to 0
execute on passengers run \
    item modify entity @s[tag=OverlyRealistic.Block.ScribingTable_Base] contents overly_realistic:scribing_table/set_model/reset_writing_symbols
execute on passengers run \
    item modify entity @s[tag=OverlyRealistic.Block.ScribingTable_Base] contents overly_realistic:scribing_table/set_model/set_writing_pos_0
scoreboard players set @s OverlyRealistic.World.ScribingTable_WritingPosition 0

# -> Advancement
execute on target run \
    advancement grant @s only overly_realistic:advancements/scribing_table_uses/paper_please

# -> Remove player's item if possible
execute on target run \
    item modify entity @s[gamemode=!creative] weapon.mainhand overly_realistic:multipurpose/remove_one_item
