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

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

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

# -> If player is not holding a sharpened flint then return
execute unless items entity @s weapon.mainhand *[custom_data~{IsSharpenedFlint:1b}] run \
    return run \
        function overly_realistic:players/items/sharpened_flint/knapping/player_not_looking_at_rock

# -> Reset vars
scoreboard players reset #or.Raycast.RayRange OverlyRealistic.General.ArbitraryData
scoreboard players reset #or.is_looking_at_rock_sharpen_flint_knap 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/sharpened_flint/knapping/item_raycast_travel

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

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

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

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