promotional bannermobile promotional banner

NightLib

This mod is a library designed to log mod performance!
NightLib
Create your game server with affiliate logo
Create Server
affiliate banner image

We can use this library to track mod performance.

The mod also features a system that recognizes your mods, so you can use /nightlib mods and it will display all mods using the API.
You can also direct people to your forum or Discord in case of issues with the mod or high RAM usage using /nightlib info <mod>

Why Use NightLib?

NightLib provides a library that allows you to monitor your mod's performance and identify potential issues! Plus, it's incredibly easy to use.

Implement the Library in your mod

1 - Build.gradle:

repositories {
}
 
dependencies {
// Format: net.night:NightLib-<loader>-<Minecraft version>:1.3.0
modImplementation "net.night:NightLib-fabric-1.20.1:1.3.0"
}


2 - Register your mod

import net.night.nightlib.api.ModProfiler;
import
net.night.nightlib.api.NightlibAPI;

public final class MyMod {
public static final String MOD_ID = "mymod";
public static ModProfiler PROFILER;

public static void init() {
// Optional: support link shown in /nightlib info
NightlibAPI.register(MOD_ID, "https://discord.gg/your-invite");

// Registers the mod (if it isn't already) and returns its profiler
PROFILER = NightlibAPI.getProfiler(MOD_ID);
}
}


3 - Reporting performance

// Option A: try-with-resources (recommended)
try (var ignored = PROFILER.start("tick")) {
doTickWork();
}

// Option B: pass a Runnable
PROFILER.time("network", MyMod::processPackets);

// Option C: measure it yourself, in nanoseconds
long start = System.nanoTime();
generateStructure();
PROFILER.record("world_gen", System.nanoTime() - start);


4 - Report Errors

try {
generateStructure();
} catch (Exception e) {
PROFILER.reportError("world_gen", e);
LOGGER.error("Failed to generate structure", e);
}


Do you need help? Join our Discord!

NightLib Team

profile avatar
  • 3
    Followers
  • 22
    Projects
  • 1.1M
    Downloads

I'm a developer; I create mods and modpacks and design quests. If you run into any issues, join my Discord.

Donate

More from NighttieView all