tp @s ~ ~ ~ facing entity @e[tag=center,limit=1,sort=nearest]

execute if block ~ ~-2 ~ oak_trapdoor[facing=south] run data merge entity @s {Rotation:[0.0f,0.0f]}
execute if block ~ ~-2 ~ oak_trapdoor[facing=west] run data merge entity @s {Rotation:[90.0f,0.0f]}
execute if block ~ ~-2 ~ oak_trapdoor[facing=north] run data merge entity @s {Rotation:[180.0f,0.0f]}
execute if block ~ ~-2 ~ oak_trapdoor[facing=east] run data merge entity @s {Rotation:[270.0f,0.0f]}

execute if entity @s[type=armor_stand] run tp @s ~ ~0.7 ~
execute if entity @s[type=armor_stand,nbt={NoGravity:1b}] run tp @s ~ ~-0.7 ~
