The bug
I have already seen the "fixed" bug report MC-151333 but the villagers still get stuck in the water. I have been trying to make a swamp village in a part of swampland that has no exposed land anywhere but the villagers keep jumping in the water and once they do they just swim in it.
I have found that the pathfinding is broken in where they still swim in the water but they can't seem to detect a bed where they need to swim out of the water and then onto land to get to it. As soon as I push the villager onto land he goes to the bed.
In the picture below a villager is in the water right beside a bed at night but isn't going into it.
How to reproduce
Linked issues
relates to 1
Attachments
Comments 16
Here's a video showing the behaviour https://youtu.be/iaydB_oyMjI
Still present in 20w15a, the villagers happily walks into the water but can not pathfind out of it again, rather problematic with them getting stuck in the water.
(Testing on 1.15.2)
Seems that villagers happily find their paths through (or more like into) 2 block deep pits, whether it has water or not. It could be that the path finding routine simply ignores water, and thus does not consider that the villager is actually floating and could step on the shore. For the routine, the villager is stuck "virtually on the bottom" until the water's floor/ground has a path of 1 block steps out of the bottom. (Or seems to work like so.)
I think this might apply to many more mobs than just villagers.
Possibly the solution could be to somehow make pathfinding consider floatable (and safe) liquids in a special way (considering the 2nd liquid block from top as solid with high movement cost). Alternately, if the entity can still move in the water towards some edges, check a special case of pathfinding from the current real position (floating high in the topmost water) to next block (whether that is shore or something in the deep), which might allow the crucial step of getting forward enough for the normal pathfinding to work its way further. The latter way might be easier to implement, but may also fail with some arrangements.
I was able to reproduce in 20w49a. They can still step up from 1 deep water, but not from 2 deep water.
However, if there are more than 1 villager in the "same spot" near land, as they keep pushing each other, they may start jumping, and one of them may get pushed on the land while jumping. A lone villager didn't get out.
My test case was to surround the village bell area (5x5 area) with 3 wide pool of water, with the innermost radius of the pool being 1 deep, rest 2 deep. Thus, when they want to get to the meeting, they will happily find their path all the way to bell area (on land), chat a while, but once the meeting is over and they should get back to work, all they do is to spread to outer edges, and can't get out (unless randomly "helped" by another villager).
(Attached screenshot of the test setup ("test-setup.png").. well, trying to.)
Still present in 1.15.2
The villagers pathfinding in water is really bad, even thoug, they seem to try to pathfind throgh water when standing on land but as soon as they enter the water, their pathfinding breaks and they usually loose their work and bed.
I have hovever noticed that it depends on how deep the water is at the edge between land/water. If the edge is 1 block deep only, then the villagers are able to pathfind out of the water easily enough, but if the water is 2 blocks or more deep, then they cannot.
As can be seen from the screenshots. 1. Villager in a puddle of water 2 block deep is unable to pathfind correctly to land and aquire a job.
[media]As soon as i place a block in the water so there is only 1 block depth agains the edge of the land/water, the villager aquires the job and starts pathfinding out of the water.