net.minecraftforge.fml.common.API Java Examples
The following examples show how to use
net.minecraftforge.fml.common.API.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassSourceCollector.java From OpenModsLib with MIT License | 5 votes |
public ClassMeta getClassInfo(Class<?> cls) { final Package pkg = cls.getPackage(); URL loadedFrom = null; try { loadedFrom = cls.getProtectionDomain().getCodeSource().getLocation(); } catch (Throwable t) { Log.warn(t, "Failed to get source for %s", cls); } final API apiAnnotation = pkg.getAnnotation(API.class); final ApiInfo apiInfo = apiAnnotation != null? new ApiInfo(apiAnnotation) : null; Map<File, Set<String>> mods = Maps.newHashMap(); for (ModCandidate candidate : table.getCandidatesFor(pkg.getName())) { if (!candidate.getClassList().contains(cls.getName().replace('.', '/'))) continue; final File candidateFile = candidate.getModContainer(); Set<String> modIds = Sets.newHashSet(); mods.put(candidateFile, modIds); for (ModContainer mod : candidate.getContainedMods()) modIds.add(mod.getModId()); } return new ClassMeta(cls, loadedFrom, apiInfo, mods); }
Example #2
Source File: ClassSourceCollector.java From OpenModsLib with MIT License | 4 votes |
public ApiInfo(API api) { this.api = api.provides(); this.owner = api.owner(); this.version = api.apiVersion(); }