trying to replicate a chorus fruit teleport (1.19.2)

i'm trying to make a datapack where you play as an enderman, and for it i wanted to have projectiles make you randomly teleport. i havent really found any way to do this besides /spreadplayers but it doesn't take your y level into account which has resulted in me getting trapped on the nether ceiling. i'm not sure how to go on with it in this case
Continue to help post