LeeCrafts Posted July 10, 2022 Posted July 10, 2022 (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 July 10, 2022 by LeeCrafts Quote
warjort Posted July 10, 2022 Posted July 10, 2022 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. Quote 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.
LeeCrafts Posted July 11, 2022 Author Posted July 11, 2022 (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 July 11, 2022 by LeeCrafts Quote
Luis_ST Posted July 11, 2022 Posted July 11, 2022 you forgot the @SubscribeEvent annotation on onInitScreenEvent Quote
LeeCrafts Posted July 11, 2022 Author Posted July 11, 2022 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? Quote
Luis_ST Posted July 11, 2022 Posted July 11, 2022 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 Quote
Recommended Posts
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.