Skip to content

Depending on the mod

The API ships inside the mod’s own jar, published to a Maven repository with one artifact per loader and Minecraft version. Players install the mod next to yours, together with NightLib, which it requires.

build.gradle.kts
repositories {
maven("https://nightsult.github.io/Immersive-Portals-Reforged/maven")
maven("https://nightsult.github.io/NightLib/maven")
maven("https://maven.architectury.dev")
}
Artifact What it is
net.night:ipreforged-fabric-<minecraft> The Fabric mod.
net.night:ipreforged-neoforge-<minecraft> The NeoForge mod.
net.night:ipreforged-forge-1.20.1 The Forge mod.
net.night:ipreforged-common-<minecraft> The common code, for the common module of an Architectury project.

The current version is 0.1.0-alpha.1. The loader artifacts bring NightLib along, so your development client runs with everything it needs.

With Fabric Loom on Minecraft 1.20.1 or 1.21.1, use the mod* configurations so that Loom remaps the jar to your mappings:

build.gradle.kts
dependencies {
// Required dependency: compile against it and run it in your development client.
modImplementation("net.night:ipreforged-fabric-1.21.1:0.1.0-alpha.1")
// Optional dependency instead: compile against it only.
// modCompileOnly("net.night:ipreforged-fabric-1.21.1:0.1.0-alpha.1")
}

Minecraft 26.1.2 and 26.3 ship without obfuscation, so there is nothing to remap: use the plain implementation or compileOnly configurations.

build.gradle.kts
dependencies {
implementation("net.night:ipreforged-fabric-26.3:0.1.0-alpha.1")
}

These are the usual declarations for each toolchain; adjust them to the conventions of your build (version catalogs, Groovy or Kotlin DSL, multi-loader setups).

The mod id is ipreforged. Declare it as a required or optional dependency, so that loaders can tell players what is missing.

fabric.mod.json
{
"depends": {
"ipreforged": ">=0.1.0-alpha.1"
}
}

For an optional dependency, list it under "suggests" instead of "depends".

If your mod should also run without Immersive Portals Reforged, keep every reference to its classes in a class of its own, and only touch that class after checking that the mod is loaded. The JVM loads a class the first time it is used, so the API classes are never looked up when the mod is absent.

PortalHooks.java
package com.example.portals;
import net.minecraft.world.entity.monster.Creeper;
import net.night.ipreforged.api.event.TeleportEvents;
/** Everything that uses Immersive Portals Reforged. Only touched when the mod is installed. */
public final class PortalHooks {
private PortalHooks() {
}
public static void register() {
// Creepers stay on their side of every portal.
TeleportEvents.BEFORE.register(pending -> {
if (pending.entity() instanceof Creeper) {
pending.cancel();
}
});
}
}

Then call it from your entry point, behind the loader’s “is this mod loaded?” check:

ExampleFabricMod.java
package com.example.portals;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
public final class ExampleFabricMod implements ModInitializer {
@Override
public void onInitialize() {
if (FabricLoader.getInstance().isModLoaded("ipreforged")) {
PortalHooks.register();
}
}
}

Registering event listeners this early is fine: events are static fields and do not need the mod to have initialised. Calls through ReforgedApi.get() must wait until later, see When you can call it.

If you use something added after API level 1, check the level of the installed mod first:

if (ReforgedApi.get().apiVersion() >= 2) {
// use the newer feature
}