I'm in Java 1.14.4 and I'm attempting to make all rabbit entities walk to a specific tagged item if they are in the range of it.

execute as @e[type=rabbit] at @s run teleport @s @e[tag=fruit,distance=5..25,limit=1]

This command would teleport any rabbits to that specific entity, but I was looking for something where the rabbit would slowly walk up to that destination instead. Is there a way to do this?

  • Well, in theory you would need something like this: execute as @e[type=rabbit] store result entity @e[type=wandering_trader,distance=0,limit=1] WanderTarget.X int 1 run data get entity @e[tag=fruit,distance=5..25,limit=1] Pos[0] But the problem is: It doesn't work. I couldn't get the wandering trader to actually move, except when I set the tag when summoning. – Fabian Röling Jul 21 '19 at 12:51
  • I just confused as and at… 🤦‍♂️ – Fabian Röling Jul 21 '19 at 13:17

Since 1.14 this is possible relatively easily with the wandering trader. It has the WanderTarget NBT field that you can set to any coordinates to make it use its regular pathfinding to walk there.

You need the dummy scoreboards x, y and z.

/execute at @e[type=rabbit] run summon wandering_trader
/execute at @e[type=rabbit] store result entity @e[type=wandering_trader,distance=0,limit=1] WanderTarget.X int 1 run data get entity @e[tag=fruit,distance=5..25,limit=1] Pos[0]
/execute at @e[type=rabbit] store result entity @e[type=wandering_trader,distance=0,limit=1] WanderTarget.Y int 1 run data get entity @e[tag=fruit,distance=5..25,limit=1] Pos[1]
/execute at @e[type=rabbit] store result entity @e[type=wandering_trader,distance=0,limit=1] WanderTarget.Z int 1 run data get entity @e[tag=fruit,distance=5..25,limit=1] Pos[2]

Then you continuously teleport the rabbit to the wandering trader. When it's within about 2 blocks or so, kill the wandering trader.
The downside of this is that it won't hop. It will also not go exactly towards the target, because the wandering target stops about two blocks before its target coordinates. But maybe it's already good enough to teleport the rabbit the remaining distance. This system also only works properly at night, otherwise the wandering trader is visible. You could give it invisibility repeatedly, but then it will still show its milk bucket whenever it tries to get rid of the effect.

Thanks to "🐾 Aelicorn_v2 🐾" and "remy - 1.14" in the Minecraft commands Discord for their help with this answer (mainly the as vs. at confusion).

  • This works fine, but the floating milk bucket is really distracting. Do you know how I could remove it? – Hydra Jul 22 '19 at 0:42
  • Not really, sadly. I wrote this entire answer and only then noticed it. Maybe you could clone the entire area somewhere else and then have the wandering trader move in the copy and the rabbit in the original. But that would still have to be in loaded chunks, so a bit complicated. You could also try instead using a zombie and a villager, but it's not reliable that the zombie actually starts walking towards the villager immediately. – Fabian Röling Jul 22 '19 at 13:18

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.