McModLauncher / modlauncher

Java 21 mod launcher
Other
171 stars 47 forks source link

ILaunchPluginService: preLaunch callback? #35

Closed Mumfrey closed 5 years ago

Mumfrey commented 5 years ago

Preamble

It's taken me a long time to get the new Mixin version to a point where I'm happy with it, mostly due to personal commitments, so I'd like to apologise for the radio silence from my end. The approach I have taken while developing Mixin for ModLauncher is to work around things as they are, since I felt that until I was happy with the engineering of the solution that asking for changes to ModLauncher was frivolous. I wanted to make sure I was asking for the right things.

To this end, I've wrapped the work-arounds and reflection-based shims into a single class which I've named Internals. This issue pertains to one of the duties offloaded to Internals, identifying the moment immediately prior to startup.

The Issue

As you may recall, Mixin processing happens in phases in order that Mixins can be loaded, conformed to the current environment, and are then ready for application during the unfolding of the lifecycle phase.

With the current design, Mixin begins the only phase (DEFAULT) as the game starts. Mixins which were previously obtained by the platform agents - eg. from FML mod containers, classpath entries, or the command line - are then selected into the environment ready for application.

Currently the only way I have discovered to detect this event is via the rather crufty method of log watching, and simply hunting for the "Launching Target" message that ML emits prior to start.

This isn't the most elegant solution in the world, so it would be helpful if either ILaunchPluginService or ITransformationService could be notified immediately prior to the call to launch service launch with some kind of preLaunch callback.

Would this be possible? I can think of reasons it might not be desirable to put it into ITransformationService but if it could be added to ILaunchPluginService that would allow me to nuke this particular hack.


As a side note, obviously Internals contains some other cruft, but rather than make a "kitchen sink" issue I figured it was more appropriate to list these as separate issues for your consideration.

cpw commented 5 years ago

I can definitely arrange a call to launch plugins notifying about impending launch. Not sure what context you'd want here though that you don't already get earlier?

Mumfrey commented 5 years ago

No additional context is required, it's purely a notification that "all the pregame stuff has ended, switch to application". As discussed I will flesh out the Mixin service extension object to receive the mod containers from FML so that the container discovery can be made more robust.

Under LaunchWrapper this point used to be detected via the call to getLaunchArguments but under ML there is no direct indication that all the pre-launch has completed and to proceed to the next phase.