
# -> Heated wrought iron operations
execute if entity @s[tag=OverlyRealistic.Player.HasHitHeatedWroughtIron] run \
    return run \
        function overly_realistic:general/custom_blocks/heated_wrought_iron/loop_operations/player_specific/hit_heated_wrought_iron_loop

# -> Forging Plate hit operate
execute if entity @s[tag=OverlyRealistic.Player.HasHitPlateWithForgingHammer] run \
    return run \
        function overly_realistic:general/custom_blocks/forging_plate/interactions/shaping_tool_forge_process/player_loop_operate

# -> Sharpened flint knap operate
execute if entity @s[tag=OverlyRealistic.Player.HasHitRockWithSharpenedFlint] run \
    return run \
        function overly_realistic:players/items/sharpened_flint/knapping/looping_logic/player_hit_rock_with_sharpened_flint

# -> If player does not have the flint flake usage tag then return
execute unless entity @s[tag=OverlyRealistic.Player.HasHitRockWithFlintFlake] run \
    return fail

# -> Add to time
scoreboard players add @s OverlyRealistic.Player.UseItem_FlintFlake_Time 1

# -> If time < max then return
execute unless score @s OverlyRealistic.Player.UseItem_FlintFlake_Time matches 2.. run \
    return fail

# -> If max amount of time is reached then return
execute if score @s OverlyRealistic.Player.UseItem_FlintFlake_BreakPower matches 7.. run \
    return run \
        function overly_realistic:players/items/flint_flake/player_not_looking_at_rock

# -> Reset vars
scoreboard players reset #or.Raycast.RayRange OverlyRealistic.General.ArbitraryData
scoreboard players reset #or.is_looking_at_rock OverlyRealistic.General.ArbitraryData
scoreboard players reset @s OverlyRealistic.Player.UseItem_FlintFlake_Time

# -> Get max block placement range
execute store result score #or.Raycast.RayRangeMax OverlyRealistic.General.ArbitraryData run \
    attribute @s minecraft:block_interaction_range get 10

# -> Raycast
execute anchored eyes \
    positioned ^ ^ ^ \
    anchored feet run \
        function overly_realistic:players/items/flint_flake/item_raycast_travel

# -> If player is not looking at a rock then return
execute unless score #or.is_looking_at_rock OverlyRealistic.General.ArbitraryData matches 1 run \
    return run \
        function overly_realistic:players/items/flint_flake/player_not_looking_at_rock

# -> Add to break power
scoreboard players add @s OverlyRealistic.Player.UseItem_FlintFlake_BreakPower 1

# -> Show break percentage
title @s times 0 35 40
title @s title ""

title @s[scores={OverlyRealistic.Player.UseItem_FlintFlake_BreakPower=..1}] subtitle [{text:"",extra:[{text:"\u0017",font:"overlyrealistic:icons"}],color:"#ffffff",shadow_color:0},{score:{name:"@s",objective:"OverlyRealistic.Player.UseItem_FlintFlake_BreakPercent"},color:"#40ca52",shadow_color:-15708648},{text:"%",color:"#40ca52",shadow_color:-15708648}]
title @s[scores={OverlyRealistic.Player.UseItem_FlintFlake_BreakPower=2}] subtitle [{text:"",extra:[{text:"\u0017",font:"overlyrealistic:icons"}],color:"#ffffff",shadow_color:0},{score:{name:"@s",objective:"OverlyRealistic.Player.UseItem_FlintFlake_BreakPercent"},color:"#ebd82d",shadow_color:-11647728},{text:"%",color:"#ebd82d",shadow_color:-11647728}]
title @s[scores={OverlyRealistic.Player.UseItem_FlintFlake_BreakPower=3}] subtitle [{text:"",extra:[{text:"\u0017",font:"overlyrealistic:icons"}],color:"#ffffff",shadow_color:0},{score:{name:"@s",objective:"OverlyRealistic.Player.UseItem_FlintFlake_BreakPercent"},color:"#fc7324",shadow_color:-11655408},{text:"%",color:"#fc7324",shadow_color:-11655408}]
title @s[scores={OverlyRealistic.Player.UseItem_FlintFlake_BreakPower=4..}] subtitle [{text:"",extra:[{text:"\u0017",font:"overlyrealistic:icons"}],color:"#ffffff",shadow_color:0},{score:{name:"@s",objective:"OverlyRealistic.Player.UseItem_FlintFlake_BreakPercent"},color:"#d62424",shadow_color:-11660784},{text:"%",color:"#d62424",shadow_color:-11660784}]
