execute as @a[scores={checkpoint=3,checkpoint_between_3=0}] at @s positioned 41 16 20 if entity @s[distance=..2] run tag @s add return_stage_checkpoint_message
execute as @a[scores={checkpoint=3,checkpoint_between_3=0}] at @s positioned 41 16 20 if entity @s[distance=..2] run spawnpoint @s 41 16 20 270.71
execute as @a[scores={checkpoint=3,checkpoint_between_3=0}] at @s positioned 41 16 20 if entity @s[distance=..2] run scoreboard players set @s checkpoint_between_3 1


#cactus

execute as @a[scores={checkpoint=3},tag=!cactus] at @s run function koncept:level/cactus
execute as @a[scores={checkpoint=3},tag=cactus] at @s run function koncept:level/nocactus

scoreboard players add 7cactus timer 1
execute as @a[scores={checkpoint=3}] at @s run execute if score 7cactus timer matches 10.. run function koncept:level/cactus
execute as @a[scores={checkpoint=3}] at @s run execute if score 7cactus timer matches 10.. run scoreboard players reset 7cactus timer


###
execute positioned 41 18 31 if entity @a[distance=..1] run scoreboard players set 7 timer 1
execute if score 7 timer matches 1.. run scoreboard players add 8 timer 1
execute if score 8 timer matches 30.. run kill @e[type=minecart,tag=3] 
execute if score 8 timer matches 1 run summon minecraft:minecart 36 18 36 {Tags:["3"]}
execute if score 8 timer matches 50.. run scoreboard players reset 7 timer
execute if score 8 timer matches 50.. run scoreboard players reset 8 timer
execute if score 8 timer matches 1..30 run data merge entity @e[type=minecraft:minecart,limit=1,sort=nearest,tag=3] {Motion:[5.0,0.0,0.0]}

###
execute positioned 41 12 20 if entity @a[distance=..4] run scoreboard players set 6 timer 1
execute if score 6 timer matches 1.. run scoreboard players add 5 timer 1
execute if score 5 timer matches 120.. run kill @e[type=minecart,tag=2] 
execute if score 5 timer matches 120.. run summon minecraft:minecart 41 12 20 {Tags:["2"]}
execute if score 5 timer matches 120.. run scoreboard players reset 6 timer
execute if score 5 timer matches 120.. run scoreboard players reset 5 timer
execute if score 5 timer matches 10..40 run data merge entity @e[type=minecraft:minecart,limit=1,sort=nearest,tag=2] {Motion:[0.3,0.0,0.0]}
execute if score 5 timer matches 40..50 run data merge entity @e[type=minecraft:minecart,limit=1,sort=nearest,tag=2] {Motion:[0.0,0.0,-0.4]}

###
execute positioned 42 8 24 if entity @a[distance=..3] run scoreboard players set 4 timer 1
execute if score 4 timer matches 1.. run scoreboard players add 3 timer 1
execute if score 3 timer matches 180.. run kill @e[type=minecart,tag=1] 
execute if score 3 timer matches 180.. run summon minecraft:minecart 39 12 26 {Tags:["1"]}
execute if score 3 timer matches 180.. run scoreboard players reset 4 timer
execute if score 3 timer matches 180.. run scoreboard players reset 3 timer
execute if score 3 timer matches 10..20 run data merge entity @e[type=minecraft:minecart,limit=1,sort=nearest,tag=1] {Motion:[1.0,0.0,0.0]}
execute if score 3 timer matches 70..150 run data merge entity @e[type=minecraft:minecart,limit=1,sort=nearest,tag=1] {Motion:[-0.2,0.0,0.0]}