
Infinite loop causing by BiomeDensityByLoadedChunk when stepping near chunk
azaneNH37 opened this issue ยท 0 comments
Description
Encounter this bug when trying mixin into this mod and later reproduce this in production environment with Integrated Server.
Sadly i haven't got time to check both the bug and might-be solution on a common server.
Following are my reproduction procedures.
Firstly, it is necessary to enable both of the following configurations.{"isBiomeDensityByChunk": true,"isBiomeDensityUseLoadedChunk": true}
Secondly, do a long /tp
(almost 100% success rate) in the game or restart the game completely(occasionally success)
Then we might spot the cloud in the game disappeared or stayed still in the previous location, and a thread keeping running as shown in VisualVM.
Maybe Reason and Solution
When looking through the code, finds the while
loop around line 138 (common/src/main/java/com/rimo/sfcr/core/CloudData.java)
i am not 100% percent sure but it might be quite likely that when doing the /tp
or leaving the game, the chunks were unloaded while the thread keeps processing. Thus leading to a permanently True
in while condition.
Following is my mixin trying to solve the issue, it cannot be the best solution but it worked well on my machine.
just simply add a check to fail the while
when the position is a little too far from the original point
@Redirect(method = "collectCloudData(DDFF)V",at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientChunkCache;hasChunk(II)Z"))
private boolean azane$mixinBugFix(ClientChunkCache instance, int chunkX, int chunkZ)
{
if(azane$gp0_lock)return instance.hasChunk(chunkX,chunkZ);
return instance.hasChunk(chunkX,chunkZ) || Math.abs(azane$gp0_scrollX - chunkX*16) + Math.abs(azane$gp0_scrollZ - chunkZ*16) > (double)(azane$gp0_cloudblocksize * width * 2);
}