Mob fleeing
In Minecraft, mob fleeing is a mechanic in which mobs will attempt to avoid or flee from sources that they are fearful of.
When a mob is in close enough proximity to something that it is fearful of (referred to as a "fear source" in this article), it attempts to move away from that source (usually through moving quickly such as sprinting) until it is a reasonable distance away.
All mobs will check for fear sources in the surrounding area every 5 ticks when there is a line of sight. The radius in which a mob detects a fear source can vary depending on the specific fear source in Java Edition or simply 3×3×3 for every mob in Bedrock Edition.[1] For example: a mob may detect a certain fear source within a radius of 8 blocks, whereas it may detect a different fear source within a larger radius of 15 blocks.
Complete article available
This cached Wiki page is unusually large, so it is loaded on demand to keep the initial page fast.