Fabric API

Fabric API

106M Downloads

Particle type registry being completely overwritten on client

Fourmisain opened this issue ยท 3 comments

commented

I am not sure if I'm at the right place and if this truly is a fabric issue, I am also making a lot of assumptions on how stuff works (especially registry synchronization), so please correct me if you notice something off.

Original issues:

RandomMcSomethin/fallingleaves#2 (comment)
paulevsGitch/BetterEnd#14

Description/Recap:

Falling Leaves is a simple mod that adds custom particles that fall from leaves.
It is intended to work fully client side and it does work both in singleplayer and multiplayer - until BetterEnd is installed.

When BetterEnd is installed on the server, the falling leaves don't appear in multiplayer - singleplayer is fine.

What happens in multiplayer is that the leaves get added to the world, but the particles are never actually created because the custom particle type does not exist in the particle type registry anymore, despite being registered beforehand.

I tried changing the falling leaves' rawId to 126 to ensure it wouldn't be overwritten due to synchronization, but it appears the particle type registry is being completely replaced and thus the lookup of the associated particle factory fails.

It turns out that commenting out these two lines:
https://github.com/paulevsGitch/BetterEnd/blob/70f5e3e02457cc0e5dafea8fede12d05c0f26064/src/main/java/ru/betterend/world/biome/BiomeMegalakeGrove.java#L19
https://github.com/paulevsGitch/BetterEnd/blob/c3a7a59d785bddc51523e2f842ce13ed2882619d/src/main/java/ru/betterend/world/biome/BiomeFoggyMushroomland.java#L21
'fixes' the issue.
Note that BetterEnd adds other biomes that use .setParticles (which ultimately sets BiomeEffects.particleConfig) but they use vanilla particle types and that has no effect on falling leaves.

Interpretation/Guesswork:

My guess is that since BetterEnd adds biomes with custom particles , the server-side particle type registry is changed and then synchronized with the client.
Unexpectedly, this synchronization doesn't seem to merge the server registry into the client one (by overwriting or remapping ids) but it seems to completely replace it.
I think this means that this breaks any client-side mod adding particles.
Potentially, this could apply to some other registries as well(?)

Potential fixes

In this case, Falling Leaves would probably be okay if it registered particle types after the server-client synchronization, though I have no idea if this is (currently) possible and it might cause other issues.

A 'proper' fix would probably be remapping particle type ids on the client when doing the server-client synchronization.

Thanks for your time reading this mess.

commented

I will investigate this shortly

commented

Thanks a lot for looking into this, you are correct the current behaviour of the registry sync is to silently remove registries entries that the server did not send over!

I have brefiely tested the PR, but feel free to do you own testing.

See my PR here: #1179

commented

I just want to add, that after we updated AoF3 with Better End, being near anything that creates a lot of particles now tanks FPS but a lot. It get super laggy. Block breakers form astromine, indrev chopper and biomass generators. Before that update, no one had FPS losses from those machines. I'm glad I found something that might point to the problem.