Animals always tend to wander uphill due to a quirk in how random wandering positions are chosen:
Positions which don't have a solid block under them are discounted, but positions inside the ground are not discounted and instead raised to the surface. This causes a very heavy bias for animals to naturally wander up hills, and causes behaviour like in the attached image.
Linked issues
relates to 1
Attachments
Comments 3
I can confirm this is in vanilla minecraft as well, it is rather hard to screenshot as it's ultimately still just a bias to move upwards and not guaranteed, however I can point to this video (timestamped) https://youtu.be/jpi50LX2Qyk?t=98 demonstrating it on a larger scale and I have also made a mod which can be viewed here https://github.com/Favouriteless/StupidCowStopClimbing which fixes this behaviour without breaking player mob farms which rely on pathfinding, however the method I used to do so most likely isn't the most performant.
The best way I can explain the bug is that when a random position is chosen, if that position has a solid block under it, then that position will be moved upwards until a solid block with air above it is found, and the animal will path towards that. However, if a block in the air without a solid block under it is chosen, it will not be moved downwards. This makes columns which contain a higher pillar of blocks far more likely to be chosen than lower columns which mostly contain air.
The modding environments we use are remapped so I'm not sure how useful this will be, but the problem occurs in LandRandomPos#generateRandomPosTowardDirection(PathfinderMob, int, boolean, BlockPos), as far as I know the class name and method signature should be about the same.
Noting this is observed in 1.21.11 Java Edition Servers with all mobs, not just passive. Tested with a copper golem, villagers, several chickens, squid, and an enderman—all were biased to scale blocks, with them only heading downhill when falling off blocks. Fish will also notably swim to the highest water source (waterfalls) regardless of whether they are salmon or not. This has led to several tropical fish deaths in my worlds. Squid, despite being intended to prefer deeper water, also swim to the surface and frequently suffocate on shorelines.
I had client-side mods enabled, so I’m not sure if that would be acceptable for recreation screenshots.
In any case—
Steps to Recreate:
To be more visually obvious, create a fenced space with a slope, as seen in the original reporter’s image.
The amount of mobs spawned does not matter. A higher number makes it easier to observe.
With the game set to 20 ticks, the mob will pathfind to higher ground within under 10 seconds. Mob will only pathfind off said ground if a higher location can be located, it falls off, or another POI or behaviour takes priority (i.e. a villager navigating to stand on top of their workstation rather than beside it, then a meeting at the bell taking prioity to navigate off it. However, notably, they pathfind on top of the bell).
Expected Behaviour:
Pathfinding selects a random, valid location to wander within a radius unless another behaviour takes priority (i.e. a bee locating a flower after wandering and pathfinding to it). Mob memory prevents pathfinding to the same area repeatedly in situations where it is relevant (copper golems navigating to chests, villagers looking for work stations, etc).
Observed Behaviour:
Pathfinding is biased to higher altitudes (y-axis) even when navigating to locations based on behaviours. This leads to similar mobs crowding and pushing to get on top of the same spot they navigated to.
Possibly occurring due to hills and other elevated terrain containing more blocks (rather than air blocks), being a false positive for blockweights.
Please verify if this is the case in vanilla, as your report shows a modded setup.
If you can reproduce this in vanilla, provide a screenshot with the F3 debug menu enabled.