Jump to content

[Version 1.19] Add custom (sound) setting to Minecraft's GUI pause menu


Recommended Posts

Posted (edited)

Hello,

I would like to add a custom setting to the game's GUI pause menu that adjusts the volume of my mod’s custom sounds. More specifically, I want to add to the pre-existing game’s volume settings, and my custom setting would be a slider. How should I get started? Should I look at the SoundOptionsScreen class?

Edited by LeeCrafts
  • LeeCrafts changed the title to [Version 1.19] Add custom (sound) setting to Minecraft's GUI pause menu
Posted

The SoundOptionsScreen will show you how to code the Slider.

To actually modify the screen you will need to register for forge's ScreenEvent(s) in your FMLClientSetup.

For example, you can respond to the Init.Post event by checking if it is the PauseScreen then adding your slider.

Your problems are probably going to be:

* Some other mod does the same thing and you end up drawing over each other

* Somebody runs the game in large gui mode and your slider doesn't fit on the screen

So you may want to be intelligent about where you add your slider, based on for example what widgets are actually on the screen.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted (edited)
16 hours ago, warjort said:

To actually modify the screen you will need to register for forge's ScreenEvent(s) in your FMLClientSetup.

Do you mean I have to do the registering in FMLClientSetupEvent? If so, would I have to use DeferredRegister<ScreenEvent> or something of the like?

So far, I tried subscribing to ScreenEvent.InitScreenEvent.Post and checked if event.getScreen() instanceof PauseScreen, but it didn't seem to work. Maybe it's because I have not registered for the ScreenEvent(s). Code below:

@Mod.EventBusSubscriber(modid = GoofyGoober.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
  
...
  
    public static void onInitScreenEvent(ScreenEvent.InitScreenEvent.Post event) {
        System.out.println("init screen"); // does not get printed
        if (event.getScreen() instanceof PauseScreen pauseScreen) {
            System.out.println("game paused"); // does not get printed either
        }
    }

...
Edited by LeeCrafts
Posted

Haha my bad, thanks.

15 hours ago, LeeCrafts said:

Do you mean I have to do the registering in FMLClientSetupEvent? If so, would I have to use DeferredRegister<ScreenEvent> or something of the like?

But is there anything I need to do regarding FMLClientSetupEvent?

Posted
10 minutes ago, LeeCrafts said:

But is there anything I need to do regarding FMLClientSetupEvent?

create an EventHandler as you have done it for all other events,

inside FMLClientSetupEvent you need to use #enqueueWork since Screens are not thread safe

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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