
# -> If player is in spectator then return
execute if entity @s[gamemode=spectator] run \
    return fail

# -> Save rotation
rotate 00000001-0000-002a-0000-00010000002a ~ ~

# -> Reset value
scoreboard players set #or.player_gamemode OverlyRealistic.General.ArbitraryData 0

# -> Get gamemode
execute if entity @s[gamemode=adventure] run \
    scoreboard players set #or.player_gamemode OverlyRealistic.General.ArbitraryData 1
execute if entity @s[gamemode=creative] run \
    scoreboard players set #or.player_gamemode OverlyRealistic.General.ArbitraryData 2
execute if entity @s[gamemode=survival] run \
    scoreboard players set #or.player_gamemode OverlyRealistic.General.ArbitraryData 3

# -> Set gamemode
gamemode spectator

# -> Set downwards rotation
rotate @s ~ 90

# -> Set impulse
item modify entity @s armor.body overly_realistic:velocity/apply_velo_y_neg_1

# -> Reset gamemode
execute if score #or.player_gamemode OverlyRealistic.General.ArbitraryData matches 1 run \
    gamemode adventure @s
execute if score #or.player_gamemode OverlyRealistic.General.ArbitraryData matches 2 run \
    gamemode creative @s
execute if score #or.player_gamemode OverlyRealistic.General.ArbitraryData matches 3 run \
    gamemode survival @s

# -> Remove impulse
item modify entity @s armor.body overly_realistic:velocity/remove_velo

# -> Restore rotation
execute rotated as 00000001-0000-002a-0000-00010000002a run \
    rotate @s ~ ~

