As far as I have observed, the wandering trader never targets a position and pathfinds toward it. The only way it changes its position is when its llamas push it. This happens every few seconds because the llamas almost constantly move, and they don't pull the trader when they get to the end of their leads, but they do push it every time they return.
The llamas can't push the trader up when they return from below it, but they'll always push it down when they return from above. The net effect is that the trader can only stay at the same level or move downward. Over time, the only possible outcomes are that it gets stuck in a corner, or it gets pushed into a concave depression/over the edge of a cliff/into a cave or ravine/into a pool, river, or ocean. In many of the latter cases, there's a good chance that it will die, and even if it doesn't, trading with it becomes less convenient. It's also absurdly suicidal behavior for the trader to allow its llamas to push it to such a fate.
Steps to reproduce:
Wait near a village (or at least a bed) until a wandering trader spawns.
Observe how its llamas push it every time they return from the end of their lead.
Observe that (unless the terrain is completely level) after enough time passes it always either gets stuck in a corner or falls into a depression, a cave, or water.
Related issues
is duplicated by
Comments


Was going to report the same thing. The llama's push the trader all over the place. They should not be able to push the trader at all. Also, those llama's are totally annoying, they constantly try crowd inside my structures instead of waiting outside, and they move so much. I would expect them to act more like sheep and just graze in place or wander one or two block between grazing for a while.

Partly fixed in 1.16. They now run away when hit or from zombies, but still do not actively move around.

What's worse is that when pushed off a cliff or into lava, etc., it now leaves behind persistent llamas that fill the mob cap, crowd villages, and obstruct farms. See MCPE-44312.
After analyzing the wandering_trader.json
file, it seems like the wandering trader is missing the "minecraft:behavior.random_stroll"
, which causes the mob to not move at all. Here's the JSON text line to fix it (+adding speed_multiplier
to adjust the walking speed like the villager does):
"minecraft:behavior.random_stroll": {
"priority": 9,
"speed_multiplier": 0.6
}

I think that actually, slightly more is needed because even if the wandering trader strolls and therefore can occasionally climb up out of a depression in the terrain, it still allows the llamas to push it, and they'll eventually push it into a depression again.
What's needed is to keep the llamas from pushing the WT, which means they have to stop moving just before reaching the WT. The behavior that does this is called follow_parent
. There is a similar behavior called follow_owner
which is used (I believe) for pets following their owners, and it has fields named start_distance
and stop_distance
that control how close the follower must be when it starts and stops following. follow_parent
doesn't have these fields, but if it did the llamas could be prevented from pushing their parent mob and everything would look very natural. The code for llama.json would then look something like this:
"minecraft:behavior.follow_parent": {
"priority": 5,
"speed_multiplier": 1,
"stop_distance": 2
}

Affects 1.17.10/11 Hotfix

I'm not sure even a follow_...
behavior with a stop_distance
would fix the pushing problem. After an initial bump or two due to random wandering, all of the llama pushing against the trader is caused by the leash pulling them back into the trader. Leash pull-back overrides any pathfinding goals. I believe a fix for this bug needs to focus on leash mechanics.
There are two problems with the leash pull-back.
Infinite loop: once a leashed mob chooses a wandering target farther than 4 blocks from the leash anchor, it gets trapped in an endless loop of moving toward that point and being pulled back, over and over (MCPE-47168, MCPE-49607).
Bumping: leash pull-back has a hidden parameter similar to a stop distance, but it's too short. From my testing it appears that leach pull-back tries to move the leashed mob horizontally to within a 1-block radius of the center of the horizontal (x, z) coordinate the entity holding the leash is standing on. For example, a mob leashed to a player at either 8.0 Y 8.0 or 8.9 Y 8.9 will be pulled back toward 8.5 Y 8.5 and might try to stop near 7.5 Y 8.5, 8.5 Y 6.5, 9.2 Y 9.2, etc. depending on the direction. This has the effect that in most cases with most mobs, the leashed mob pushes the leash-holder, sometimes for longer distance, sometimes for a shorter distance.
A fix to leashes should do either/both of (1) and (2), and either/both of (3) and (4):
Allow leash pull-back to cancel the current AI pathing goal, rather than just override it temporarily. Then leashed mobs could still wander, lunge, etc. (which looks natural) but would not get stuck in an inane loop.
Allow wandering goals to time out (i.e. fix MCPE-49607). Again, this would allow leashed mobs to wander without getting stuck in an inane loop.
Increase the default stop distance/goal radius/whatever for leash pull-back. As part of that, center it on the actual anchor point to the nearest 1/10th of block.
Make the stop distance/goal radius/whatever for leash pull-back data driven. This would allow better control of leashing for custom mobs, especially larger mobs.
One way to work around llamas pushing the trader with a behavior pack would be to give llamas a behavior to avoid the wandering trader with a higher priority than random wandering.
A stronger behavior pack workaround is to remove behavior.random_stroll
from the llama's base components and put it in the llama_tamed
and llama_wild
groups instead. This way, llama's simply do not wander when leashed to the trader. An unfortunate consequence is that they perpetually stand inside the trader. To overcome that, they can be given behavior.move_to_random_block
with high priority and a 2 block range for just a second after spawning.

Affects 1.17.40.20

The AI looping of leashed animals is fixed in 1.18.10 but the leash pull-back still causes leashed mobs to bump the leash holder. So now llamas push the wandering trader around in random directions instead of in the same direction continually.
Wandering traders lack their wander movement. This is slightly the same behavior they had on Java (Snapshot 19w05a). Unlike that snapshot however, the wandering trader runs away from any zombie or illager.