S-Lib
S-Lib 是一个实用工具和配置库。我的其他模组使用它来管理其配置和配置界面,因此单独安装时不会为游戏添加任何内容。如果你安装的模组将 S-Lib 列为依赖项,请将其放入你的 mods 文件夹中。
依赖项
版本支持
| Minecraft |
Fabric |
Forge |
NeoForge |
| 1.20 - 1.20.1 |
Yes |
Yes |
|
| 1.20.2 - 1.20.4 |
Yes |
|
仅 1.20.4 |
| 1.20.5 - 1.20.6 |
Yes |
|
Yes |
| 1.21 - 1.21.1 |
Yes |
|
Yes |
| 1.21.2 - 1.21.4 |
Yes |
|
Yes |
| 1.21.5 |
Yes |
|
Yes |
| 1.21.6 - 1.21.8 |
Yes |
|
Yes |
| 1.21.9 - 1.21.10 |
Yes |
|
Yes |
| 1.21.11 |
Yes |
|
Yes |
| 26.1 |
Yes |
|
Yes |
| 26.2 |
Yes |
|
Yes |
| 26.3 |
Yes |
|
Yes |
玩家指南
每个模组都会在其 config 文件夹中的 .json5 文件里保存设置。如果你在编辑时弄错了某个选项,只有该选项会恢复为默认值。旧文件会先被备份。
如果安装了 YACL(且模组支持此功能),点击配置按钮即可在游戏内打开设置界面。
在多人游戏中,由服务器管理的设置会在你加入时自动发送给你,并且除非服务器允许你修改(通常仅限管理员),否则这些设置会显示为灰色不可用状态。在局域网世界中,主机始终可以更改它们。在没有安装 S-Lib 的服务器上,这些设置将直接使用默认值。
模组开发者指南
- 配置基于注解的 POJO,支持范围限制、注释等功能
- 可通过一行代码注册配置,只需几行代码即可轻松构建完整的 YACL 界面
- YACL 控制器:支持颜色、枚举以及物品/标签下拉菜单
- 物品匹配器(支持 ID、标签、正则表达式,使用前缀
! 表示排除)以及一些辅助工具
请参阅 GitHub README 获取完整文档,并查看 S-Lib Test Mod 获取实际代码示例。
S-Lib
S-Lib is a utility and config library. My other mods use it for their configs and config screens, so on its own it adds nothing to the game. If a mod you installed lists S-Lib as a dependency, drop it in your mods folder.
Dependencies
- Fabric only: Fabric API
- Optional: YACL for the in-game config screens. Without YACL everything still works, you will need to edit the config files manually.
- Optional, Fabric only: Mod Menu
Versions
| Minecraft |
Fabric |
Forge |
NeoForge |
| 1.20 - 1.20.1 |
Yes |
Yes |
|
| 1.20.2 - 1.20.4 |
Yes |
|
1.20.4 only |
| 1.20.5 - 1.20.6 |
Yes |
|
Yes |
| 1.21 - 1.21.1 |
Yes |
|
Yes |
| 1.21.2 - 1.21.4 |
Yes |
|
Yes |
| 1.21.5 |
Yes |
|
Yes |
| 1.21.6 - 1.21.8 |
Yes |
|
Yes |
| 1.21.9 - 1.21.10 |
Yes |
|
Yes |
| 1.21.11 |
Yes |
|
Yes |
| 26.1 |
Yes |
|
Yes |
| 26.2 |
Yes |
|
Yes |
| 26.3 |
Yes |
|
Yes |
For players
Each mod keeps its settings in a .json5 file in your config folder. If you mess up an option when editing, only that option goes back to its default. The old file gets backed up first.
With YACL installed (and if the mod supports it), the config button opens a settings screen in game.
In multiplayer, server-managed settings are automagically sent to you when you join, and they stay greyed out unless the server lets you change them (usually operators only). In a LAN world the host can always change them. On a server without S-Lib, those settings just use their defaults.
For mod developers
- Configs are annotation-based POJOs with support for range clamping, comments, and more
@Sync decides whether an option is kept locally or synced to the server
- Configs can be registered with a one-liner, and an entire YACL screen can easily be built with a few more lines
- YACL controllers for colors, enum and items/tags dropdowns.
- An item matcher (ids, tags, regex,
! to exclude) and some smaller helpers
See the GitHub README for the full documentation, and the S-Lib Test Mod for real code examples.
评论 0
登录后参与评分
还没有评论,来抢沙发吧