Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.lifecycle

Generated

This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.

TypeKindDescription
ClientModInitializerfunctional interfaceEntrypoint listed under entrypoints.client in poly.mod.json.
CommonModInitializerfunctional interfaceEntrypoint listed under entrypoints.common in poly.mod.json.
DedicatedServerModInitializerfunctional interfaceEntrypoint listed under entrypoints.server in poly.mod.json.
LoadedModsinterfaceThe mods loaded in this game, of every loader: Poly Mods, the mods of other loaders that Poly Mod Loader runs (Fabric), and the mods a host loader runs (MinecraftForge's, when Forge runs the game, ADR-0021).
LoadedMods.ModrecordOne loaded mod.
ModContextinterfaceInformation Poly Mod Loader hands to a mod entrypoint about the mod being initialised and the process it runs in.

ClientModInitializer​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ClientModInitializer

Entrypoint listed under entrypoints.client in poly.mod.json. Runs only on the client, after every CommonModInitializer. Same timing and failure rules as CommonModInitializer.

onInitializeClient(ModContext)​

void onInitializeClient(ModContext context)

Since 0.1.0-alpha.4 or earlier

Initialises the mod's client-only parts.

ParameterTypeDescription
contextModContext—

CommonModInitializer​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface CommonModInitializer

Entrypoint listed under entrypoints.common in poly.mod.json. Runs on both the client and the dedicated server.

Timing: called once on the main thread after all mods were discovered, validated, and ordered by their dependencies, and before Minecraft's own main starts. Minecraft registries and game objects do not exist yet at this point.

Failure: an exception stops the launch and is reported with the mod ID.

onInitializeCommon(ModContext)​

void onInitializeCommon(ModContext context)

Since 0.1.0-alpha.4 or earlier

Initialises the mod's common (side-independent) parts.

ParameterTypeDescription
contextModContext—

DedicatedServerModInitializer​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface DedicatedServerModInitializer

Entrypoint listed under entrypoints.server in poly.mod.json. Runs only on a dedicated server, after every CommonModInitializer. Same timing and failure rules as CommonModInitializer.

onInitializeDedicatedServer(ModContext)​

void onInitializeDedicatedServer(ModContext context)

Since 0.1.0-alpha.4 or earlier

Initialises the mod's dedicated-server-only parts.

ParameterTypeDescription
contextModContext—

LoadedMods​

interface · Stability PREVIEW · Since 0.1.0-alpha.18

public interface LoadedMods

The mods loaded in this game, of every loader: Poly Mods, the mods of other loaders that Poly Mod Loader runs (Fabric), and the mods a host loader runs (MinecraftForge's, when Forge runs the game, ADR-0021). A Poly Mod reads it to switch an optional integration on or off, as Fabric mods use FabricLoader.isModLoaded and Forge mods ModList.isLoaded.

Only loaded mods are listed: mods that were blocked or left out are not, nor are the game, Java and the loaders themselves (minecraft, java, fabricloader, forge).

When: complete from the first entrypoint on; the list does not change while the game runs.

Thread: safe to read from any thread.

Implementations are provided by Poly Mod Loader; mods do not implement this interface.

isLoaded(String)​

boolean isLoaded(String modId)

Since 0.1.0-alpha.18

Whether a mod with modId is loaded, by its own ID or an ID it provides (provides in fabric.mod.json).

ParameterTypeDescription
modIdString—

Returns boolean

find(String)​

Optional<LoadedMods.Mod> find(String modId)

Since 0.1.0-alpha.18

The loaded mod with modId: the mod whose own ID it is, otherwise the first mod that provides it; empty when none is loaded.

ParameterTypeDescription
modIdString—

Returns Optional<LoadedMods.Mod>

all()​

List<LoadedMods.Mod> all()

Since 0.1.0-alpha.18

Every loaded mod: first those a host loader runs, then the others in the order their entrypoints run.

Returns List<LoadedMods.Mod>

LoadedMods.Mod​

record · Stability PREVIEW · Since 0.1.0-alpha.18

public static record Mod(String modId, String version, String name, String loader, List<String> providedIds)

One loaded mod.

ComponentTypeDescription
modIdStringits ID
versionStringits version text, as its own metadata declares it
nameStringits display name
loaderStringthe loader that runs it, in lower case: poly, fabric, minecraftforge; more loaders may appear in later versions
providedIdsList<String>further IDs it answers to

ModContext​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ModContext

Information Poly Mod Loader hands to a mod entrypoint about the mod being initialised and the process it runs in. Implementations are provided by Poly Mod Loader; mods do not implement this interface.

modId()​

String modId()

Since 0.1.0-alpha.4 or earlier

The mod ID declared in poly.mod.json, for example minimal_native_mod.

Returns String

modVersion()​

String modVersion()

Since 0.1.0-alpha.4 or earlier

The mod version declared in poly.mod.json.

Returns String

side()​

GameSide side()

Since 0.1.0-alpha.4 or earlier

Whether this process is a client or a dedicated server.

Returns GameSide

mods()​

LoadedMods mods()

Since 0.1.0-alpha.18

The mods loaded in this game, of every loader (Poly Mods, Fabric mods, Forge mods).

Returns LoadedMods

systems()​

SystemLookup systems()

Since 0.1.0-alpha.4 or earlier

The active implementation of each Poly Mod Loader system, after replacements were applied.

Returns SystemLookup

events()​

EventRegistry events()

Since 0.1.0-alpha.4 or earlier

Registers event listeners owned by this mod.

Returns EventRegistry

onShutdown(String, Runnable)​

void onShutdown(String description, Runnable task)

Since 0.1.0-alpha.4 or earlier

Registers work to run when the game process exits.

Order: tasks run once, in reverse registration order across all mods, so mods are cleaned up before the mods they depend on.

Thread: tasks run on Poly Mod Loader's shutdown thread while the JVM exits. They must be quick, must not start new threads, and must not touch game state, which may already be gone.

Failure: an exception is logged with the mod ID (POLY-SHUTDOWN-001); the remaining tasks still run.

ParameterTypeDescription
descriptionStringwhat the task cleans up, shown in diagnostics
taskRunnablethe work

Throws IllegalStateException — when called after shutdown has started

configDirectory()​

Path configDirectory()

Since 0.1.0-alpha.4 or earlier

This mod's configuration directory, config/<mod id> in the game directory; created on first call. Configuration file formats are up to the mod.

Returns Path

content()​

ContentRegistrar content()

Since 0.1.0-alpha.4 or earlier

Declares this mod's blocks and items (common entrypoints only).

Returns ContentRegistrar

commands()​

CommandRegistrar commands()

Since 0.1.0-alpha.4 or earlier

Registers this mod's server commands.

Returns CommandRegistrar

network()​

NetworkRegistrar network()

Since 0.1.0-alpha.4 or earlier

Declares this mod's network channels.

Returns NetworkRegistrar

worldgen()​

WorldgenRegistrar worldgen()

Since 0.1.0-alpha.4 or earlier

Attaches this mod's placed features to biomes.

Returns WorldgenRegistrar

gameTests()​

GameTestRegistrar gameTests()

Since 0.1.0-alpha.4 or earlier

Registers this mod's in-game tests.

Returns GameTestRegistrar

client()​

ClientRegistrar client()

Since 0.1.0-alpha.4 or earlier

Client-only registrations: key bindings and HUD layers.

Returns ClientRegistrar

Throws IllegalStateException — on a dedicated server (POLY-CLIENT-001)

resources()​

ResourceRegistrar resources()

Since 0.1.0-alpha.4 or earlier

Reload listeners for the mod's own data and asset files.

Returns ResourceRegistrar

permissions()​

PermissionRegistrar permissions()

Since 0.1.0-alpha.4 or earlier

The mod's permissions and permission providers.

Returns PermissionRegistrar

Buy me a coffee