I will say right now that both MC-12427 and MC-4661 are included in what I am about to report. However, I am reporting exactly what the problem is, how they are in reality the same issue, examples of other pathfinding issues which also occur, and how it could all be fixed with a single theoretical solution. It seems sort of conceded to ask if they could be consolidated into this report, but I feel like this single one is more constructive than a bunch of little ones out there which are all symptoms of the same bug.
The problem
The problem with the pathfinding in Minecraft is that is uses a strictly grid-based system. This would be okay except that collisions are not as strictly grid-based. Entity movement accounts for this, but pathfinding does not. The consequences of this are far reaching. Basically there are many ways in which an entity may conclude that it cannot move when in reality it can and vice versa. Fixing this bug would make farming less frustrating and hiding from monsters much harder. Let me explain each of the four images inside the larger image I posted.
1. Mobs (the creeper) get stuck in northwest corners
This is a combination of things. For one thing, entities begin pathfinding from their northwest corner instead of their center. For another, they do not take into account collisions properly. This means the creeper pictured begins his pathfinding from inside the corner fence. This creeper believes he can travel both north and west because it is air, and he cannot travel either south or east because they are fences. All four of these assertions are wrong. If he were to analyze collisions instead of just the grid he would know this.
2. Mobs are incapable of passing through half slab gaps
Some people like and utilize this, but it is a flaw. The creeper knows he can pathfind through the center of the hole, but reasons he is too tall to put his feet through the center and his head through the half slab. This is false. He does not take into account where his feet will land, and the same can be said about his head.
3. Mobs, especially small ones, get stuck inside walls
The picture is a special case in which the sheep has his northwest corner inside a wall. He can clearly step back and walk through the opening in the fence to my character, but he believes the fastest way is to walk through, because he is already "inside" the fence and does not take collisions into account. This same thing will happen with small entities far more frequently because their entire collision box can fit inside the fence block. This makes it a pain to lead animals along/through fences and other thin walls.
4. Mobs cannot navigate through gaps between blocks
This is the same issue as the creeper who cannot walk through the half slabs but in the x and z dimensions. If the chicken were to acknowledge the size of its bounding box and which blocks it would collide with, it could reason that it is possible to fit through the gap.
More details
It has recently come to my attention that small entities like chickens cannot pathfind out of fence corners even if they are told they can pathfind literally anywhere. This is because they cannot draw a vector out of the fence wireframe without concluding they will collide with it.
Theoretical solution
Ideally, if the code could be more double-based, relying on the actual bounding box, this problem would be fixed in all instances. But, unfortunately, that would likely require a significant amount of processing. Instead, it is probably best to add more conditions to the code which allow pathing along but not through fences.
At the very least, changing pathfinding so that entities begin from their center should fix situations 1 and 3 (MC-12427 and MC-4661 respectively) for the majority of creatures (everything but babies, silverfish, and chickens).
Linked issues
is duplicated by 22
relates to 6
Attachments
Comments 35
Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
Do you have any idea what the computational cost of pathfinding is? A lot of games pre-calculate and store pathing information for the terrain in order to reduce the cost of finding a path. There are certainly improvements that could be made, particularly to solve the sort of problems you mention, but you're oversimplifying the problem a great deal.
I don't believe so, because it causes passive mobs to wander away in the same direction or bunch up in corners of fenced in areas, and that is clearly a bug/unintended behavior.
PLEASE.
Thank you for explaining – and showing with simple pictures – exactly what's going on.
PLEASE, Mojang, this and 2025 – please make these, and similar issues, the focus of your next patch level. Yes, I'm asking for 1.7 to be the raid release (raid = bug spray)