Skip to main content
Version: Minecraft 26.2

Operations

Config folder​

Path config = mod.configDirectory(); // config/<mod id>
Path file = config.resolve("settings.properties");

The config folder is config/<mod id>. Your mod decides the file format. You can call this from any thread.

Other mods in the game​

if (mod.mods().isLoaded("sodium")) {
// switch on an optional integration
}
mod.mods().find("jei").ifPresent(jei -> LOGGER.info("{} {} ({})", jei.name(), jei.version(), jei.loader()));
  • mod.mods() lists every loaded mod of every loader: Poly Mods, Fabric mods, and Forge mods when MinecraftForge runs the game. loader() is poly, fabric or minecraftforge.
  • isLoaded and find also match an ID a mod provides (provides in fabric.mod.json); a mod's own ID comes first.
  • Mods that were blocked or left out are not listed, nor are the game and the loaders themselves.
  • The list is complete from the first entrypoint on and never changes. You can read it from any thread.
  • Seeing a mod tells you it is loaded, not that its classes are ready: a Fabric mod's own entrypoint runs after Poly Mods' common entrypoints. Run code that uses another mod's classes in LifecycleEvents.MODS_INITIALIZED.

Shutdown tasks​

mod.onShutdown("say goodbye", () -> LOGGER.info("bye"));
  • When the JVM shuts down, Poly Mod Loader runs each task once on the Poly Mod Loader shutdown thread, in reverse registration order.
  • If one task fails, the others still run (POLY-SHUTDOWN-001).
  • Registering after shutdown has started gives POLY-SHUTDOWN-002.

Login check​

mod.events().register(PlayerEvents.LOGIN_CHECK, (id, name) ->
banned(id) ? Optional.of("reason") : Optional.empty());
  • It is called on the server thread after the game's authentication, ban, whitelist, and player-count checks pass, and before the player is created.
  • If any listener returns a reason, the player is refused. The first refusal reason appears on the disconnect screen.

World backup when mods change​

Before loading a world, if Poly Mod Loader mods were removed or their versions changed compared with last time, Poly Mod Loader first creates the game's world backup (a zip in the backups/ folder).

  • A newly added mod does not count as a change.
  • The list of mods loaded last time is recorded in <world>/poly/mods.properties.
  • If checking for a backup fails, Poly Mod Loader logs POLY-BACKUP-001 and continues loading.

You change the policy in config/poly/backups.properties.

config/poly/backups.properties
# Back up before loading a world in which mods were removed or their versions changed
backup-on-mod-change=true
# Number of backups to keep per world. Older backup zips of that world are deleted (0 keeps all)
max-backups-per-world=10

Diagnostic reports and logs​

  • Log: run/<side>/logs/latest.log. Poly Mod Loader and game logs are written in order to a single file.
  • Reports: .poly/startup-report.json, .poly/transformation-report.json. See Troubleshooting.
Buy me a coffee