Posted July 10, 20223 yr 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 July 10, 20223 yr by LeeCrafts
July 10, 20223 yr 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.
July 11, 20223 yr Author 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 July 11, 20223 yr by LeeCrafts
July 11, 20223 yr Author 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?
July 11, 20223 yr 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.