The bug
Using a lead on an iron golem changes their nature so that the will no longer attack hostiles, including a player that attacks them. Found this on an iron golem "farm" using a zombie; dragging 7 golems that were out of range so that they were within aggro and releasing them from the lead caused them to walk around in a somewhat glitchy way, with no apparent path finding (never really leaving the area they were dragged to), and not interested in chasing after the zombie. Lead two more zombies within range and the iron golems ignored them. I even attacked a golem myself and was not attacked.
Other iron golems in the village still act as normal. It only affects the iron golems that have been moved using leads.
To reproduce
Place a zombie inside of an iron golem trap
Summon an iron golem
Leash the iron golem
Unleash the iron golem
→ ✔ The iron golem will try to get to the zombie, but won't succeed, turn around sometimes, and it looks quite confused in generalClose and reopen the world
→ ❌ Now the iron golem is as angry onto the zombie as ever
Videos
Survival, village golems: https://youtu.be/sVl5fxA6GAY
Creative, self-built golems:
Code analysis
Code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 9
relates to 3
Attachments
Comments 7
Length of time leashed or distance plays a role, but I havent found the exact trigger. I have leashed them for smaller moves and had them seemingly behave as normal. So I created a new 1.15.1 world myself and re-tested; I think path-finding is more broken than the aggro behavior, and I think the former masks the latter. Because path-finding is compromised, I was under the belief that they wouldn't attack hostile mobs (or a hostile player), but I think it maybe they can't path-find to their target. I can stand next to a golem and punch it and it'll wallop me, but if I move away, it can't pursue. Likewise, a zombie in their range is ignored unless the zombie is actively attacking the golem, in which case the zombie puts itself in range, though the golem's ability to defend themselves still seems compromised vs an unaffected golem.
Also interesting observation that if I re-log, they are able to path-find again.
I have a similar issue but I have seen it more expansively than this as it happens to me with ANY mob that attacks hostile mobs. I have had this with self made iron golems, tamed wolves, wild wolves, all after the mobs are put on a lead. More information here:
I have a new development. I have tested it and while the bug does still seem to happen to Iron Golems it DOES NOT impact zoglins. After leashing and moving arround a zoglin (what produces this error) and the unleashing the zoglin, I found that the zoglin will still attack anything and its path finding ability does not seem to be damaged by this error.
Despite being 'leaded' the zoglin's path finding is not damaged unlike the Iron Golem.
(It should be noted I have found tamed wolves to produce this same error when 'leaded' so the error is not unique to Iron Golems; instead, the zoglin is unique in that it seems to be unaffected by the lead and still path finds correctly.)
i am having the same problem. I have to tie my iron golems or they go to the nearby village. I release the pillager's patrol coming, but they don't attack and my iron golems are heavily damaged, sometimes dying. For this reason, my iron resources have started to run out.
When any mob is attached with a lead, a field called restrictCenter
is set to the leash holder's position and another field called restrictRadius
stores the restriction distance which is set to 5 blocks when a mob is leashed. This field is tested for in various mob AI classes to check if a mob is allowed to navigate outside of the restrictRadius
from the restrictCenter
position and whether a mob should try to or continue to attack another mob if the target or the attacker is outside of this restriction. The issue is that when a mob has its lead removed, restrictRadius
is not reset to the sentinel value of -1 (which means the mob has no restriction) until the game is reloaded.
This is also the cause for MC-221754.
I tried this in a newly created world in 1.15.1 and it did not happen, how long did you use the lead on them?