Minecraft wiki entry for Village, associated text: The naturally spawned iron golem attacks the player if the player hits a villager (using a weapon, a fishing rod‌[Bedrock Edition only], snowballs, eggs, or your fists) in front of the golem. The iron golem will be neutral again if the player runs out of the iron golem's line of sight or far enough from it for a while, although hitting the iron golem makes it hostile for longer. This also applies to iron golems that are summoned by a command or iron golems that spawn regularly if a village population is big enough. Iron golems will get provoked again if a player's popularity score is -15 or less and goes into the line-of-sight with the golem, even when the player went away from the golem.