karix_2_34547

Develop a client-side mod that dynamically adjusts all game sounds based on the current tick rate, slowing down audio playback proportionally as the tick rate decreases.

Kodari AI
KodariApr 17 at 6:45 pm 6,473 (v2)
TickRateAudioSync
A client-side Fabric mod that dynamically adjusts all in-game sound playback speed proportionally to the current tick rate. As the server tick rate slows (e.g., during lag), all sounds slow down to match, creating a cohesive audio-visual experience. Uses a mixin to intercept sound engine pitch calculations and applies a real-time multiplier derived from the current tick rate relative to the standard 20 TPS baseline.

Now I have enough context. Here’s my plan:

  • Use a ClientTickEvents listener to read client.world.getTickManager().getTickRate() each tick and cache a pitch multiplier (tickRate / 20.0f)

  • Mixin into AbstractSoundInstance.getPitch() to multiply the returned pitch by that cached value

  • Pure client-side mod with split source sets

TickRateAudioSync
A client-side Fabric mod that dynamically adjusts all in-game sound playback speed proportionally to the current server tick rate. As the server tick rate slows (e.g., during lag or slow-motion commands), all sounds slow down in real time to match. Uses a mixin on AbstractSoundInstance to scale pitch by the ratio of current tick rate to the standard 20 TPS baseline, updated every client tick.

The mod registers a END_CLIENT_TICK listener that reads world.getTickManager().getTickRate() every tick and caches the ratio to the 20 TPS baseline in TickRatePitchManager. The AbstractSoundInstanceMixin then intercepts every getPitch() call and scales the returned value by that cached multiplier, causing all sounds to slow down or speed up in sync with the current tick rate.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
8 150
src/client/java/com/tickrateaudiosync/TickRateAudioSyncClient.java
package com.tickrateaudiosync;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;

@Environment(EnvType.CLIENT)
public class TickRateAudioSyncClient implements ClientModInitializer {

    private static final float BASE_TICK_RATE = 20.0f;

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            if (client.world == null) {
                TickRatePitchManager.setMultiplier(1.0f);
                return;
            }
            float currentTickRate = client.world.getTickManager().getTickRate();
            TickRatePitchManager.setMultiplier(currentTickRate / BASE_TICK_RATE);
        });
    }
}