Iron golem causes lag when it can't attack its enemies
The bug
When an Iron Golem is caged with line of sight to the target mob but can't attack due to blocks being in the way it creates large amounts of server lag.
Attached in a video of the bug, 1st part is the lag subsiding after kill the iron golem, the second part is the lag subsiding after killing the pillagers.
Video
Linked Issues
Created Issue:
Iron Golem Causes Lag When It Can't Attack Enemy
When an Iron Golem is caged with line of sight to the target mob but can't attack due to blocks being in the way it creates large amounts of server lag.
Attached in a video of the bug, 1st part is the lag subsiding after kill the iron golem, the second part is the lag subsiding after killing the pillagers.
Environment
Windows 10, Java Edition
Windows 10, Java Edition
When an Iron Golem is caged with line of sight to the target mob but can't attack due to blocks being in the way it creates large amounts of server lag.
Attached in a video of the bug, 1st part is the lag subsiding after kill the iron golem, the second part is the lag subsiding after killing the pillagers.
The bug
When an Iron Golem is caged with line of sight to the target mob but can't attack due to blocks being in the way it creates large amounts of server lag.
Attached in a video of the bug, 1st part is the lag subsiding after kill the iron golem, the second part is the lag subsiding after killing the pillagers.
Video
IronGolemCausesLagWhenItCan'tAttackEnemyIron golem causes lag when it can't attack its enemies
relates to
As MC-182325 has been fixed, this should be no longer of an issue for you. Please check if this still affects you in 1.16-pre6 or later.


It does not look like your fps changes significantly. How does this bug affect you?
Once the TPS gets into the red as shown in the video mob movements becomes jittery and almost non existent, yes my FPS is fine and I'm able to move around the area but I'm no longer able to interact with my surroundings.
Though I'm seeing more of an fps-drop (from 60 to ~45-50) than a tps-drop using this repro, it definitely affects performance.
Affects 1.16 pre release 2
The8BitMonkey would you mind uploading your world?
I've failed to reproduce this on 20w18a snapshot even using the exact same cage you built and with both less and more combinations of golems / pillagers.
The8BitMonkey Just a reminder to send the world for testing. As much as I'd hate to we would otherwise need to resolve this as a no-repro, but I'd love to try out on your world first.
Sure it’s not pillager pathfinding lag?
Could well be, but I cannot reproduce the lag the reporter is seeing. We've done a few optimizations to the pathfinding recently which could help out a bit, but I failed to repro even on the 20w18a snapshot was reported on.
That's why I'm interested in seeing the world to see if any of the recent changes we've made fixes this or if we need to do more.
Hi, sorry for the delay in reply, had to return to work and not been able to check messages.
I've attached the world file generated in 1.16 Pre-Release 5 (latest as of posting) and still experiencing the bug.
Did a few tests myself and it would seem that the issue does lie with the Golem as the spikes only start to happen once the iron golem takes notices of the Pillagers, while the pillagers are just trying to attack the golem but before it notices them there are no spikes but as soon as the iron golem starts to track one of the pillagers but can't attack them the spikes start to go up.
Iron_Golem_Lag_Bug - 1.16 Pre-Release 5.zip
Here is a screenshot of the issue just before I exited the game and saved it to attach here: 2020-06-12_21.49.09.png
If it's at all helpful my system specs are:
Using the latest MC launcher and latest snapshot (pre-release) version
As a test that it wasn't my system at fault, I opened the world on a second PC and this was the result after summoning 10 or 12 pillagers, the spike started once again after the iron golem registered the pillager but couldn't attack
Awesome, will take a look at this today. Thanks for your report!
So I think I got the hang of this. Apparently the pillagers doesn't see the Iron Golem through the fence which in itself is a bit of problem. They could obviously see it at some point in time, otherwise they would not be able to obtain their target.
What this leads to is constant pathfinding trying to get closer to the golem every tick causing the lag.
The quick fix to this is to limit the number of path updates, but in the long run we'd also like to take a look at both the Pillager AI here as well as why they can't see through the fences.
Thanks The8BitMonkey for the detailed report and sending your world!
That problem could also relate to
MC-64370