################################################################################################
#
# Swing
#
################################################################################################

scoreboard objectives add swing_timer dummy
scoreboard objectives add is_moving dummy
scoreboard objectives add swing_speed dummy
scoreboard objectives add swing_rot dummy
scoreboard objectives add swing_dir dummy
scoreboard objectives add constant dummy

scoreboard players set 500 constant 500
scoreboard players set 150 constant 150
scoreboard players set 100 constant 100
scoreboard players set 70 constant 70
scoreboard players set 50 constant 50
scoreboard players set 47 constant 47
scoreboard players set 35 constant 35
scoreboard players set 30 constant 30
scoreboard players set 10 constant 10
scoreboard players set 5 constant 5
scoreboard players set 3 constant 3
scoreboard players set 2 constant 2
scoreboard players set -1 constant -1


scoreboard objectives add ET dummy
scoreboard objectives add ET dummy

scoreboard players add @s swing_dir 0
#----------------------------------- Speed 1 ---------------------------------------#
scoreboard players add @s[scores={is_moving=1..,swing_speed=0,swing_dir=0,swing_timer=-500..500}] swing_timer 70
scoreboard players remove @s[scores={is_moving=1..,swing_speed=0,swing_dir=1,swing_timer=-500..500}] swing_timer 70

scoreboard players add @s[scores={is_moving=1..,swing_speed=0,swing_dir=0,swing_timer=-800..-501}] swing_timer 60
scoreboard players remove @s[scores={is_moving=1..,swing_speed=0,swing_dir=1,swing_timer=-800..-501}] swing_timer 60
scoreboard players add @s[scores={is_moving=1..,swing_speed=0,swing_dir=0,swing_timer=..-801}] swing_timer 50
scoreboard players remove @s[scores={is_moving=1..,swing_speed=0,swing_dir=1,swing_timer=..-801}] swing_timer 50

scoreboard players add @s[scores={is_moving=1..,swing_speed=0,swing_dir=0,swing_timer=501..800}] swing_timer 60
scoreboard players remove @s[scores={is_moving=1..,swing_speed=0,swing_dir=1,swing_timer=501..800}] swing_timer 60
scoreboard players add @s[scores={is_moving=1..,swing_speed=0,swing_dir=0,swing_timer=801..}] swing_timer 50
scoreboard players remove @s[scores={is_moving=1..,swing_speed=0,swing_dir=1,swing_timer=801..}] swing_timer 50



scoreboard players add @s[scores={is_moving=0,swing_speed=0,swing_timer=..-41}] swing_timer 40
scoreboard players remove @s[scores={is_moving=0,swing_speed=0,swing_timer=41..}] swing_timer 40
scoreboard players set @s[scores={is_moving=0,swing_speed=0,swing_timer=-40..40}] swing_timer 0





scoreboard players set @s[scores={swing_timer=1000..,swing_dir=0}] swing_dir 1
scoreboard players set @s[scores={swing_timer=..-1000,swing_dir=1}] swing_dir 0

scoreboard players operation @s swing_rot = @s swing_timer

scoreboard players operation @s swing_rot *= 2 constant
scoreboard players operation @s swing_rot /= 5 constant
scoreboard players operation @s swing_rot /= 10 constant
#scoreboard players operation @s[tag=inv] swing_rot *= -1 constant


execute store result entity @s Pose.Head[0] float 1 run scoreboard players get @s swing_rot
execute store result entity @s Rotation[1] float 1 run scoreboard players get @s swing_rot







##
