FML loader APIs and their Sunrise routes

NeoForge's mod loader (FML) hands a mod its own files and paths: the list of mod files, a config's full path, the game directory, an update URL. Sunrise answers the same needs with different shapes on purpose. This page says which FML APIs have no counterpart of the same shape, what a Sunrise mod uses instead, and why, so a porter does not search the vocabulary for a name that will never exist.

From Sunrise's modding bookead8a1e

A row marked by design is not a gap. A row that links an issue is a real gap that is tracked, not by design.

  • ModList file reads: getModFiles, getModFileById, forEachModFile, applyForEachModFile, applyForEachModFileAlphabetical

    Sunrise route
    LoadedMods from RegistrationContext::mods(): ids(), iter() and get(id) over the loaded packages, each a PackageInfo (see Load phases and access)
    Why it differs
    By design. A package is one mod, so there is one PackageInfo per mod rather than a file with several mods in it. It carries the id, version, kind, side, namespaces, dependencies and the manifest's details (display name, description, authors, license, links, the icon's path inside the package, runtime and properties), and no path to the package on disk. Iteration is in dispatch order; there is no alphabetical variant, so sort the ids yourself.
  • ModConfig.getFullPath

    Sunrise route
    ConfigFile.file, a name relative to config/ (or to a world's serverconfig/), and Host::config_files() for the calling mod's own files (see Config files and settings)
    Why it differs
    By design. config_files() is bound to the calling mod and never lists another mod's files. A wasm mod has no file path at all: the game reads the file and hands over its text.
  • FMLLoader.getGameDir and FMLPaths.GAMEDIR

    Sunrise route
    Host::instance_dir() on native; RegistrationContext::instance_dir() on both targets (see Load phases and access)
    Why it differs
    By design. Host::instance_dir() is native only: a wasm mod has no file system to point at, and reads its own data and assets through reload listeners. RegistrationContext::instance_dir() gives the path on both targets, but as data, not as permission to open it.
  • IModInfo.getUpdateURL

    Sunrise route
    None in a mod. The mod browser compares the installed version with the newest one in Sunrise's registry (see Installing and using mods)
    Why it differs
    By design for registry mods: updates come from the registry, not from a URL a mod declares. A mod installed from outside the registry has no update check yet.

A mod that needs to know who else is loaded asks LoadedMods; one that needs a file reads it through the services above. If neither answers, file an issue naming the FML API and what the mod does with it.

Edit this page on GitHub · Spotted something wrong? Open an issue or ask on Discord.