
# --> Interaction binary tree

# -> Progression 0 (tool head)
execute if score #or.tool_handle_progress OverlyRealistic.General.ArbitraryData matches 0 run \
    return run \
        execute if items entity @s weapon.mainhand *[custom_data~{IsToolPart:1b}] run \
            function overly_realistic:general/custom_blocks/tool_handle/interaction_events/progress_0/player_place_tool_head

# -> Progression 1 (cordage)
execute if score #or.tool_handle_progress OverlyRealistic.General.ArbitraryData matches 1 run \
    execute if items entity @s weapon.mainhand #overly_realistic:tool_handle_cordage run \
        return run \
            function overly_realistic:general/custom_blocks/tool_handle/interaction_events/progress_1/player_place_cordage
#execute if score #or.tool_handle_progress OverlyRealistic.General.ArbitraryData matches 1 run \
    return run \
        execute if items entity @s weapon.mainhand *[custom_data~{IsToolPart:1b}] run \
            function overly_realistic:general/custom_blocks/tool_handle/interaction_events/progress_0/player_place_tool_head

# -> Progression 2 (adhesive)
execute if score #or.tool_handle_progress OverlyRealistic.General.ArbitraryData matches 2 run \
    execute if items entity @s weapon.mainhand #overly_realistic:tool_handle_adhesive run \
        return run \
            function overly_realistic:general/custom_blocks/tool_handle/interaction_events/progress_2/player_place_adhesive
execute if score #or.tool_handle_progress OverlyRealistic.General.ArbitraryData matches 2 run \
    execute if items entity @s weapon.mainhand *[custom_data~{or_adhesive_item:1b}] run \
        return run \
            function overly_realistic:general/custom_blocks/tool_handle/interaction_events/progress_2/player_place_adhesive
execute if score #or.tool_handle_progress OverlyRealistic.General.ArbitraryData matches 2 run \
    execute unless items entity @s weapon.mainhand * run \
        return run \
            function overly_realistic:general/custom_blocks/tool_handle/interaction_events/progress_2/player_skip_adhesive

# -> Progression 3 (completion)
execute unless score #or.tool_handle_progress OverlyRealistic.General.ArbitraryData matches 3 run \
    return fail
advancement grant @s only overly_realistic:advancements/stone_age/cant_handle_this_family/true_craftsmanship
function overly_realistic:players/wisdom/blacksmithing/add_to_skill_xp_c_craft_equipment
scoreboard players set #or.tool_handle_interaction_type OverlyRealistic.General.ArbitraryData 3
