Avoidable stuttering when using updateMovingSounds=true
briansemrau opened this issue ยท 6 comments
Bug description
When playing with update_moving_sounds=true
, I get significant stuttering (~60ms frame time vs 16ms median)
Versions
- Minecraft version: 1.19.2
- Mod version: 1.0.16
- Fabric
I was wondering why this was happening, so I glanced at the source code:
Yeah, that'll do it. This should be reworked to stagger sound updates across every tick.
Suggested fix:
- if (minecraft.level != null && minecraft.level.getGameTime() % 5 == 0) {
+ if (minecraft.level != null && (minecraft.level.getGameTime() + sound.getId().hashCode()) % 5 == 0) {
Ah, I quickly assumed that getId
would return a UUID, not a name. My bad. I suppose a randomized int could be added to SoundInstance as a mixin.
I don't have the built tools set up to test any solution locally, so feel free to make the PR if you like.
Yes, we are aware of that issue but we haven't investigated that yet. Your solution looks good! I personally wouldn't use the ID of the sound as it might be the same for sounds that get played multiple times.
Do you want to make a PR or should I do it?
It's now up on curse and modrinth. I also added a config value for the actual interval (5 by default).