NilKit API
专为基于 NilLoader 构建的模组设计的独立实用工具 API 和开发者工具箱。
重要提示
NilKit 并非官方 NilLoader 项目的一部分,也不是使用 NilLoader 所必需的。
NilLoader 由以下地址单独维护:
NilKit 为旧版 Minecraft 模组开发提供可复用的 API 和工具,旨在减少围绕事件、反射、映射(mappings)、元数据、网络通信以及开发辅助方面的样板代码。
NilKit 4.1.0 针对 Java 8 字节码,其核心 API 不需要与特定的 Minecraft JAR 建立硬运行时依赖。Minecraft 特有的功能仍然依赖于目标游戏版本的映射和结构。
特性
事件与生命周期
- 轻量级事件总线
- 可取消的事件
- 监听器优先级
premain / hijack 生命周期辅助工具
- 类型化和基于注解的监听器
反射与旧版 Minecraft 工具
- 用于版本相关 Minecraft 代码的反射辅助工具
- SRG/CSRG 映射工具
- 映射检查、反转、链式调用和查找
- 在开发期间集成外部
MinecraftRemapping 映射仓库
KDL
NilKit 包含一个通用的 KDL 解析器和写入器,并可以使用 KDL 来提供更丰富的项目/模组元数据。
KDL 支持是可选的。NilKit 不要求 NilLoader 模组必须使用 KDL,标准的 NilLoader 元数据仍然完全受支持。
示例:
nilmod {
name "My Mod"
description "Example mod"
authors "Author"
version "1.0.0"
}
entrypoints {
premain "com.example.MyPremain"
hijack "com.example.MyHijack"
}
nilkit {
requires "nilloader" "nilkit"
load_after "nilkit"
icon "assets/mymod/icon.png"
modurl "https://modrinth.com/mod/my-mod"
sourceurl "https://github.com/example/my-mod"
license "MIT"
credits "Author"
}
网络通信
- Java NIO 客户端/服务器工具
- 数据包注册表和解码器(codecs)
- 可选的面向 Minecraft 的网络辅助工具
开发者工具箱
可选的 -all.jar 还捆绑了多个开发者库,且未对其公共包进行重定位:
- Byte Buddy
- GEB
- ClassGraph
- SnakeYAML
普通的 NilKit 工件在运行时不需要这些库。
Gradle
repositories {
maven {
url = uri("https://repo.tamkungz.me")
}
}
dependencies {
implementation "me.tamkungz.nilkit:nilkit:4.1.0"
}
文档
完整的文档和开发信息可在 GitHub 仓库中获取:
NilLoader
NilKit 旨在补充 NilLoader,而非替代它。
NilLoader 本身、其加载生命周期及其上游开发均与 NilKit 保持独立。
许可证
NilKit 采用 LGPL-3.0-or-later 许可证授权。
NilKit API
An independent utility API and developer toolkit for mods built with NilLoader.
Important
NilKit is not part of the official NilLoader project and is not required to use NilLoader.
NilLoader is maintained separately at:
NilKit provides reusable APIs and tooling for legacy Minecraft mod development, with a focus on reducing boilerplate around events, reflection, mappings, metadata, networking, and development utilities.
NilKit 4.1.0 targets Java 8 bytecode and does not require a hard runtime link to a specific Minecraft JAR for its core APIs. Minecraft-specific functionality remains dependent on the mappings and structure of the target game version.
Features
Events and lifecycle
- Lightweight event bus
- Cancellable events
- Listener priorities
premain / hijack lifecycle helpers
- Typed and annotation-based listeners
Reflection and legacy Minecraft tooling
- Reflection helpers for version-dependent Minecraft code
- SRG/CSRG mapping utilities
- Mapping inspection, reversal, chaining, and lookup
- Integration with the external
MinecraftRemapping mapping repository during development
KDL
NilKit includes a general-purpose KDL parser and writer and can use KDL for richer project/mod metadata.
KDL support is optional. NilKit does not require NilLoader mods to use KDL, and standard NilLoader metadata remains fully supported.
Example:
nilmod {
name "My Mod"
description "Example mod"
authors "Author"
version "1.0.0"
}
entrypoints {
premain "com.example.MyPremain"
hijack "com.example.MyHijack"
}
nilkit {
requires "nilloader" "nilkit"
load_after "nilkit"
icon "assets/mymod/icon.png"
modurl "https://modrinth.com/mod/my-mod"
sourceurl "https://github.com/example/my-mod"
license "MIT"
credits "Author"
}
Networking
- Java NIO client/server utilities
- Packet registry and codecs
- Optional Minecraft-facing network helpers
Developer toolbox
The optional -all.jar also bundles several developer libraries without relocating their public packages:
- Byte Buddy
- GEB
- ClassGraph
- SnakeYAML
The normal NilKit artifact does not require these libraries at runtime.
Gradle
repositories {
maven {
url = uri("https://repo.tamkungz.me")
}
}
dependencies {
implementation "me.tamkungz.nilkit:nilkit:4.1.0"
}
Documentation
Full documentation and development information are available in the GitHub repository:
NilLoader
NilKit is designed to complement NilLoader, not replace it.
NilLoader itself, its loading lifecycle, and its upstream development remain separate from NilKit.
License
NilKit is licensed under LGPL-3.0-or-later.
评论 0
登录后参与评分
还没有评论,来抢沙发吧