A macOS app written in Swift that enables the Game Mode (introduced in macOS Sonoma) for Java-based games such as Minecraft.
When creating the game process, change the executable path to /path/to/GameStub.app/Contents/Resources/launcher and prepend the absolute path of java to the arguments. This will activate the Game Mode.
If your launcher supports setting a "Wrapper Command", simply enter /path/to/GameStub.app/Contents/Resources/launcher into the field.
launcherstarts the main executable (which we callrunner) viaNSWorkspace.openApplication.- After
runneris registered as a Game App, it replaces the current process with thejavaprocess usingexecv, allowing the game to inherit the Game App identity.
Warning
When Game Mode is active, macOS may reduce the performance of the launcher process. If runner is a child or descendant process of the launcher, its performance will also be degraded.
launcher uses NSWorkspace.openApplication to entrust runner to launchd to avoid game performance degradation. However, this approach prevents log and return value transmission.
We may add a Java Agent in future versions to transmit stdout, stderr, and the exit code to launcher via a socket, which will then forward them to the launcher.
I don't know, it's probably... magic ✨