
# -> Set sheep exist success
scoreboard players set #or.sheep_exist_success OverlyRealistic.General.ArbitraryData 1

# -> Add to sheep shear time
scoreboard players add @s OverlyRealistic.Animal.SheepShearTime 1

# -> Add bonus to shear time if player is using iron shears
execute if score #or.player_using_iron_shears OverlyRealistic.General.ArbitraryData matches 1 run \
    scoreboard players add @s OverlyRealistic.Animal.SheepShearTime 2

# -> Reset success
scoreboard players set #or.sheep_shear_success OverlyRealistic.General.ArbitraryData 0

# -> Get sheep shear time max
scoreboard players operation @s OverlyRealistic.Animal.SheepShearTime_Max = @s OverlyRealistic.Animal.ScaleSize
scoreboard players add @s OverlyRealistic.Animal.SheepShearTime_Max 10
scoreboard players set @s[scores={OverlyRealistic.Animal.ScaleSize=..-10}] OverlyRealistic.Animal.SheepShearTime_Max 8

# -> If sheep shear time is over max then set success
execute if score @s OverlyRealistic.Animal.SheepShearTime >= @s OverlyRealistic.Animal.SheepShearTime_Max run \
    function overly_realistic:players/items/shears/sheep_shearing/shear_sheep_attempt_success

# -> Globalize value
scoreboard players operation #or.sheep_shear_time_global OverlyRealistic.General.ArbitraryData = @s OverlyRealistic.Animal.SheepShearTime
scoreboard players operation #or.sheep_shear_time_max_global OverlyRealistic.General.ArbitraryData = @s OverlyRealistic.Animal.SheepShearTime_Max

# -> Get sheep color
execute store result score @s OverlyRealistic.Animal.SheepColor run \
    data get entity @s Color

# --> Sheep color binary tree

# -> Branch 0
execute if score @s OverlyRealistic.Animal.SheepColor matches 0..3 run \
    return run \
        function overly_realistic:players/items/shears/sheep_shearing/sheep_shear_tree/branch_0

# -> Branch 1
execute if score @s OverlyRealistic.Animal.SheepColor matches 4..7 run \
    return run \
        function overly_realistic:players/items/shears/sheep_shearing/sheep_shear_tree/branch_1

# -> Branch 2
execute if score @s OverlyRealistic.Animal.SheepColor matches 8..11 run \
    return run \
        function overly_realistic:players/items/shears/sheep_shearing/sheep_shear_tree/branch_2

# -> Branch 3
execute if score @s OverlyRealistic.Animal.SheepColor matches 12..15 run \
    return run \
        function overly_realistic:players/items/shears/sheep_shearing/sheep_shear_tree/branch_3
