0

I would like to know how I can teleport an entity relative to itself if the entity type is unknown. I have tried the solution in this topic here: Teleport all entities relative to themselves in 1.13 removing the type=minecart part leaving just @e, but that just ends up making all the entities cram themselves together. The command I used was:

execute at @p run execute as @e[distance=..15,type=!player] at @s run tp @e[type=!player,distance=..15] ^ ^10 ^
1

Your old command:

execute
  at @p                                       # At the nearest player...
  as @e[distance=..15,type=!player]           # give control to all non-players within 15 blocks and make them...
  at @s                                       # move the execution position to themselves and...
run tp @e[type=!player,distance=..15] ^ ^10 ^ # teleport all the entities 10 blocks up from themselves

The last part is the problem. When each entity runs /tp, they are referencing all the entities, causing them all to teleport to the same position. You need each entity to reference themselves independently, which means changing the target selector in the /tp to @s.

execute at @p as @e[distance=..15,type=!player] at @s run tp @s ~ ~10 ~

Explanation:

execute
  at @p                             # At the nearest player...
  as @e[distance=..15,type=!player] # give control to all non-players within 15 blocks and make them...
  at @s                             # move the execution position to themselves and...
run tp @s ~ ~10 ~                   # teleport themselves upward ten blocks

I changed the ^s to ~s because they are more reliable when teleporting entities, that way they aren't sightline-sensitive.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.