Jump to content

Recommended Posts

Posted

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. 

Posted

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()));
    }
}

 

Posted (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 by geekles
Posted

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. 

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.