scoreboard objectives add Click minecraft.used:minecraft.carrot_on_a_stick
scoreboard objectives add MotionX dummy
scoreboard objectives add MotionZ dummy
scoreboard objectives add Jump_power dummy

execute as @a if score @s Click matches 1.. run execute as @e[name=TheblueMan2D] at @s store result entity @s Motion[1] double 0.001 unless block ~ ~-1 ~ air run scoreboard players get @a[tag=PlayingIn2D,limit=1] Jump_power
execute as @e[name=TheblueMan2D] store result entity @s Motion[0] double 0.001 run scoreboard players get @a[tag=PlayingIn2D,limit=1] MotionX
execute as @e[name=TheblueMan2D] store result entity @s Motion[2] double 0.001 run scoreboard players get @a[tag=PlayingIn2D,limit=1] MotionZ

execute as @a if score @s Click matches 1.. run scoreboard players set @s Click 0
execute as @e[name=TheblueMan2D] at @s if block ~ ~-1 ~ minecraft:barrier run tp @s @e[name=Checkpoint,limit=1]
execute as @e[name=TheblueMan2D] at @s if block ~ ~-1 ~ minecraft:emerald_block run tp @e[name=Checkpoint,limit=1] @s
replaceitem entity @a[gamemode=adventure,tag=PlayingIn2D] hotbar.0 minecraft:carrot_on_a_stick{display:{Name:"{\"text\":\"Jump\",\"color\":\"white\",\"italic\":false}"},Unbreakable:1,HideFlags:1} 1
effect give @a[gamemode=adventure,tag=PlayingIn2D] levitation 1 255 true

execute as @p run execute as @e[tag=Wander] at @s if block ~ ~-1 ~ minecraft:magenta_glazed_terracotta[facing=west] store result entity @s Motion[0] double 0.0001 run scoreboard players get @s Motion
execute as @p run execute as @e[tag=Wander] at @s if block ~ ~-1 ~ minecraft:magenta_glazed_terracotta[facing=east] store result entity @s Motion[0] double -0.001 run scoreboard players get @s Motion
execute as @p run execute as @e[tag=Wander] at @s if block ~ ~-1 ~ minecraft:magenta_glazed_terracotta[facing=north] store result entity @s Motion[2] double 0.001 run scoreboard players get @s Motion
execute as @p run execute as @e[tag=Wander] at @s if block ~ ~-1 ~ minecraft:magenta_glazed_terracotta[facing=south] store result entity @s Motion[2] double -0.001 run scoreboard players get @s Motion
execute as @p run execute as @e[tag=Wander] at @s if block ~ ~-2 ~ minecraft:magenta_glazed_terracotta[facing=west] store result entity @s Motion[0] double 0.001 run scoreboard players get @s Motion
execute as @p run execute as @e[tag=Wander] at @s if block ~ ~-2 ~ minecraft:magenta_glazed_terracotta[facing=east] store result entity @s Motion[0] double -0.001 run scoreboard players get @s Motion
execute as @p run execute as @e[tag=Wander] at @s if block ~ ~-2 ~ minecraft:magenta_glazed_terracotta[facing=north] store result entity @s Motion[2] double 0.001 run scoreboard players get @s Motion
execute as @p run execute as @e[tag=Wander] at @s if block ~ ~-2 ~ minecraft:magenta_glazed_terracotta[facing=south] store result entity @s Motion[2] double -0.001 run scoreboard players get @s Motion

execute as @e[tag=Wander] at @s if block ~ ~-1 ~ minecraft:magenta_glazed_terracotta[facing=west] run data merge entity @s {Rotation:[-90f,0f]}
execute as @e[tag=Wander] at @s if block ~ ~-1 ~ minecraft:magenta_glazed_terracotta[facing=east] run data merge entity @s {Rotation:[90f,0f]}
execute as @e[tag=Wander] at @s if block ~ ~-1 ~ minecraft:magenta_glazed_terracotta[facing=north] run data merge entity @s {Rotation:[0f,0f]}
execute as @e[tag=Wander] at @s if block ~ ~-1 ~ minecraft:magenta_glazed_terracotta[facing=south] run data merge entity @s {Rotation:[180f,0f]}
execute as @e[tag=Wander] at @s if block ~ ~-2 ~ minecraft:magenta_glazed_terracotta[facing=west] run data merge entity @s {Rotation:[-90f,0f]}
execute as @e[tag=Wander] at @s if block ~ ~-2 ~ minecraft:magenta_glazed_terracotta[facing=east] run data merge entity @s {Rotation:[90f,0f]}
execute as @e[tag=Wander] at @s if block ~ ~-2 ~ minecraft:magenta_glazed_terracotta[facing=north] run data merge entity @s {Rotation:[0f,0f]}
execute as @e[tag=Wander] at @s if block ~ ~-2 ~ minecraft:magenta_glazed_terracotta[facing=south] run data merge entity @s {Rotation:[180f,0f]}