Package net.neoforged.fml.loading
Class FMLLoader
java.lang.Object
net.neoforged.fml.loading.FMLLoader
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final recordprivate class -
Field Summary
FieldsModifier and TypeFieldDescription(package private) @Nullable IBindingsProviderprivate final ClassProcessorAuditLogprivate final List<AutoCloseable> Additional user-supplied resources that will be closed, before this loader itself is closed.private static final AtomicReference<@Nullable FMLLoader> private ClassLoaderThe current tail of the class-loader chain.(package private) FMLLoader.DiscoveryResultprivate final net.neoforged.api.distmarker.Distprivate final Pathprivate @Nullable ModuleLayerprivate LanguageProviderLoaderprivate LoadingModListprivate static final org.slf4j.Loggerprivate final @Nullable ClassLoaderThe context class-loader that will be restored when the loader is closed.private final List<AutoCloseable> Resources owned by this loader, such as opened URL classloaders, which will be closed alongside the loader.private final booleanprivate final ProgramArgsprivate VersionInfoprivate VersionSupportMatrix -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateFMLLoader(ClassLoader currentClassLoader, String[] programArgs, net.neoforged.api.distmarker.Dist dist, boolean production, Path gameDir) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCloseCallback(AutoCloseable callback) Adds a callback that will be called once, when this loader is about to close.private voidappendLoader(String loaderName, List<JarContents> jars) Loads the given services into a URL classloader.private TransformingClassLoaderbuildTransformingLoader(ClassProcessorSet classProcessorSet, ClassProcessorAuditLog auditTrail, List<JarContentsModule> content) voidclose()static FMLLoadercreate(@Nullable Instrumentation instrumentation, StartupArgs startupArgs) static FMLLoadercreate(StartupArgs startupArgs) private static ClassProcessorcreateAccessTransformerService(FMLLoader.DiscoveryResult discoveryResult) private static ClassProcessorSetcreateClassProcessorSet(StartupArgs startupArgs, FMLLoader.LaunchContextAdapter launchContext, FMLLoader.DiscoveryResult discoveryResult, MixinFacade mixinFacade) private static net.neoforged.api.distmarker.DistdetectDist(ClassLoader classLoader) private static booleandetectProduction(ClassLoader classLoader) getBasePaths(JarContents contents, boolean ignoreFilter) static FMLLoaderstatic @Nullable FMLLoadernet.neoforged.api.distmarker.DistgetDist()static LanguageProviderLoader@Nullable IModFilegetModFileByClass(Class<?> clazz) Tries to get the mod file that a given class belongs to.private static StringgetModuleNameList(Configuration cf, List<JarContentsModule> content) Please note that the returned version information can be incomplete until mod discovery has been completed.(package private) VersionSupportMatrixbooleanprivate voidloadEarlyServices(StartupArgs startupArgs) private voidloadPlugins(List<IModFileInfo> plugins) private voidprivate voidIf any location being added is already on the classpath, we add a masking classloader to ensure that resources are not double-reported when using getResources/getResource.private FMLLoader.DiscoveryResultprivate static <T> TrunOffThread(Supplier<T> supplier)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
current
-
originalClassLoader
The context class-loader that will be restored when the loader is closed. -
currentClassLoader
The current tail of the class-loader chain. It is moved whenever a new set of Jars is loaded. -
ownedResources
Resources owned by this loader, such as opened URL classloaders, which will be closed alongside the loader. -
closeCallbacks
Additional user-supplied resources that will be closed, before this loader itself is closed. -
programArgs
-
languageProviderLoader
-
dist
private final net.neoforged.api.distmarker.Dist dist -
loadingModList
-
gameDir
-
locatedPaths
-
versionInfo
-
versionSupportMatrix
-
backgroundScanHandler
-
production
private final boolean production -
gameLayer
-
earlyServicesJars
-
discoveryResult
-
classTransformerAuditLog
-
bindings
-
-
Constructor Details
-
FMLLoader
private FMLLoader(ClassLoader currentClassLoader, String[] programArgs, net.neoforged.api.distmarker.Dist dist, boolean production, Path gameDir)
-
-
Method Details
-
getClassTransformerAuditLog
-
getModFileByClass
Tries to get the mod file that a given class belongs to.- Returns:
- Null, if the class doesn't belong to a mod file.
-
addCloseCallback
Adds a callback that will be called once, when this loader is about to close.Mod files and class-loaders will not be closed yet when the callback is called, allowing for class-loading to occur normally.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
makeCurrent
private void makeCurrent() -
getCurrentClassLoader
-
getProgramArgs
-
getBindings
-
create
-
create
public static FMLLoader create(@Nullable @Nullable Instrumentation instrumentation, StartupArgs startupArgs) -
createClassProcessorSet
private static ClassProcessorSet createClassProcessorSet(StartupArgs startupArgs, FMLLoader.LaunchContextAdapter launchContext, FMLLoader.DiscoveryResult discoveryResult, MixinFacade mixinFacade) -
createAccessTransformerService
private static ClassProcessor createAccessTransformerService(FMLLoader.DiscoveryResult discoveryResult) -
buildTransformingLoader
private TransformingClassLoader buildTransformingLoader(ClassProcessorSet classProcessorSet, ClassProcessorAuditLog auditTrail, List<JarContentsModule> content) -
maskContentAlreadyOnClasspath
If any location being added is already on the classpath, we add a masking classloader to ensure that resources are not double-reported when using getResources/getResource.The primary purpose of this is in mod and NeoForge development environments, where IDEs put the mod on the app classpath, but we also add it as content to the game layer. This method is responsible for setting up a classloader that prevents getResource/getResources from reporting Jar resources for both the jar on the App classpath and on the transforming classloader.
-
getBasePaths
-
getModuleNameList
-
detectDist
-
detectProduction
-
loadEarlyServices
-
loadPlugins
-
appendLoader
Loads the given services into a URL classloader. -
runDiscovery
-
runOffThread
-
getLanguageLoadingProvider
-
getCurrent
-
getCurrentOrNull
-
getDist
public net.neoforged.api.distmarker.Dist getDist() -
getLoadingModList
- Throws:
IllegalStateException- if the loading mod list hasn't been built yet.
-
getGameDir
-
isProduction
public boolean isProduction() -
getGameLayer
-
getVersionInfo
Please note that the returned version information can be incomplete until mod discovery has been completed. This is only relevant for early FML services. -
getVersionSupportMatrix
VersionSupportMatrix getVersionSupportMatrix()
-