#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#
#    This function has been created by Skilendarz Group.
#             https://skilendarz.com
#
#      GIVE MAP MAKERS THE CREDIT THEY DESERVE!
#             COPYING IS PROHIBITED!
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#Per tick
tag @a[tag=player,gamemode=!spectator,scores={kill-timer=0}] add compass_compatible
item replace block 14 107 -23 container.0 with compass{HideFlags:6,display:{Name:'{"translate":"compass.name","color":"gold","bold":true,"italic":false}'},LodestoneTracked:0b,LodestonePos:{X:0.0d,Y:0.0d,Z:0.0d},LodestoneDimension:"overworld",AttributeModifiers:[{AttributeName:"generic.attack_speed",Amount:-4,Name:"generic.attack_speed",UUID:[I;-122626,11713,112933,-23426]}]}
execute as @a[tag=compass_compatible] at @s run function f:game/compass/tick

#Switch Compass
scoreboard players set @a[tag=!hold_compass] click 0
execute if score $game_type main matches 3 run scoreboard players set @a click 0
execute as @a[scores={click=1}] run function f:game/compass/switch

#Loop
scoreboard players set 4 id 4
execute store result score compass_async id if entity @a[tag=compass_compatible]
scoreboard players add compass_async time 1
scoreboard players operation compass_async id -= compass_async time
scoreboard players operation compass_async id /= 4 id

#Compass
execute as @a[tag=compass_compatible,tag=!compass_async,limit=1] at @s run function f:game/compass/compass

#Reser loop
execute if score compass_async time matches 4 as @a[tag=compass_compatible,tag=!compass_async] at @s run function f:game/compass/compass
execute if score compass_async time matches 4 run tag @a remove compass_async
execute if score compass_async time matches 4.. run scoreboard players set compass_async time 0

#No target
execute as @a[tag=no_compass_target,tag=compass_compatible] run function f:game/compass/no_target

tag @a[team=seeker] remove hold_compass
tag @a remove compass_compatible