-
Bug
-
Resolution: Cannot Reproduce
-
None
-
Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b, Minecraft 17w45a, Minecraft 17w45b, Minecraft 17w46a, Minecraft 17w47a, Minecraft 17w47b, Minecraft 17w48a, Minecraft 17w50a, Minecraft 18w01a, Minecraft 18w02a, Minecraft 18w03b, Minecraft 18w05a, Minecraft 18w06a, Minecraft 18w07a, Minecraft 18w08b, Minecraft 18w11a, Minecraft 18w14a, Minecraft 18w14b, Minecraft 18w16a, Minecraft 18w20c, Minecraft 18w21a, Minecraft 1.13-pre5, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 18w43b, Minecraft 18w43c, Minecraft 18w44a, Minecraft 18w45a, Minecraft 18w50a
-
Confirmed
-
(Unassigned)
The bug
When running to get into houses during nightfall, villagers run extremely fast. However when escaping from zombies (including babies), they only walk at normal speeds, allowing zombies (especially babies) to catch up and kill them. They run from illagers faster than from zombies, but not as fast as getting into houses.
This running behavior is incorrect; if anything they should sprint away from zombies and vindicators, and walk normally to get into houses (where there's no real danger). Their sprinting to get into houses also impairs their ability to get through the doorway.
How to reproduce
Summon a NoAI zombie and vindicator at opposite ends of a 10-15 block long tunnel, and spawn a villager. It will sprint away from the vindicator to the zombie, than walk away from the zombie back to the vindicator.
Videos demonstrating the issue
- Zombie and vindicator at opposite ends: difference in speed is noticeable
- Zombie and a valid house at the same end: difference in speed is even more noticeable
- Vindicator and house at the same end: the villager seems to run faster towards the house than away from the vindicator, although this difference is less noticeable than the previous two
Note that the first video was taken during daytime, and the latter two were during nighttime with the Night Vision effect.
Code analysis
This was decompiled in 1.12 with MCP 9.40:
The different villager "running" actions were given different speeds (which may be intended, but is inconsistent). The file EntityVillager.java has the following four lines in the initEntityAI() method:
this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D)); this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityEvoker.class, 12.0F, 0.8D, 0.8D)); this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityVindicator.class, 8.0F, 0.8D, 0.8D)); this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityVex.class, 8.0F, 0.6D, 0.6D));
In the file EntityAIMoveIndoors.java, there is the following line of code:
this.entity.getNavigator().tryMoveToXYZ((double)i + 0.5D, (double)j, (double)k + 0.5D, 1.0D);
It seems like the speed modifiers of Villagers are set to 0.6 for avoiding zombies, 0.8 for illagers, and 1.0 for moving indoors. This priority is incorrect; villagers should move faster when avoiding actual zombies instead of moving indoors due to supposed threats.