geekles Posted June 3, 2019 Posted June 3, 2019 In my mod, especially for testing, I want to have the client still running in the background regardless if I am actively playing it or I am simply browsing the web and it is running in the background without having the pause menu show up the second I click away. In game settings, there is an option to disable the "pauseOnLostFocus" feature which works during tests within my IntelliJ development environment. However, if I build the mod and actually run it using my client, I find that this feature oddly enough no longer works. The second I click away (alt + tab) the game pauses. I have decompiled the mod I have added into the mod folder to ensure that the built mod is in fact the latest version, therefore it is unclear to me why pauseOnLostFocus would be utilized differently in both environments. Quote
geekles Posted June 3, 2019 Author Posted June 3, 2019 Very simple, but here it is. The final line in the constructor is all that it really is. public class ExperimentalModification { public static final String MOD_ID = "experimentalmodification"; // Directly reference a log4j logger. public static final Logger LOGGER = LogManager.getLogger(); public ExperimentalModification() { // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); // Register the enqueueIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); // Register the processIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); // Register the doClientStuff method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); Minecraft.getInstance().gameSettings.pauseOnLostFocus = false; } private void setup(final FMLCommonSetupEvent event) { // some preinit code } private void doClientStuff(final FMLClientSetupEvent event) { // do something that can only be done on the client LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings); } private void enqueueIMC(final InterModEnqueueEvent event) { // some example code to dispatch IMC to another mod InterModComms.sendTo("experimental", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world"; }); } private void processIMC(final InterModProcessEvent event) { // some example code to receive and process InterModComms from other mods LOGGER.info("Got IMC {}", event.getIMCStream(). map(m -> m.getMessageSupplier().get()). collect(Collectors.toList())); } } Quote
geekles Posted June 3, 2019 Author Posted June 3, 2019 (edited) I assume it does this differently then say within the development environment? Because I have had no issues while testing it, but the second I install the mod into my actual client and run it, I can't appear to use this setting. Edited June 3, 2019 by geekles Quote
geekles Posted June 3, 2019 Author Posted June 3, 2019 So I gave what you said a try, and it didn't work, however what you said did make sense so I simply tried changing the gamesetting at a much later time, such as when I join a server, and now it works. I'll probably have to add some sort of minor delay after the FMLClientSetupEvent is triggered. Quote
suppergerrie2 Posted June 6, 2019 Posted June 6, 2019 Any reason you dont just do "F3+P" to enable it? It even gets saved so you only have to do it once, and if you want to turn it off just press "F3+P" again 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.