Jump to content

[1.15-1.16] [FG4] Service files in mod


hohserg

Recommended Posts

I doing my annotation processor which generate service file for current mod.

And I doing my mod which looking for such services in all mods in modpack.

Forge can provide location of mod, whether it is an jar or in-dev-folder.

The problem is getting actual location of service file.

For jar is trivially and work fine.

For in-dev-folder it's hard: File provided by Forge is not only one folder with mod files (look screenshot)

It's really problematic and now I'm stumped.

Any ideas?

Also I can consider other ways instead of services.

Related code:

https://github.com/ElegantNetworking/ElegantNetworking_1.16/blob/master/src/main/java/hohserg/elegant/networking/impl/Main.java#L18-L20

https://github.com/ElegantNetworking/ElegantNetworking_1.16/blob/master/build.gradle#L111

Debug screenshot:

image.thumb.png.fa870d62c6b9e37c8010a0c0137e9b51.png

Some note: for example I made mod which looking for services and mod within services in one bottle, and you can see it on screenshot, but it's irrelevant to the problem.

Edited by hohserg
Link to comment
Share on other sites

  • hohserg changed the title to [1.15-1.16] [FG4] Service files in mod

If I use ServiceLoader, how it will work with multiple jars with identically named service files?

As I know, ServiceLoader resolves existence of multiple same service files by taking first.

It's also can resolve by ClassLoader, but I dont know, is Forge use separeted class loaders for each mod and is it be true it future.

Also, ServiceLoader gives instances of classes which specified in service, but I'm need to instances of Class<?> of these classes.

So, standard utility is not look as appropriate

Link to comment
Share on other sites

52 minutes ago, diesieben07 said:

all of them

Well. How to determine which class does the mod relate to?

52 minutes ago, diesieben07 said:

make a service interface that provides that Class

Look excessive

Maybe it's a bad idea to call this thing as 'service'. Service is a most similar thing.

Generally thing which I need is a file with list of names of classes which been found(and generated) by my annotation processor and readable by my mod. And multiple mods in one modpack can contain such file

 

  

52 minutes ago, diesieben07 said:

What?

Sorry, it's my wrong understanding of ServiceLoader 

Edited by hohserg
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.