Is it possible to teleport an entity to a nearby entity?
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.