Teleport to different dimension safely

Trying to make the player safely teleport to any dimension, without them landing in lava/void/blocks how should i do this, im kinda banging my head against a wall here> 1.21.1

Continue to help post