Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

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

  • Author
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

  • Author

I found a pretty thing:

`IModLocator#findPath`

It's look as good solve to get actual location of "service" files for each mod

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.