The before 1.19 villager iron golem last seen timer was 30 seconds (600 ticks).
In 1.19 and 1.19.1 pre-releases the timer is 35 seconds (700 ticks).
It appears that the spawn attempt countdown timer is resetting before the last seen golem countdown timer is finishing resulting in the villager waiting for the next spawn attempt, or another 100 ticks.
This appears to be a bug in the calculation order.
A youtube video showing in more detail.
https://www.youtube.com/watch?v=DehjbNoEY30
You can easily recreate this bug by using a repeating command block to kill golems as soon as they spawn and timing the time between spawns.
Code analysis
Code analyses by @unknown can be found in this comment and this comment.
Linked issues
Attachments
Comments 10
I tested this issue with carpetmod's /tick freeze/step and /ai_tracker.
Effectively, villagers are missing the spawning window by just 1 tick, making us having to wait for another 100 ticks to get the golem to spawn.
I compared the Brain class of 1.18.2 and 1.19, the method tickMemories() on 1.18.2 calls memory.tick() first and then memory.isExpired() and on 1.19 is the othey way around, memory.isExpired() first and then memory.tick(). So the information on the video is accurate.
(These are names are from the Fabric mappings, actual names may be different)
Forcing to call memory.tick() first and then memory.isExpired() on 1.19 (Using Fabric's mixins) I get a constant Iron Golem every 600 ticks or 30 seconds (assuming spawn attempt succeded) like we used to.
@unknown You are correct, this is in Brain#forgetOutdatedMemories()
using Mojang mappings. I think the new code makes more sense though, why would you tick a memory that has been expired? Maybe there is another issue?
I do agree with ampolive, looks like the correct way is the one on 1.19 and the extra 100 ticks is not an intended behavior. When I get a free time I’ll try to dig further into it, something is off
Let's suppose we have 3 villagers meeting all the conditions for panic summon a golem. The memory of last seen golem is about to expire and it's the begining of tick when it get's summoned, all 3 memories are 1 and the flow is the following:
Brain#tick(world, villagerA) is called
Executes Brain#tickMemories() -> villagerA memory gets decresed by 1, meaning last seen memories is 0 now
Then it executes Brain#updateTasks(world, villagerA) -> here, the condition is met, iron golem get's summoned and all 3 memories are reset to 600 (VillagerEntity#summonGolem rewrites all the memories of the 3 villagers)
Brain#tick(world, villagerA) is over: villagerA, villagerB and villagerC memory is 600
Brain#tick(world, villagerB) is called
Executes Brain#tickMemories() -> villagerB memory gets decresed by 1, meaning last seen memories is 599 now
Brain#updateTasks(world, villagerB) -> task fails because iron golem got summoned and the memory is not 0
Brain#tick(world, villagerB) is over: villagerA and VillagerC is 600, villagerB memory is 599
Brain#tick(world, villagerC) is called
Executes Brain#tickMemories() -> villagerC memory gets decresed by 1, meaning last seen memories is 599 now
Brain#updateTasks(world, villagerC) -> task fails because iron golem got summoned and the memory is not 0
Brain#tick(world, villagerC) is over: villagerA memory is 600, villagerB and VillagerC memory is 599
This flow causes a desync in the memory between the 3 villagers, so when the next time that a villager can spawn a golem because its memory is 0, it can't because the others are on 1s
This is my theory I could made a mistake. I'm attaching a screenshot of my observations: This is the end of next tick after the golem spawned
[media]
Hi! Glad to see the awesome work you two are putting into this issue.
I just wanted to comment that based on carpet mod's ai_tracker, it seems like 1.18.2 also have golem last seen timer out of sync per your last comment. I've been working on a separate video and been using ai_tracker with iron golems a lot and it is very common in 1.18.2 to have one villager with a golem-last-seen timer 1-tick less than the other two villagers. I know it is not the same exact as what you explained above, but it is a desync non-the less (best to check youself though, I am writing this from work from memory so may be mixed up).
The point is, the 100 spawn attempt timer is not added on top of the 600 tick cooldown timer in 1.18.2 despite the desync between the villagers.
It's perhaps something else that should be fixed, but maybe not the root cause of this bug.
I may be wrong though, it's very clear that you are much more qualified on this topic than me, just a general observation to help if possible. :-]
The same class change also effected piglins which used to barter every 120gt and now only barter every 121gt. The change was made in 22w12a
@unknown: I had modified this ticket to include this, but eventually decided to revert the modifications since this ticket has already been triaged and assigned a Mojang Priority. Please create a separate ticket for the bartering issue.
made a dedicated report for the bartering issue but the cause is literally the same class change that caused this. for reference the change happened in 22w12a
I tested this myself and consistently get times of about 34 to 35 seconds between spawns in vanilla, but my times might be a little bit off.