As of 1.14, iron golems use to target raiders during raids, as in 1.16.200, iron golems can't detect raiders far away anymore, it causes the raiders to kill the villagers if iron golems aren't detecting them far away
Separated ticket MCPE-121894
Expected Results: Iron golems should detect them far away
Observed Results: Iron golems doesn't detect them
Reproduce Steps:
Spawn a lot of iron golems and villagers
Trigger a raid
Find the raiders where they spawned
The only changes to iron golems' base targeting behavior (
minecraft:behavior.nearest_attackable_target) from 1.14 to now are related to Hoglins and Zoglins. They do not automatically target pillagers, and they only target monsters from 10 blocks away. They do have a behavior to defend the village from attackers, but as far as I can tell it would only make them target an illager after it hits a villager within 16 blocks of the iron golem. They can target a mob from 64 blocks away only if they are hit by that mob.There is no indication on the wiki, either, that Iron Golems would spontaneously hunt down raiders outside of the village.