
# -> Reset adv trigger
advancement revoke @s only overly_realistic:items/use_sharpened_flint

# -> If player has a stick in one of their hands then return and sharpen it
execute if items entity @s weapon.* stick run \
    return run \
        function overly_realistic:players/items/sharpened_flint/sharpened_stick/sharpen_stick_with_flint

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

# -> If time >= max then rotate
execute unless score @s OverlyRealistic.Player.UseItem_SharpenedFlint_RotateTime matches 20.. run \
    return fail

# -> Reset rotate time
scoreboard players reset @s OverlyRealistic.Player.UseItem_SharpenedFlint_RotateTime

# -> If player is knapping the sharpened flint then operate
execute if entity @s[tag=OverlyRealistic.Player.HasHitRockWithSharpenedFlint] run \
    function overly_realistic:players/items/sharpened_flint/knapping/player_rotate_sharpened_flint

# -> Advancement
advancement grant @s only overly_realistic:advancements/stone_age/flipping_it

# -> If item is in the mainhand then return and operate
execute if items entity @s weapon.mainhand *[custom_data~{IsSharpenedFlint:1b}] run \
    return run \
        function overly_realistic:players/items/sharpened_flint/rotate_sharpened_flint/rotate_flint_in_mainhand

# -> Rotate item
execute if items entity @s weapon.offhand *[item_model="overlyrealistic:items/sharpened_flint/sharpened_flint_0"] run \
    return run \
        item modify entity @s weapon.offhand overly_realistic:items/sharpened_flint/flint_1
execute if items entity @s weapon.offhand *[item_model="overlyrealistic:items/sharpened_flint/sharpened_flint_1"] run \
    return run \
        item modify entity @s weapon.offhand overly_realistic:items/sharpened_flint/flint_2
execute if items entity @s weapon.offhand *[item_model="overlyrealistic:items/sharpened_flint/sharpened_flint_2"] run \
    return run \
        item modify entity @s weapon.offhand overly_realistic:items/sharpened_flint/flint_3
execute if items entity @s weapon.offhand *[item_model="overlyrealistic:items/sharpened_flint/sharpened_flint_3"] run \
    return run \
        item modify entity @s weapon.offhand overly_realistic:items/sharpened_flint/flint_0
