TransWikia.com

Is it possible to teleport an entity to a nearby entity?

Arqade Asked on July 28, 2021

With players, you can teleport player1 to the closest nearby player with:

/execute at player1 run tp @p

But can the same be done with an entity?

3 Answers

To teleport an entity (such as an entity tagged cow1, for example), to the nearest entity that is not itself, use this command:

tp @s @e[tag=!cow1,sort=nearest,limit=1]

Correct answer by ginkgo on July 28, 2021

You can use @e to target all entities so if you wanted to teleport all cows near by you would use

/tp @e[type=cow]

to teleport the cows to the nearest player it would be

/tp @e[type=cow] @p

I don't believe there is a way to teleport a single entity.

https://minecraft.gamepedia.com/Commands/teleport

https://minecraft.gamepedia.com/Target_selector

Answered by Robbie on July 28, 2021

First of all, I suggest reading this post's answer because it will likely have a lot of information which is helpful to you.

Secondly, in it's simplest form the /tp command takes two entity arguments, or one entity and one location argument. /tp <entity> <entity> or /tp <entity> [<Pos>].

If you wanted to teleport the nearest sheep to the nearest villager, relative to your location, you would do /tp @e[type=sheep,sort=nearest,limit=1] @e[type=villager,sort=nearest,limit=1].

All entities selected by the first argument will be teleported to the entity selected by the second argument. Keep in mind that the second selector must only select one entity, or otherwise you will get an error.

For more information, see the links provided in Robbie's answer.

Answered by Nik3141 on July 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP