How to teleport nearby villagers to me?
The first command doesn't always work because it's selecting a box that extends 300 blocks in the x, y, and z directions from your current location. If there's no villager in that box, they're not going to be teleported. You shouldn't be using the dx
, dy
, and dz
selector arguments without the z
, y
, and z
selectors in most cases anyway. This kind of selection is best reserved for finding a target within a very specific box, which is probably not the case here.
The second command doesn't work (except in very specific contrived circumstances) because you are trying to find a villager exactly 200 blocks away. For various reasons, this is basically impossible in normal gameplay. Fortunately it's relatively easy to fix this by searching for a villager less than or equal to 200 blocks away:
/tp @e[type=minecraft:villager,distance=..200] @p
If you only want to teleport a single villager instead of multiple villagers, it's simple to impose that limit as well:
/tp @e[type=minecraft:villager,distance=..200,limit=1,sort=nearest] @p
or to get a random villager:
/tp @e[type=minecraft:villager,distance=..200,limit=1,sort=random] @p