Interface IModFile

All Known Implementing Classes:
ModFile

@NonExtendable public interface IModFile
Represents a single "mod" file in the runtime.

Although these are known as "Mod"-Files, they do not always represent mods. However, they should be more treated as an extension or modification of minecraft. And as such can contain any number of things, like language loaders, dependencies of other mods or code which does not interact with minecraft at all and is just a utility for any of the other mod files.

  • Method Details

    • create

      static IModFile create(JarContents contents, ModFileInfoParser parser) throws InvalidModFileException
      Builds a new mod file instance depending on the current runtime.
      Parameters:
      contents - The secure jar to load the mod file from.
      parser - The parser which is responsible for parsing the metadata of the file itself.
      Returns:
      The mod file.
      Throws:
      InvalidModFileException
    • create

      static IModFile create(JarContents contents, JarModuleInfo metadata, ModFileInfoParser parser) throws InvalidModFileException
      Builds a new mod file instance depending on the current runtime.
      Parameters:
      contents - The secure jar to load the mod file from.
      parser - The parser which is responsible for parsing the metadata of the file itself.
      Returns:
      The mod file.
      Throws:
      InvalidModFileException
    • create

      static IModFile create(JarContents contents, ModFileInfoParser parser, ModFileDiscoveryAttributes attributes) throws InvalidModFileException
      Builds a new mod file instance depending on the current runtime.
      Parameters:
      contents - The secure jar to load the mod file from.
      parser - The parser which is responsible for parsing the metadata of the file itself.
      attributes - Additional attributes of the modfile.
      Returns:
      The mod file.
      Throws:
      InvalidModFileException
    • create

      static IModFile create(JarContents contents, JarModuleInfo metadata, ModFileInfoParser parser, IModFile.Type type, ModFileDiscoveryAttributes attributes) throws InvalidModFileException
      Builds a new mod file instance depending on the current runtime.
      Parameters:
      contents - The secure jar to load the mod file from.
      metadata - Information about the jar contents.
      parser - The parser which is responsible for parsing the metadata of the file itself.
      type - the type of the mod
      attributes - Additional attributes of the modfile.
      Returns:
      The mod file.
      Throws:
      InvalidModFileException
    • create

      static IModFile create(JarContents contents, ModFileInfoParser parser, IModFile.Type type, ModFileDiscoveryAttributes attributes) throws InvalidModFileException
      Builds a new mod file instance depending on the current runtime.
      Parameters:
      contents - The secure jar to load the mod file from.
      parser - The parser which is responsible for parsing the metadata of the file itself.
      type - the type of the mod
      attributes - Additional attributes of the modfile.
      Returns:
      The mod file.
      Throws:
      InvalidModFileException
    • getId

      String getId()
      A unique ID identifying this mod file.

      For mod files containing mods this will correspond with the mod id of the first mod contained in this file.

      For non-mod jar files, an approach to generating a unique id is using the same algorithm used by Java to determine a Java module name for a given Jar file, but this is not guaranteed.

    • getContents

      JarContents getContents()
      Returns the contents of the mod file, which allow direct access to files in the mods jar file.
      Returns:
      the contents of the mod file, which allow direct access to files in the mods jar file
    • getSubstitutionMap

      Supplier<Map<String,Object>> getSubstitutionMap()
      The mod files specific string data substitution map. The map returned here is used to interpolate values in the metadata of the included mods. Examples of where this is used in FML: While parsing the mods.toml file, keys like: ${file.xxxxx} are replaced with the values of this map, with keys xxxxx.
      Returns:
      The string substitution map used during metadata load.
    • getType

      IModFile.Type getType()
      The type of the mod jar. This primarily defines how and where this mod file is loaded into the module system.
      Returns:
      The type of the mod file.
    • getFilePath

      Path getFilePath()
      The path to the underlying mod file.
      Returns:
      The path to the mod file.
    • getModInfos

      List<IModInfo> getModInfos()
      Returns a list of all mods located inside this jar.

      If this method returns any entries then getType() has to return IModFile.Type.MOD, else this mod file will not be loaded in the proper module layer in 1.17 and above.

      Returns:
      The mods in this mod file.
    • getScanResult

      ModFileScanData getScanResult()
      The metadata scan result of all the classes located inside this file.
      Returns:
      The metadata scan result.
    • getFileName

      String getFileName()
      The raw file name of this file.
      Returns:
      The raw file name.
    • getDiscoveryAttributes

      ModFileDiscoveryAttributes getDiscoveryAttributes()
      Get attributes about how this mod file was discovered.
    • getModFileInfo

      IModFileInfo getModFileInfo()
      The metadata info related to this particular file.
      Returns:
      The info for this file.