Walking target not saved, mobs moving to a block stop moving on reload
See title.
If a mob decides to walk to a certain block, leaving and entering the world will result in the mob stopping to move to that block.
The walk target is saved internally as a memory, but simply not serialised to the save data.
Created Issue:
Walking target not saved, mobs moving to a block stop moving on reload
See title.
If a mob decides to walk to a certain block, leaving and entering the world will result in the mob stopping to move to that block.The walk target is saved internally as a memory, but simply not serialised to the save data.
relates to
relates to
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.
How is this a feature request when all the other reports about data being lost on reload are valid? And in particular, why is MC-183791 valid while this isn't? Why is it intended that a cow forgot that you punched it but unintended that it forgot which block it was walking/running to?