Fallen-Breath / conditional-mixin

Use annotation to conditionally apply your mixins
GNU Lesser General Public License v3.0
25 stars 5 forks source link

Support for (Neo)Forge #4

Closed RubixDev closed 3 months ago

RubixDev commented 4 months ago

It would be really nice to have this available for Forge and NeoForge as well. I have a multiplatform Architectury project but sadly cannot use this as it only works for Fabric atm.

As far as I can tell, most of this mods code doesn't really depend on Fabric already, so I might give this a go myself.

Fallen-Breath commented 4 months ago

This mod utilizes fabric loader's versioning api for version check, which should be the only place that relies on fabric

RubixDev commented 4 months ago

I've started implementing support for forge, but stumbled upon a rather big problem: the version predicates that conditional mixin uses is directly the one from the Fabric loader, and it relies on its parser. Forge on the other hand declares version ranges according to the apache version spec. That means that in a forge environment the parser for the currently used version predicate strings is unavailable. So to add cross-platform support we would have to decouple the version predicate stuff from the fabric loader. What are your thoughts on this?

Fallen-Breath commented 4 months ago

yeah, as you pointed out, to make it multi-loader support, it's necessary to extract and separate the mod version related stuffs from the main codebase. One possible approach is refactoring the project into a common subproject (requires mixin only) + serveral platform specialized subproject (for fabric, forge, etc.)

Another problem is about the versionPredicate syntax design. Possible workarounds:

  1. Keep using the current fabric syntax and perform translation to the target platform. Compatibly with the current design, but might be strange for forge users
  2. Simlply use the syntax that the platform provides. Disadvantage: in multi-platform projects, an annotation instance with version predicate cannot be directly reused in different platforms
  3. Design a new universal syntax, and translate to the target platform. tho I'll prefer 1. than this
  4. Shadows let's say fabric's version checking codes into the mod, and use it for all platforms. A bit too tricky for me
Fallen-Breath commented 3 months ago

Close as PR #5 is merged