# ----

execute unless score @s y_level matches ..-1 run spawnpoint @s ~ ~2 ~ ~ ~
## while playing

execute if entity @s[gamemode=spectator,tag=playing] if score @s y_level matches ..-1 run tp @s ~ 0 ~

# ----

execute store result score @s y_level run data get entity @s Pos[1]
tag @s add temp
execute as @n[type=marker,tag=death_plane] if score @s y_level > @n[gamemode=!spectator,tag=temp] y_level as @n[gamemode=!spectator,tag=temp] at @s run function pctf:logic/player/fall
tag @s remove temp

execute if score @s death_count matches 1.. run function pctf:logic/player/death

execute if score @s spectator_time matches 1.. run function pctf:logic/player/spectator

execute if score @s kill_streak_timer matches 1.. run function pctf:logic/player/game/kill_streak

function pctf:logic/game/actionbar/main

execute if entity @s[tag=has_flag,team=blue] if block ~ ~-1 ~ minecraft:gold_block if entity @e[type=marker,tag=blue_flag_dropoff,distance=..2] run function pctf:logic/player/capture_flag/check_blue
execute if entity @s[tag=has_flag,team=red] if block ~ ~-1 ~ minecraft:gold_block if entity @e[type=marker,tag=red_flag_dropoff,distance=..2] run function pctf:logic/player/capture_flag/check_red

execute if score @s coins_to_add matches 1.. run function pctf:logic/player/coins/add
execute if score @s gems_to_add matches 1.. run function pctf:logic/player/gems/add

execute if score @s explosive_arrow_timer matches 1.. run function pctf:logic/items/lucky_block/effects/explosive_arrows/main

execute if entity @s[tag=floor_is_lava,tag=playing,gamemode=!spectator] unless block ~ ~-1 ~ #pctf:valid_floor run function pctf:logic/items/lucky_block/outcomes/global/floor_is_lava/hurt

execute if score @s dropped matches 1.. if entity @s[tag=playing] at @s run function pctf:logic/player/no_drop

execute if entity @s[tag=has_flag] run effect give @s minecraft:glowing 1 0 true

execute if items entity @s weapon.mainhand *[custom_data~{damage:1b}] if score @s spell_cooldown1 matches 1.. run function pctf:logic/items/spell1_on_cooldown
execute if items entity @s weapon.mainhand *[custom_data~{defence:1b}] if score @s spell_cooldown2 matches 1.. run function pctf:logic/items/spell2_on_cooldown
execute if items entity @s weapon.mainhand *[custom_data~{utility:1b}] if score @s spell_cooldown3 matches 1.. run function pctf:logic/items/spell3_on_cooldown

execute unless score @s time_warp_delay matches 1.. if items entity @s hotbar.* *[custom_data~{time_warp_scroll:1b}] run function pctf:logic/items/scrolls/time_warp/trail
execute if score @s time_warp_delay matches 1.. run function pctf:logic/items/scrolls/time_warp/warp_delay

# ----

execute if entity @s[gamemode=!spectator] if score @s y_level matches 150.. run function pctf:logic/player/out_of_bounds
execute if entity @s[gamemode=!spectator] if score @s y_level matches ..-1 run function pctf:logic/player/check_for_pearls

# ----