public final class ModDiscoverer
extends java.lang.Object
Loader which is not available early.
Builds a bidirectional mod-id and file mapping used for dependency checking.| Modifier and Type | Method and Description |
|---|---|
static void |
applyForceLoadAsMod()
Honors the
ForceLoadAsMod manifest key for every jar collected during discover(). |
static void |
discover()
Gathers the same candidate set FML resolves in
CoreModManager.discoverCoreMods(java.io.File, net.minecraft.launchwrapper.LaunchClassLoader) (the flat
mods/ and mods/<version> directories, command-line --mods, and contained
dependencies extracted into memory_repo or the libraries directory) and supplements it with
classpath entries already on the LaunchClassLoader for the dev environment. |
static void |
flushRescuedTweakClasses() |
static java.lang.String |
getModFromSource(java.io.File source)
Returns the id of the mod owning the given jar.
|
static java.util.Set<java.lang.String> |
getModsFromSource(java.io.File source)
Returns the ids of the mod(s) owning the given jar, resolved during
discover() from its
mcmod.info or, when that declares none, its @Mod annotation. |
static java.util.Set<java.io.File> |
getModSources(java.lang.String modId)
Returns the jars that declare the given mod id.
|
static java.util.Set<java.lang.String> |
getPresentMods()
Returns the ids of every mod discovered across all scanned jars.
|
static boolean |
isModPresent(java.lang.String modId)
Returns whether any discovered jar declares the given mod id.
|
static void |
rescueDroppedCoremods()
Loads the
FMLCorePlugin of every jar that also declares a TweakClass,
which Forge's CoreModManager.discoverCoreMods(java.io.File, net.minecraft.launchwrapper.LaunchClassLoader) skips. |
public static boolean isModPresent(java.lang.String modId)
modId - the mod id to testtrue if at least one scanned jar declares the idpublic static java.util.Set<java.lang.String> getPresentMods()
public static java.util.Set<java.io.File> getModSources(java.lang.String modId)
modId - the mod id to resolvepublic static java.lang.String getModFromSource(java.io.File source)
getModsFromSource(File) instead if you need every declared id.source - the jar to resolvemcmod.info, else its @Mod annotation),
or null if the jar declares no modpublic static java.util.Set<java.lang.String> getModsFromSource(java.io.File source)
discover() from its
mcmod.info or, when that declares none, its @Mod annotation. A jar may declare more
than one mod (via mcmod.info's modList), hence the set.source - the jar to inspectpublic static void applyForceLoadAsMod()
ForceLoadAsMod manifest key for every jar collected during discover().
Replicating the only behavior the removed MixinPlatformAgentFMLLegacy still provided which was
un-ignoring jars so Forge would load it as mods. Forge unconditionally adds cascading-tweaker jars
to its ignored list and never reaches its own FMLCorePluginContainsFMLMod handling for them.
Without this functionality those jars would silently fail to load as mods.
Must run after CoreModManager.discoverCoreMods(java.io.File, net.minecraft.launchwrapper.LaunchClassLoader) has fully populated the ignored list, i.e. from
injectData and not from the plugin constructor.public static void rescueDroppedCoremods()
FMLCorePlugin of every jar that also declares a TweakClass,
which Forge's CoreModManager.discoverCoreMods(java.io.File, net.minecraft.launchwrapper.LaunchClassLoader) skips.
The removed MixinPlatformAgentFMLLegacy re-injected these via CoreModManager.loadCoreMod
and this replicates that. This must run from CoremodsRescuer's constructor while LaunchWrapper is
iterating TweakClasses, because rescued coremods such as Sledgehammer may add directly to
Tweaks. Any TweakClasses added during rescue are captured and replayed later to avoid
corrupting LaunchWrapper's active TweakClasses iterator.public static void flushRescuedTweakClasses()
public static void discover()
CoreModManager.discoverCoreMods(java.io.File, net.minecraft.launchwrapper.LaunchClassLoader) (the flat
mods/ and mods/<version> directories, command-line --mods, and contained
dependencies extracted into memory_repo or the libraries directory) and supplements it with
classpath entries already on the LaunchClassLoader for the dev environment.
Must be called once before FML's own mod discovery runs.