dev.polymodloader.api.lifecycle
This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.
| Type | Kind | Description |
|---|---|---|
ClientModInitializer | functional interface | Entrypoint listed under entrypoints.client in poly.mod.json. |
CommonModInitializer | functional interface | Entrypoint listed under entrypoints.common in poly.mod.json. |
DedicatedServerModInitializer | functional interface | Entrypoint listed under entrypoints.server in poly.mod.json. |
LoadedMods | interface | 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). |
LoadedMods.Mod | record | One loaded mod. |
ModContext | interface | Information 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.
| Parameter | Type | Description |
|---|---|---|
context | ModContext | — |
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.
| Parameter | Type | Description |
|---|---|---|
context | ModContext | — |
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.
| Parameter | Type | Description |
|---|---|---|
context | ModContext | — |
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).
| Parameter | Type | Description |
|---|---|---|
modId | String | — |
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.
| Parameter | Type | Description |
|---|---|---|
modId | String | — |
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.
| Component | Type | Description |
|---|---|---|
modId | String | its ID |
version | String | its version text, as its own metadata declares it |
name | String | its display name |
loader | String | the loader that runs it, in lower case: poly, fabric, minecraftforge; more loaders may appear in later versions |
providedIds | List<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.
| Parameter | Type | Description |
|---|---|---|
description | String | what the task cleans up, shown in diagnostics |
task | Runnable | the 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