neoforged / FancyModLoader

The fancy mod loader for NeoForged
Other
62 stars 31 forks source link

Unable to recognize lib-mod's services in dev environment #191

Open USS-Shenzhou opened 1 month ago

USS-Shenzhou commented 1 month ago

I'm currently developing a lib mod and have added an implementation of ITransformationService, an implementation of ICoreMod and corresponding services files. They work perfectly when I launch the game in both dev/production environment.

However, when I implement this lib-mod in another project (by normal gradle implementation from mavenLocal), FML's ServiceLoader seems fails to recognize/find the services provided by the lib mod in dev environment (it doesn't occur in production environment). I was wondering if this requires additional configuration, or is it intentional, or a bug?

My dev environment is the same as MDK-1.21-NeoGradle.

lukebemish commented 1 month ago

Is your file a mod file? (it shouldn't be, those services load at a higher up layer) Have you set up the correct FMLModType in the manifest? Can you share your actual source code or at least the jar in question?

USS-Shenzhou commented 1 month ago
  1. My jar is also a mod file. (So do you mean I must split my single file into two part, the normal and the core, and players must install 2 files?)
  2. I did not know anything about FMLModType before. Will it solve the must-split question by setting it to GAMELIBRARY?
  3. My code is here. I deleted the services files and turned into another worse-performance way as a temp solution after I opened this issue.

ps. I also tried using jij and shadow to avoid letting players install 2 files but both ways failed either.

lukebemish commented 1 month ago
  1. No, you can have one file jar-in-jar the other.
  2. Not GAMELIBRARY, that loads on the same layer as mods. I think LIBRARY might work? I'm unsure what layer those services are on, might need to be on the service layer stuff.

FML services load in a different layer than mods. So if your file is a mod file, It's not going to have FML services discovered from it. You have to provide those services in something on the appropriate layer.

USS-Shenzhou commented 3 weeks ago

Thx, I will try jij and setting FMLModType.