Setting max_dist and max_flee above the default values of 3 and 10 does not make any difference.
If a mob has max_dist and max_flee value of 24, the mob will only start fleeing once the target is within 3 blocks and will only flee up to 10 block away.
This can be seen easily by spawning a vanilla ocelot. In the behavior file, it is supposed to flee from players 10 block away. However, it won't start fleeing until the player is 3 blocks away.
This is extra obvious when setting the max_dist and max_flee higher in a behavior pack.
For example, when setting the Salmon behavior.json behavior.avoid_mob_type max_dist and max_flee to 24, the salmon will only start fleeing within 3 blocks and will stop at 10 blocks away.
This can also be recreated easily by using the Ocelot behavior.json and setting max_dist and max_flee to 24. The ocelot will only begin to flee at 3 blocks away and will stop at 10 blocks.
Expected behavior:
With max_dist set higher, mobs will start to flee from farther away. With max_flee set higher, mobs will flee to a greater distance. These values seem to be capped or hardcoded to 3 and 10 blocks and the fields are ignored.
I have attached a simple behavior pack below which increases the max_dist and max_flee of the Ocelot, Fish (cod), and Salmon mobs to 24. All will start to flee when the player is within 3 blocks and will stop running at 10 blocks away.
This can also be seen in the vanilla behavior where the Ocelot has max_dist 10, but it does not begin to flee until the player is 3 blocks away.
Linked issues
Attachments
Comments 15


Please attach a behavior pack that can be used to reproduce this.

I added a simple behavior pack which increases the max_dist and max_flee of the Ocelot, Fish, and Salmon mobs. All will still only start for flee from 3 blocks away and will stop at 10 blocks despite the max_dist and max_flee values.
This can also be seen in vanilla with no behavior packs. The Ocelot behavior [ocelot | Microsoft Learn|https://learn.microsoft.com/en-us/minecraft/creator/reference/source/vanillabehaviorpack_snippets/entities/ocelot?view=minecraft-bedrock-stable] has 'behavior.avoid_mob_type' 'max_dist' set to 10, but it does not begin to flee until the player is within 3 blocks.

I added a simple behavior pack which increases the max_dist and max_flee of the Ocelot, Fish, and Salmon mobs. All will still only start for flee from 3 blocks away and will stop at 10 blocks despite the max_dist and max_flee values.
This can also be seen in vanilla with no behavior packs. The Ocelot behavior [ocelot | Microsoft Learn|https://learn.microsoft.com/en-us/minecraft/creator/reference/source/vanillabehaviorpack_snippets/entities/ocelot?view=minecraft-bedrock-stable] has 'behavior.avoid_mob_type' 'max_dist' set to 10, but it does not begin to flee until the player is within 3 blocks.

Part of the issue here is that throughout the data-driven behavior components and documentation the words “radius” and “distance” are used in a misleading and idiosyncratic way to mean the length of the side of a cube centered on the entity’s position. I have not been able to find a dictionary that lists this definition for “radius”, and it is obviously not what “distance” normally means.
The misleading use of “radius” and “distance” leads players and addon-makers to expect many distances to be double what they actually are in-game. The ocelot mentioned in the description is a good example: “max_dist”: 6, does not compute to “6 blocks from the player”; rather, it computes to “within a 6x6x6 volume centered on the ocelot’s position,” which in other words means 3 blocks from the player in each cardinal direction.
This can lead to custom content breaking in ways that are hard to debug. I once helped someone make dogs fetch items. They wanted dogs to pick up items within 1 block, so they set “goal_radius“: 1. This actually caused the dog to freeze about 50% of the time you dropped an item for it, because pathfinding works in block units and, unbeknownst to us for some hours of banging heads on the desk, the radius of 1 limited the dog to a 1/2 block reach, so it would freeze after pathing to an item and then being unable to reach it.
See also MCPE-153784.

If I understand correctly, the max_dist is the distance at which the entity should start to flee, and max_flee is the distance it will try to achieve from the target.
In that case, it should work with both set to the same value. If the value for both is 24, then when a player is within 24 blocks, the mob will try to get to 24 blocks distance. If player is 15 blocks away, the mob should start to flee to get 24 blocks separation.
I tried again with max_dist set to 16 and max_flee set to 32, but I am still getting the same behavior where max_dist seems to be 3 and max_flee seems to be 10. I also tried the inverse, but that had the same effect where the mob doesn't react until within 3 blocks and stops at 10 blocks away.
I believe neither of these parameters are getting used in any case for the mobs and the default values are always used.

Can confirm, Now I attached the affected world with same behaviour pack to test how mob flee distance measurements
[media]
Can also confirm. I've attached another world that can be used to reproduce the bug, but mine focuses on using fish rather than ocelots, as I find their behavior is easier to track, The world already has the addon attached, so you can just remove it after testing to compare the vanilla values to the modded ones.
The underlying issue does appear to be that the max_dist and max_flee parameters are somehow hardcoded and their default values cannot be overridden. This results in add-on makers not being able to customize them, and being stuck with the default max_dist range of 3 blocks and max_flee distance of 10 blocks.
Steps to reproduce:
Load one of the attached worlds: Jervie's handles ocelots, while mine focuses on fish. These reproduction steps only apply to my world, but the concept is the same and should be reproducible with his too.
In my world, you'll spawn behind a bedrock line, which illustrates the threshold where the vanilla hardcoded max_dist variable starts. Your starting point should always be behind the said line.
While standing behind the line, spawn a cod on the gold block in front of you.
Wait for the fish to swim 1 block closer to you, or walk a block closer to it for it to start fleeing. Then observe how many blocks away it ceases fleeing.
Repeat the same process but without the add-on enabled.
Observed results (with the add-on enabled):
If you or the fish don't get closer to each other, it won't flee from you.
If you or the fish do get closer to each other (1 block or more), it will flee from you. If it does start fleeing from you, it will swim exactly 10 blocks (the diamond blocks represent the 10-block mark) before it stops fleeing, as that is the hardcoded maximum distance.
Expected results (with the add-on enabled):
The fish will flee from you, as you're within its custom max_dist range.
The fish will flee from the player, regardless of whether you get closer to each other or not. Additionally, it will swim past the diamond blocks and continue to flee from you until it reaches its custom max_flee distance.

I can confirm the issue after working Jervie's fish test world and making a custom world + pack of my own.
In my world + pack I disabled fish wandering and flocking so that their only movement was from behavior.avoid_mob_type. My results were
Fish only moved when spawned within 3 blocks of the player, regardless of what max_dist was set to.
Fish always fled a random distance up to 16 blocks from the player, regardless of what max_flee was set to.
I also experimented with vanilla wolves, which have a max_dist of 25 to flee from llamas and move noticeably faster when fleeing.
Wolves only flee from llamas when spawned within 3 blocks.
Wolves flee a random distance but far less than 25 blocks from the llama.
Based on these and other tests it is clear that there is a default parameter that functions something like a "max_dist" and looks deceptively like the default max_dist of 3 blocks but is actually 6x6 square (or 6x6x6 cube) around the mob rather than a linear distance. I do not see any evidence that the default "max_flee" of 10 blocks is working at all, since the fish in my tests often fled to 16 blocks.

please fix ❤️