Posted June 13, 20214 yr 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: 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 June 13, 20214 yr by hohserg
June 13, 20214 yr 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
June 13, 20214 yr 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 June 13, 20214 yr by hohserg
June 14, 20214 yr 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.