[1.16.5][Collective-2.50][StraySpawn-1.3] Crash when going to Repurposed Structures's Underground Bastion
TelepathicGrunt opened this issue ยท 11 comments
In 1.16.5 single player on 36.2.2 Forge, I was testing mods individually to try and reproduce a different bug (bug report for that coming up soon once I pin down that other bug). So I made a world using only Blame, Collective 2.50, and Repurposed Structures. Entered world and teleported to Underground Bastion. I closed the game and then added strayspawn_1.16.5-1.3 and tried to enter the world but got this crash instead:
Seems to be some sort of concurrency issue in Collective but I cannot be of more help than that sorry. Hopefully this is not some sort of race condition and that this stacktrace is enough to pin down the issue.
More testing and the other bug I mentioned is actually this one. So it appears that Stray Spawn registers a condition to Collective to try and swap Skeletons with Strays. However, Collective uses the wrong method to spawn the stray and ends up either crashing the worldgen thread or deadlocks it. It's random between the two behavior it seems. After I got a deadlock, I did a thread dump and this was the result that shows what collective method is the cause.
https://paste.ee/p/t1GEy
It's basically a repeat of this issue: #526
So the reason why it happens when going to Repurposed Structures's Underground Bastion is because my jigsaw structure has some skeletons saved as nbt and configuredfeatures. And these spawn whent he structure is being made during world generation and collective detects this and tries to spawn the stray unsafely. That's what killed the game.
This could be theoretically be reproducible with just a datapack that replaces the golem nbt for villages with a skeleton on and the player goes to a village with Stray Spawn on.
This should be enough info to help you out! addFreshEntityWithPassengers is the safe method yeah. It's what Witch Huts uses to spawn their witches safely during worldgen
Edit: Husk Spawn is gonna have the same issue with any structure with Zombies saved in NBT it seems
Edited post as I was originally testing with an old version of collective from the user without realizing. Updated it to 2.50 and still got same issue.
Thanks! I've made the changes to addFreshEntityWithPassengers in Collective. As I'm still keeping the 1.12.2 version updated, does the same issue occur there or is the codebase different so that it doesn't cause deadlocks?
I've released Collective v2.51 which should hopefully solve the issue you were having. Thanks for your work towards figuring it out and providing the solution! I appreciate it
https://www.curseforge.com/minecraft/mc-mods/collective/files
Thanks! I've made the changes to addFreshEntityWithPassengers in Collective. As I'm still keeping the 1.12.2 version updated, does the same issue occur there or is the codebase different so that it doesn't cause deadlocks?
I do not know if 1.12 has the same issue. You could try checking out the Witch Hut code in 1.12 to see if you are using the same method. That was originally how I realized I was using the wrong method when trying to debug why I was freezing when some mobs in a configuredfeature in 1.15
Seems like it just uses spawnEntity, so should be all good! :)
EntityWitch entitywitch = new EntityWitch(worldIn);
entitywitch.enablePersistence();
entitywitch.setLocationAndAngles((double)l + 0.5D, (double)i1, (double)k + 0.5D, 0.0F, 0.0F);
entitywitch.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(l, i1, k)), (IEntityLivingData)null);
worldIn.spawnEntity(entitywitch);
@ricksouth Can you re-open this issue report? I had the person update collective but the issue still happens. I tested myself with:
collective-1.16.5-2.54.jar
repurposed_structures_forge-3.1.0+1.16.5
strayspawn_1.16.5-1.4
and did /locate repurpsoed_structures:underground_bastion and teleported to it. This is the crash I got: https://paste.ee/p/PRHte
Log when I fly to the structure instead of teleporting to it: https://paste.ee/p/abYUs
It looks like this entity for loop in ChunkManager seems to dislike where you are adding the entity I think. Not sure
I never seen this specific crash before so I cant be of much help sorry. Very weird.
Would changing the spawn code to the next tick in a TickEvent work do you think?
Hope you're doing well @TelepathicGrunt! I've just released an update to Collective (2.62) which now adds new entities on the next world tick instead of immediately when another spawns in the EntityJoinWorldEvent. If you have time, could you check if this fixes the issues you were having?