Naturally Charged Creepers (Fabric)

Naturally Charged Creepers (Fabric)

87.6k Downloads

[Realistic Bees 1.16.5-1.2] Bees spawning as part of world gen will deadlock when realisticbees.events.BeeEvent.onBeeSpawn runs

TelepathicGrunt opened this issue ยท 3 comments

commented

This may be related to this issue report as well #470

Basically, if Realistic Bees is put on alongside my mod called The Bumblezone, entering my dimension always leads to the game hanging forever because my dimension spawns bees as part of world generation.
https://www.curseforge.com/minecraft/mc-mods/the-bumblezone-forge

I opened up VisualVM and did a thread dump to find out what caused the main thread to deadlock and it seems to be caused by com.natamus.realisticbees.events.BeeEvent.onBeeSpawn(BeeEvent.java:74) calling ServerWorld.func_217376_c (addEntity).
https://paste.ee/p/hPMBE

Apparently, this occurring during world generation is unsafe and will deadlock the world. By doing addEntity from the ServerWorld while the chunk is being made, that method will call getChunk which deadlocks the game because getChunk will wait until the chunk is finished but we are calling that method while the chunk is still being made. Instead, try using world.spawnEntityAndPassengers as that method is safe to call during worldgen from a WorldGenRegion. The event should have the WorldGenRegion passed in instead of the ServerWorld.

Hopefully this helps!

commented

I can't find world.spawnEntityAndPassengers within the new Mojang mappings. Do you know what it's called?

commented

Ah it's addFreshEntityWithPassengers, I'll see if I can get it to work :)

commented

Fixed in version 1.5 of Realistic Bees. Thanks for providing the solution @TelepathicGrunt! Using serverworld.addFreshEntityWithPassengers(entity)

https://www.curseforge.com/minecraft/mc-mods/realistic-bees/files/all