FabricMC / fabric-loader

Fabric's mostly-version-independent mod loader.
Apache License 2.0
617 stars 262 forks source link

[Feature] FMJ Spec API #956

Open SHsuperCM opened 2 months ago

SHsuperCM commented 2 months ago

Following the conversation in #loom I wanted to bring this into an issue so I wont forget about it.

This is a feature request for either fabric loader or the fabric project as a whole in a separate "fmj spec" library that fabric loader would use. The idea is to have a proper public api for the fmj specification and for dealing with fmj files. I believe the issue should be here as fabric loader is the main project that defines and uses the fmj file.

Currently the fmj is accessed directly through the json. What I am seeking is a layer of abstraction for interacting with it that is the same across all users of the spec, whether it be fabric loader, Loom or other 3rd party libraries needing to work with fmj.

When Loom builds a fabric mod, it adds included jar entries manually by modifying the built fmj with gson. It also pulls interface injection entries as well as access widener paths(for taws) when loading mod dependencies. The system for it is completely separate from the code in floader that implements the fmj spec which could lead to breakages. In addition, mods' buildscripts modify the version of the built mod manually using a gradle processResources which requires accessing and modifying through mentioning the file by name and expanding text in the file.

Another use case would be 3rd party libraries, an example for this would be my own plugin Fletching Table which, among other things, adds the ability to append entrypoints to the fmj which are collected from an annotation processor. Again, the way I have to access the entrypoints in the fmj is very informal and relies on the assumption of fmj specs.

The api I'm looking for should be able to read fmj spec, keeping a consistent access abstraction across (future)spec versions. The api should allow modification as well as generation from scratch, to allow plugins such as Loom, 3rd party plugins or even the project's buildscript to change or append metadata to the built mod. Or even go as far as "datagenning" the entire fmj from the buildscript.

If added

All of the above points are of course up for debate but these were the intended uses from within the fabric project itself.

Thank you for coming to my ted talk.