SoundBlocker module

SoundBlocker: Minecraft 26.3 cheat module, full source for every implementation (1 client: OfflineClient).

1 implementationMISC

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

OfflineClientMISCsrc/main/java/com/jellypudding/offlineclient/modules/misc/SoundBlocker.javaJava · 71 lines · 2.7 KB

Mutes the sounds you pick.

SettingsSoundsBlock allKeep menusKeep music
SoundBlocker.javaJava · Minecraft 26.2 · 71 lines · 2.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.misc;
2
3
import com.jellypudding.offlineclient.module.Category;
4
import com.jellypudding.offlineclient.module.Module;
5
import com.jellypudding.offlineclient.setting.BoolSetting;
6
import com.jellypudding.offlineclient.setting.RegistryListSetting;
7
import net.minecraft.client.resources.sounds.SoundInstance;
8
import net.minecraft.core.registries.BuiltInRegistries;
9
import net.minecraft.sounds.SoundEvent;
10
import net.minecraft.sounds.SoundEvents;
11
import net.minecraft.sounds.SoundSource;
12
13
import java.util.List;
14
import java.util.concurrent.atomic.AtomicInteger;
15
16
// Silences the sounds you pick. The sound engine is the last stop for every sound.
17
// Weather and other sounds the client makes itself are caught too.
18
public final class SoundBlocker extends Module {
19
20
    private final RegistryListSetting<SoundEvent> sounds = new RegistryListSetting<>("Sounds",
21
        "The sounds to mute. Click to pick them.", BuiltInRegistries.SOUND_EVENT,
22
        List.of(SoundEvents.GENERIC_EXPLODE.value(), SoundEvents.RESPAWN_ANCHOR_DEPLETE.value()));
23
    private final BoolSetting blockAll = new BoolSetting("Block all",
24
        "Mute everything instead of the chosen sounds.", false);
25
    private final BoolSetting keepUi = new BoolSetting("Keep menus",
26
        "Lets button clicks and menu sounds through.", true)
27
        .under(blockAll);
28
    private final BoolSetting keepMusic = new BoolSetting("Keep music",
29
        "Lets the background music through.", true)
30
        .under(blockAll);
31
32
    private final AtomicInteger muted = new AtomicInteger();
33
34
    public SoundBlocker() {
35
        super("SoundBlocker", "Mutes the sounds you pick.", Category.MISC);
36
        addSettings(sounds, blockAll, keepUi, keepMusic);
37
        searchTags("mute", "no sound", "silence", "crystal spam", "no rain");
38
    }
39
40
    @Override
41
    public String getSuffix() {
42
        int count = muted.get();
43
        return count == 0 ? null : count + " muted";
44
    }
45
46
    @Override
47
    protected void onEnable() {
48
        muted.set(0);
49
    }
50
51
    // Called from the sound engine before every sound starts.
52
    public boolean shouldMute(SoundInstance instance) {
53
        if (!isEnabled()) {
54
            return false;
55
        }
56
        if (blockAll.isOn()) {
57
            SoundSource source = instance.getSource();
58
            if (keepUi.isOn() && source == SoundSource.UI) {
59
                return false;
60
            }
61
            if (keepMusic.isOn() && source == SoundSource.MUSIC) {
62
                return false;
63
            }
64
        } else if (!sounds.contains(BuiltInRegistries.SOUND_EVENT.getValue(instance.getIdentifier()))) {
65
            return false;
66
        }
67
        muted.incrementAndGet();
68
        return true;
69
    }
70
}
71