Jump to content

Adding additional SoundCategory(s)


Recommended Posts

I'm looking for some help to get this added as a proper PR to forge. I have a working class for adding the sound category that will work in a mod. I've tested this with with 1.9.4 and 1.10+. I have not yet tried to setup a Forge dev environment but the videos that cpw made make it look simple enough. I still pretty much a java rookies, but learning more as I go. Your comments are welcome.


The class below allows the addition of a new sound category. It uses nothing more that the existing Forge utility classes for reflections and enums. You new sound category will have all the attributes of the vanilla sound categories.

That is:

  • A volume control for the category displays in the vanilla "Music & Sound Options..." dialog
  • The volume level is saved and loaded from the client options.txt file.
  • The Vanilla SoundHandler will correctly use the custom sound category

Here's the class on GitHub. There are some notes about using it in the comments


I've also included the code below.


I have not started work to see what's required to make the vanilla "Music & Sound Options..." dialog behave correctly. Ideally it would work like the "Controls..." dialog. That is the volume controls could be scrolled. So far I've not seen anyone other mod add a custom SoundCategory / volume control. But it might be useful for other mods. And as a part of Forge mod authors could use it without fear of causing issues with vanilla or other mods.


For the mxTune mod I'm working on I wanted a separate sound category for the instruments. I can get by without this PR, but I wanted to share this with the community.




package net.aeronica.mods.mxtune.sound;

import java.util.Map;

import com.google.common.collect.Maps;

import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.SoundCategory;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

* MODSoundCategory
* Add a new CONSTANT and reference name to net.minecraft.util.SoundCategory
* This allows the display of a volume control in the "Music & Sound Options" dialog.
* Unfortunately the GuiScreenOptionsSounds dialog does not auto size
* properly and move the Done button lower on the screen.
* To initialize the class create an instance during FMLPreInitializationEvent in
* the file with the @Mod annotation or your common proxy class.
* Usage example: static final SoundCategory SC_MXTUNE = MODSoundCategory.add("MXTUNE");
* The language file key is "soundCategory.mxtune"
* The game settings "options.txt" key is "soundCategory_mxtune"
* To use the MXTUNE enum constant in code it must be referenced by name because
* SoundCategory.MXTUNE does not exist at compile time.
*   e.g. SoundCategory.getByName("mxtune");
* @author Paul Boese aka Aeronica
public class MODSoundCategory
    private static final String SRG_soundLevels = "field_186714_aM";
    private static final String SRG_SOUND_CATEGORIES = "field_187961_k";
    private static Map<SoundCategory, Float> soundLevels;
    private static MODSoundCategory instance = new MODSoundCategory();
    private MODSoundCategory() {}
    public static MODSoundCategory getInstance() {return instance;}
     * The "name" should be your MODID or MODID_name if your mod adds more
     * than one SoundCategory.
     * @param name
     * @return a unique SoundCategory
     * @throws fatal error if name is not unique
    public static SoundCategory add(String name)
        Map<String, SoundCategory> SOUND_CATEGORIES;

        String constantName;
        String referenceName;
        SoundCategory soundCategory;
        constantName = new String(name.toUpperCase().replace(" ", ""));
        referenceName = new String(constantName.toLowerCase());
        soundCategory =  EnumHelper.addEnum(SoundCategory.class , constantName, new Class[]{String.class}, new Object[]{referenceName});
        SOUND_CATEGORIES = ObfuscationReflectionHelper.getPrivateValue(SoundCategory.class, SoundCategory.VOICE ,"SOUND_CATEGORIES", SRG_SOUND_CATEGORIES);
        if (SOUND_CATEGORIES.containsKey(referenceName))
            throw new Error("Clash in Sound Category name pools! Cannot insert " + constantName);
        SOUND_CATEGORIES.put(referenceName, soundCategory);
        if (FMLLaunchHandler.side() == Side.CLIENT) setSoundLevels();

        return soundCategory;

    /** Game sound level options settings only exist on the client side */
    private static void setSoundLevels()
        /** SoundCategory now contains 'name' sound category so build a new map */
        soundLevels = Maps.newEnumMap(SoundCategory.class);
        /** Replace the map in the GameSettings.class */
        ObfuscationReflectionHelper.setPrivateValue(GameSettings.class, Minecraft.getMinecraft().gameSettings, soundLevels, "soundLevels", SRG_soundLevels);



From this point on I'll just use bare bones minimal/incomplete code...

Creating custom sound categories:



package net.aeronica.mods.modtest;

import net.aeronica.mods.mod189stuff.audio.MODSoundCategory;
import net.aeronica.mods.mod189stuff.caps.ISimple;
import net.minecraft.util.SoundCategory;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = Main.MODID, name = Main.MODNAME, version = Main.VERSION)
public class Main {
public static final String MODID = "modtest";
public static final String MODNAME = "Mod Testing";
public static final String VERSION = "1.10.2-0.1.0-dev";

public static Main instance;

public static SoundCategory MODTEST_A;
public static SoundCategory MODTEST_B;
public static SoundCategory MODTEST_C;
public static SoundCategory MODTEST_D;
public static SoundCategory MODTEST_E;
public static SoundCategory MODTEST_F;
public static SoundCategory MODTEST_G;
public static SoundCategory MODTEST_H;

public void preInit(FMLPreInitializationEvent event) {
        // You need to register these on the the client and server side. A good place is your common proxy.
MODTEST_A = MODSoundCategory.add("MODTEST_A");
        MODTEST_B = MODSoundCategory.add("MODTEST_B");
        MODTEST_C = MODSoundCategory.add("MODTEST_C");
        MODTEST_D = MODSoundCategory.add("MODTEST_D");
        MODTEST_E = MODSoundCategory.add("MODTEST_E");
        MODTEST_F = MODSoundCategory.add("MODTEST_F");
        MODTEST_G = MODSoundCategory.add("MODTEST_G");
        MODTEST_H = MODSoundCategory.add("MODTEST_H");

public void init(FMLInitializationEvent event) {

public void postInit(FMLPostInitializationEvent event) {



Here's one way to use the custom sound category


// some item
. . .
    public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
        if (!worldIn.isRemote)
            // worldIn.playSound(EntityPlayer, BlockPos, SoundEvent, SoundCategory, volume, pitch)
            worldIn.playSound(null, new BlockPos(playerIn.posX,playerIn.posY,playerIn.posZ), 
                    SoundEvents.ENTITY_FIREWORK_BLAST, SoundCategory.getByName("modtest_a"), 1F, 1F);
            // instead of SoundCategory.getByName("modtest_a") you could use Main.MODTEST_A
. . .


If you add or change  or remove your custom sound categories in your mod, vanilla will gracefully ignore and overwrite the settings. No worries about a crash for a missing custom sound category.


If you goof up and add a conflicting sound category you will crash MC. Oops!, but of course as a developer you should know better right!

Section of the client side options.txt where game settings are saved.





Here's a demo of it in use:

[embed=425,349]<iframe width="560" height="315" src="https://www.youtube.com/embed/A5lhR-pP4Mg" frameborder="0" allowfullscreen></iframe>[/embed]


Here's how the current 1.10.2 vanilla "Music & Sounds Options.." looks after adding several more unique sound categories. Yup, the dialog needs some loving.










Link to comment
Share on other sites

  • 1 month later...

This is a very good feature. I would definitely use it if I update my Mod to 1.11 and it's there. (I would use it in 1.7.10 too, but I don't think the forge team is willing to add stuff to 1.7 :'().


One thing that I think needs to get added is a submenu. So you have a button "Mod Sound Sliders" which opens a submenu with a list of all modded sound sliders. (Similar to keybindings). Every mod is a major category, and maybe allow mods to add a minor category within the mod.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • [13abr.2024 23:04:08.876] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, thehappiestdeus, --version, 1.20.1-forge-47.2.23, --gameDir, C:\Users\********\AppData\Roaming\.minecraft, --assetsDir, C:\Users\********\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 6947100bd693327a9d73af48e609bc8e, --accessToken, ????????, --clientId, 0, --xuid, 0, --userType, msa, --versionType, release, --width, 854, --height, 480, --launchTarget, forgeclient, --fml.forgeVersion, 47.2.23, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] [13abr.2024 23:04:08.900] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.9 10.0.9 main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 11 arch amd64 version 10.0 [13abr.2024 23:04:12.324] [main/INFO] [net.minecraftforge.fml.loading.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow [13abr.2024 23:04:12.626] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 [13abr.2024 23:04:15.807] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 [13abr.2024 23:04:16.706] [pool-4-thread-1/INFO] [EARLYDISPLAY/]: GL info: NVIDIA GeForce GTX 1050/PCIe/SSE2 GL version 4.6.0 NVIDIA 551.61, NVIDIA Corporation [13abr.2024 23:04:18.403] [main/WARN] [gg.essential.loader.stage1.EssentialLoaderBase/]: Found newer Essential Loader (stage2) version 1.6.0 [stable], skipping at user request [13abr.2024 23:04:18.405] [main/INFO] [gg.essential.loader.stage1.EssentialLoaderBase/]: Starting Essential Loader (stage2) version 1.4.1 (4b3b87be87d34916028dffa85460d085) [stable] [13abr.2024 23:04:18.631] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/********/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar#100!/ Service=ModLauncher Env=CLIENT [13abr.2024 23:04:18.982] [main/WARN] [gg.essential.loader.stage2.EssentialLoaderBase/]: Found newer Essential version [stable], skipping at user request [13abr.2024 23:04:20.965] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.20.1-47.2.23\fmlcore-1.20.1-47.2.23.jar is missing mods.toml file [13abr.2024 23:04:20.974] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.20.1-47.2.23\javafmllanguage-1.20.1-47.2.23.jar is missing mods.toml file [13abr.2024 23:04:20.981] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.20.1-47.2.23\lowcodelanguage-1.20.1-47.2.23.jar is missing mods.toml file [13abr.2024 23:04:20.991] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\********\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.20.1-47.2.23\mclanguage-1.20.1-47.2.23.jar is missing mods.toml file [13abr.2024 23:04:22.047] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select two dependency jars from JarJar which have the same identification: Mod File: and Mod File: . Using Mod File: [13abr.2024 23:04:22.056] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: curios. Using Mod File: C:\Users\********\AppData\Roaming\.minecraft\mods\curios-forge-5.7.2 1.20.1.jar [13abr.2024 23:04:22.056] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: resourcefullib. Using Mod File: C:\Users\********\AppData\Roaming\.minecraft\mods\resourcefullib-forge-1.20.1-2.1.24.jar [13abr.2024 23:04:22.058] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 22 dependencies adding them to mods collection [13abr.2024 23:04:31.937] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [13abr.2024 23:04:31.989] [main/ERROR] [mixin/]: Mixin config firstperson.mixins.json does not specify "minVersion" property [13abr.2024 23:04:32.169] [main/ERROR] [mixin/]: Mixin config entity_model_features.mixins.json does not specify "minVersion" property [13abr.2024 23:04:33.081] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [com.sonicether.soundphysics.MixinConnector] [13abr.2024 23:04:33.089] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.20.1-forge-47.2.23, --gameDir, C:\Users\********\AppData\Roaming\.minecraft, --assetsDir, C:\Users\********\AppData\Roaming\.minecraft\assets, --uuid, 6947100bd693327a9d73af48e609bc8e, --username, thehappiestdeus, --assetIndex, 5, --accessToken, ????????, --clientId, 0, --xuid, 0, --userType, msa, --versionType, release, --width, 854, --height, 480] [13abr.2024 23:04:33.497] [main/INFO] [ModernFix/]: Loaded configuration file for ModernFix 5.15.0 mc1.20.1: 77 options available, 0 override(s) found [13abr.2024 23:04:33.500] [main/INFO] [ModernFix/]: Applying Nashorn fix [13abr.2024 23:04:33.544] [main/INFO] [ModernFix/]: Applied Forge config corruption patch [13abr.2024 23:04:33.869] [main/INFO] [Embeddium/]: Loaded configuration file for Embeddium: 172 options available, 3 override(s) found [13abr.2024 23:04:33.873] [main/INFO] [Embeddium-GraphicsAdapterProbe/]: Searching for graphics cards... [13abr.2024 23:04:34.631] [main/INFO] [Embeddium-GraphicsAdapterProbe/]: Found graphics card: GraphicsAdapterInfo[vendor=NVIDIA, name=NVIDIA GeForce GTX 1050, version=DriverVersion=] [13abr.2024 23:04:34.632] [main/INFO] [Embeddium-GraphicsAdapterProbe/]: Found graphics card: GraphicsAdapterInfo[vendor=INTEL, name=Intel(R) UHD Graphics 630, version=DriverVersion=] [13abr.2024 23:04:34.644] [main/WARN] [Embeddium-Workarounds/]: Sodium has applied one or more workarounds to prevent crashes or other issues on your system: [NVIDIA_THREADED_OPTIMIZATIONS] [13abr.2024 23:04:34.645] [main/WARN] [Embeddium-Workarounds/]: This is not necessarily an issue, but it may result in certain features or optimizations being disabled. You can sometimes fix these issues by upgrading your graphics driver. [13abr.2024 23:04:34.668] [main/WARN] [mixin/]: Reference map 'entity_model_features_forge_1.20.1-forge-refmap.json' for entity_model_features.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:34.868] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:34.879] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras_forge.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.002] [main/WARN] [mixin/]: Reference map 'nitrogen_internals.refmap.json' for nitrogen_internals.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.135] [main/INFO] [Radium Config/]: Loaded configuration file for Radium: 125 options available, 1 override(s) found [13abr.2024 23:04:35.152] [main/WARN] [mixin/]: Reference map 'trashslot.refmap.json' for trashslot.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.360] [main/WARN] [mixin/]: Reference map '${refmap_target}refmap.json' for corgilib.forge.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.404] [main/WARN] [mixin/]: Reference map 'coroutil.refmap.json' for coroutil.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.599] [main/WARN] [mixin/]: Reference map 'chiselsandbits.refmap.json' for chisels-and-bits.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.634] [main/WARN] [mixin/]: Reference map 'cristellib-forge-refmap.json' for cristellib.mixins.json could not be read. If this is a development environment you can ignore this message [13abr.2024 23:04:35.822] [main/INFO] [Essential Logger - Plugin/]: Starting Essential v1.3.1.1 (#3a090c5c88) [stable] [13abr.2024 23:04:40.482] [main/WARN] [mixin/]: Error loading class: dev/tr7zw/skinlayers/render/CustomizableModelPart (java.lang.ClassNotFoundException: dev.tr7zw.skinlayers.render.CustomizableModelPart) [13abr.2024 23:04:42.465] [main/WARN] [Radium Config/]: Force-disabling mixin 'alloc.blockstate.StateMixin' as option 'mixin.alloc.blockstate' (added by mods [ferritecore]) disables it and children [13abr.2024 23:04:43.118] [main/WARN] [mixin/]: Error loading class: vectorwing/farmersdelight/client/renderer/HangingCanvasSignRenderer (java.lang.ClassNotFoundException: vectorwing.farmersdelight.client.renderer.HangingCanvasSignRenderer) [13abr.2024 23:04:43.129] [main/WARN] [mixin/]: Error loading class: vectorwing/farmersdelight/client/renderer/CanvasSignRenderer (java.lang.ClassNotFoundException: vectorwing.farmersdelight.client.renderer.CanvasSignRenderer) [13abr.2024 23:04:45.276] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.world.sky.WorldRendererMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.277] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.world.sky.ClientWorldMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.278] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.world.sky.BackgroundRendererMixin' as rule 'mixin.features.render.world.sky' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.285] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.gui.font.GlyphRendererMixin' as rule 'mixin.features.render.gui.font' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.285] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.gui.font.FontSetMixin' as rule 'mixin.features.render.gui.font' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.286] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.shadows.EntityRenderDispatcherMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.286] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.fast_render.ModelPartMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.288] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.fast_render.CuboidMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [13abr.2024 23:04:45.291] [main/WARN] [Embeddium/]: Force-disabling mixin 'features.render.entity.cull.EntityRendererMixin' as rule 'mixin.features.render.entity' (added by mods [oculus]) disables it and children [13abr.2024 23:04:46.387] [main/INFO] [MixinExtras|Service/]: Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.3.5). [13abr.2024 23:04:51.658] [pool-6-thread-1/INFO] [net.minecraft.server.Bootstrap/]: ModernFix reached bootstrap stage (53.35 s after launch) [13abr.2024 23:04:52.021] [pool-6-thread-1/WARN] [mixin/]: @Final field delegatesByName:Ljava/util/Map; in modernfix-forge.mixins.json:perf.forge_registry_alloc.ForgeRegistryMixin should be final [13abr.2024 23:04:52.023] [pool-6-thread-1/WARN] [mixin/]: @Final field delegatesByValue:Ljava/util/Map; in modernfix-forge.mixins.json:perf.forge_registry_alloc.ForgeRegistryMixin should be final [13abr.2024 23:04:52.518] [pool-6-thread-1/INFO] [ModernFix/]: Injecting BlockStateBase cache population hook into getNeighborPathNodeType from me.jellysquid.mods.lithium.mixin.ai.pathing.AbstractBlockStateMixin [13abr.2024 23:04:52.519] [pool-6-thread-1/INFO] [ModernFix/]: Injecting BlockStateBase cache population hook into getPathNodeType from me.jellysquid.mods.lithium.mixin.ai.pathing.AbstractBlockStateMixin [13abr.2024 23:04:52.520] [pool-6-thread-1/INFO] [ModernFix/]: Injecting BlockStateBase cache population hook into getAllFlags from me.jellysquid.mods.lithium.mixin.util.block_tracking.AbstractBlockStateMixin [13abr.2024 23:04:57.799] [pool-6-thread-1/INFO] [net.minecraft.server.Bootstrap/]: Vanilla bootstrap took 6125 milliseconds  
    • k i opened rit and luanched. no matter what launcher i use, it always says 2 mods loaded, but it has 0 mdos loaded. i tried several times with multiMC
    • i downloaded it. what do i do next? how do i open the luancher
    • It happened suddenly to me and a friend and we don't know how to fix it Blocks like the lava, the "UGH" sound, the door sound, etc.
  • Topics

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.