跳到正文

NightLib

作者:Nighttie

This mod is a library designed to log mod performance!

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。

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 支持哪些 Minecraft 版本?

NightLib 支持 Minecraft Java 版 1.20.1–26.1.2,共 3 个版本,可用的加载器:Fabric / Forge / NeoForge。下载时注意选择和你游戏版本一致的文件。

NightLib 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric / Forge / NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。

评论

登录后评论和评分

Nighttie 的其他作品

查看全部 →