
execute as @e[type=minecraft:falling_block,tag=1] at @s run data merge entity @s {Time:1b}

execute positioned 10 -13 55 run tp @e[type=minecraft:shulker,distance=..10] ~ ~-10000 ~
execute positioned 10 -13 55 run kill @e[type=minecraft:armor_stand,distance=..5]
execute positioned 10 -13 55 run kill @e[type=minecraft:falling_block,distance=..5]

execute positioned 6 -12 22 run kill @e[type=minecraft:acacia_boat,distance=..3]
execute positioned 3 -12 19 run kill @e[type=minecraft:acacia_boat,distance=..3]
execute positioned 0 -12 15 run kill @e[type=minecraft:acacia_boat,distance=..3]
execute positioned -3 -12 11 run kill @e[type=minecraft:acacia_boat,distance=..3]
execute positioned -5 -12 8 run kill @e[type=minecraft:acacia_boat,distance=..3]
execute positioned -7 -12 4 run kill @e[type=minecraft:acacia_boat,distance=..3]
execute positioned -5 -12 4 run kill @e[type=minecraft:acacia_boat,distance=..3]
execute positioned -1 -12 20 run kill @e[type=minecraft:interaction,distance=..10]
execute positioned 2 -12 11 run kill @e[type=minecraft:interaction,distance=..10]
execute positioned 4 -12 9 run kill @e[type=minecraft:item,distance=..10]
execute positioned 2 -12 -5 run kill @e[type=minecraft:arrow,distance=..15]
execute positioned 53 -11 11 run kill @e[type=minecraft:slime,distance=..5]
execute positioned 1 -13 -43 run tp @e[type=minecraft:shulker,distance=..10] ~ ~-10000 ~
execute positioned 1 -13 -43 run kill @e[type=minecraft:armor_stand,distance=..5]
execute positioned 1 -13 -43 run kill @e[type=minecraft:falling_block,distance=..5]

team join collision @a[scores={checkpoint=2}]
gamemode adventure @a[gamemode=survival]
scoreboard players enable @a gamemode_creative

execute as @a[gamemode=creative,tag=!gamemode_creative] run function koncept:gamemode_creative
execute as @a[scores={gamemode_creative=1..}] run function koncept:gamemode_creative1

execute as @a at @s positioned -10.5 101 -1 if entity @s[distance=..3] run function koncept:nether_portal
execute as @a at @s positioned -4.5 81 -33 if entity @s[distance=..3] run function koncept:nether_portal1

kill @e[type=minecraft:acacia_boat,scores={timer_an5=1200..}]
tag @a remove slime
execute as @a at @s if entity @e[type=minecraft:marker,tag=slime,distance=..2] run tag @s add slime
bossbar set minecraft:slime players
bossbar set minecraft:slime players @a[tag=slime]

tag @a[scores={deathCount_damage=1..}] remove damage1
scoreboard players reset @a[scores={deathCount_damage=1..}] deathCount_damage

effect give @e[tag=mob_resistance] minecraft:resistance infinite 10 true

execute as @a at @s run execute as @a[y=-5,dy=0] at @s run function koncept:return_stage with storage stage:checkpoint

execute as @a[tag=!welcome] at @s run function koncept:welcome

execute as @a[tag=player_start] at @s run function koncept:player

function koncept:spawn

execute unless entity @a[scores={checkpoint=1}] run fill 15 12 13 16 12 14 minecraft:barrier[waterlogged=false]
execute if entity @a[scores={checkpoint=1}] run fill 15 12 13 16 12 14 minecraft:air


execute as @e[type=minecraft:falling_block,tag=1] at @s run data merge entity @s {Time:1b}

execute as @e[type=minecraft:acacia_boat,nbt={Fire:300s}] at @s run tp @s ~ ~0.2 ~
execute as @e[type=minecraft:acacia_boat,nbt={Fire:300s}] at @s run data merge entity @s {Invulnerable:1b,NoGravity:0b,Tags:["boat"]}

function koncept:macro_checkpoint

execute if score 25 timer matches 1.. run function koncept:level/4

execute if score 54 timer matches 1.. run function koncept:level/10

execute as @a[tag=25.end] at @s run function koncept:level/25.2

execute unless entity @a[scores={checkpoint=39}] run execute if score 200 timer_an2 matches 1 run function koncept:level/39

execute unless entity @a[scores={checkpoint=32}] run fill -22 85 -6 -2 72 -24 minecraft:red_concrete_powder replace minecraft:magma_block
execute unless entity @a[scores={checkpoint=32}] run fill -22 85 -6 -2 72 -24 minecraft:green_concrete replace minecraft:soul_sand

execute as @e[type=minecraft:goat] at @s run tp @s ^ ^ ^0.1

execute as @e[type=minecraft:goat] at @s if block ~0.5 ~ ~ minecraft:structure_void run function koncept:kill

tag @a[tag=levit] add levitno
execute as @a[tag=!levitno] at @s if entity @e[tag=levit,distance=..1] run tag @s add levit
effect give @a[tag=levit,tag=!levitno] minecraft:slow_falling 1 2 true

scoreboard players add @a[tag=levitno] timer_an1 1
tag @a[tag=levitno,scores={timer_an1=50..}] remove levit
tag @a[tag=levitno,scores={timer_an1=50..}] remove levitno
scoreboard players reset @a[tag=levitno,scores={timer_an1=50..}] timer_an1



execute as @e[tag=levitation,type=minecraft:marker] at @s run particle minecraft:end_rod ~ ~0.5 ~ 0.2 0.7 0.2 0 1
execute as @a at @s if entity @e[tag=levitation,type=minecraft:marker,distance=..0.7] at @s run effect give @s minecraft:levitation 1 1 true


#######################################################################################################################################
execute as @a[tag=stopwatch,tag=!nostopwatch] run function koncept:stopwatch

execute as @a[tag=stopwatch_no] at @s run function koncept:stopwatch_no

scoreboard players add @a[tag=stopwatch] stopwatch_t 1

# s
execute as @a[tag=!return_stage_checkpoint_message,tag=stopwatch,scores={stopwatch_m=0}] at @s run title @s actionbar [{"text":"Stage:","color":"#FFE254"},{"score":{"name":"@s","objective":"checkpoint"},"color":"#FFE254"},{"text":"/55 ","color":"#FFE254"},{"text":"s","color":"#FFE254"},{"score":{"name":"@s","objective":"stopwatch_s"},"color":"#FFE254"}]
# m, s
execute as @a[tag=!return_stage_checkpoint_message,tag=stopwatch,scores={stopwatch_m=1..}] at @s run execute as @a[tag=stopwatch,scores={stopwatch_h=0}] at @s run title @s actionbar [{"text":"Stage:","color":"#FFE254"},{"score":{"name":"@s","objective":"checkpoint"},"color":"#FFE254"},{"text":"/55 ","color":"#FFE254"},{"text":"m","color":"#FFE254"},{"score":{"name":"@s","objective":"stopwatch_m"},"color":"#FFE254"},{"text":", ","color":"#FFE254"},{"text":"s","color":"#FFE254"},{"score":{"name":"@s","objective":"stopwatch_s"},"color":"#FFE254"}]
# h, m, s
execute as @a[tag=!return_stage_checkpoint_message,tag=stopwatch,scores={stopwatch_h=1..}] at @s run title @s actionbar [{"text":"Stage:","color":"#FFE254"},{"score":{"name":"@s","objective":"checkpoint"},"color":"#FFE254"},{"text":"/55 ","color":"#FFE254"},{"text":"h","color":"#FFE254"},{"score":{"name":"@s","objective":"stopwatch_h"},"color":"#FFE254"},{"text":", ","color":"#FFE254"},{"text":"m","color":"#FFE254"},{"score":{"name":"@s","objective":"stopwatch_m"},"color":"#FFE254"},{"text":", ","color":"#FFE254"},{"text":"s","color":"#FFE254"},{"score":{"name":"@s","objective":"stopwatch_s"},"color":"#FFE254"}]

execute as @a[tag=return_stage_checkpoint_message,tag=stopwatch] at @s run function koncept:stopwatch_checkpoint

scoreboard players add @a[tag=stopwatch,scores={stopwatch_t=20}] stopwatch_s 1
scoreboard players set @a[tag=stopwatch,scores={stopwatch_t=20..}] stopwatch_t 0
scoreboard players add @a[tag=stopwatch,scores={stopwatch_s=60}] stopwatch_m 1
scoreboard players set @a[tag=stopwatch,scores={stopwatch_s=60..}] stopwatch_s 0
scoreboard players add @a[tag=stopwatch,scores={stopwatch_m=60..}] stopwatch_h 1
scoreboard players set @a[tag=stopwatch,scores={stopwatch_m=60..}] stopwatch_m 0

###checkpoint

execute as @e[tag=checkpoint,type=minecraft:armor_stand] at @s run tp @s ~ ~ ~ facing entity @p eyes

execute as @e[tag=checkpoint,type=minecraft:armor_stand] at @s if block ~ ~ ~ minecraft:light_weighted_pressure_plate[power=0] run tag @s remove checkpoint_2

execute as @e[tag=checkpoint,type=minecraft:armor_stand] at @s if block ~ ~ ~ minecraft:light_weighted_pressure_plate[power=1] run tag @s add checkpoint_1

execute as @e[tag=!checkpoint_2,tag=checkpoint_1,type=minecraft:armor_stand] at @s run function koncept:checkpoint_1

tag @e[tag=checkpoint_1] add checkpoint_2
tag @e[tag=checkpoint_2] remove checkpoint_1




execute as @a[scores={checkpoint_damage=1}] at @s run attribute @s minecraft:max_health base set 1
scoreboard players add @a[tag=damage,tag=!damage1] checkpoint_damage 1
#effect give @a[scores={checkpoint_damage=1..5}] minecraft:jump_boost 3 137 true
effect give @a[scores={checkpoint_damage=1}] minecraft:instant_damage 1
effect give @a[scores={checkpoint_damage=60}] minecraft:instant_damage 1
effect give @a[scores={checkpoint_damage=1..5}] minecraft:slowness 3 10 true
title @a[scores={checkpoint_damage=20}] title [{"text":"1","color":"#08cb5b"}]
title @a[scores={checkpoint_damage=40}] title [{"text":"2","color":"#f6c810"}]
title @a[scores={checkpoint_damage=60}] title [{"text":"3","color":"#e52b41"}]
title @a[scores={checkpoint_damage=80}] title [{"text":"","color":"#e52b41"}]
execute as @a[scores={checkpoint_damage=65}] at @s run function koncept:return_stage with storage stage:checkpoint

tag @a[scores={checkpoint_damage=80}] remove damage
tag @a[scores={checkpoint_damage=80}] add damage1
scoreboard players reset @a[scores={checkpoint_damage=80}] checkpoint_damage

effect give @a minecraft:saturation infinite 80 true

title @a[scores={timer=80},tag=woter] title [{"text":"","color":"#08cb5b"}]

#######################################################################################################################################
execute if entity @a[scores={checkpoint=49}] run function koncept:level/color
execute if entity @a[scores={checkpoint=45}] run function koncept:level/color

