-
Bug
-
Resolution: Invalid
-
None
-
1.21.4
-
None
-
Community Consensus
-
Save Data
Various mobs which can "sprint" (move faster than their idle walking speed) will cease doing so when the world is reloaded. This affects:
- Villagers and animals fleeing from danger
- Creepers fleeing from cats
- Pigs and striders which have been "speed-boosted" by their riders
- Various situations covered by MC-250059, if we consider mobs like pillagers, iron golems, etc. to "walk" when idle and "sprint" when pursuing a target, which makes sense to me
This happens because mobs' sprinting state is not saved to NBT.
How to reproduce
- Punch a cow
- Immediately reload the world
Notice how the cow is no longer fleeing from you. (It also forgot where it was walking to due to MC-183791.)
Suggested fix
I suggest fixing this as part of a refactor that also fixes MC-183791 and MC-250059. Extra speed from sprinting would be stored as a modifier to the minecraft:movement_speed attribute (as would player sprinting/crouching/crawling), and the base Mob class would gain 3 new fields: danger_source (int array; UUID) attack_target (int array; UUID) and path_target (int array; block pos). Whenever a mob re-evaluates its movement, it checks these fields in the order listed here to determine what to do. Pigs and striders would also gain boost_time_remaining and boost_time_total fields so that their boost state is preserved.
I realize that this section kind of reads like a design suggestion but I feel like I would be remiss not to propose a comprehensive solution. As far as I know Mojang aspires for gameplay to be completely unaffected by world reloads – with very limited exceptions – so these internal changes seem to me like the natural extension of that logic.