★ Starshadow Config
来自普通 Java 类的精美配置界面。
Starshadow Config 是一个面向 Fabric 模组的基于注解的配置库。只需将设置定义为一个简单的 Java 类,对字段添加注解,即可获得精美的配置界面——包含标签页、分区、滑块、开关和枚举下拉框——无需编写任何样板 UI 代码。
"配置界面不应要求具备 GUI 编程博士学位。"
? 工作原理
对于模组开发者
- 在
build.gradle.kts 中添加依赖
- 创建带有注解字段的配置类
- 完成 —— Starshadow Config 自动生成整个界面
@StarConfig(modId = "mymod")
public class MyConfig {
@Tab(id = "general", icon = "minecraft:crafting_table")
@Section("scanning")
@Range(min = 1, max = 64)
@DefaultValue("16")
private int scanRange = 16;
@Section("display")
@DefaultValue("true")
private boolean showOverlay = true;
}
就是这样。没有界面构建器类。没有组件定位。没有布局数学计算。只需带有注解的配置字段。
对于玩家
如果某个模组使用了 Starshadow Config,你将获得:
- 通过 Mod Menu 访问的分页设置界面
- 所有使用该库的模组之间统一、整洁的 UI
- 使用滑块、开关和下拉框替代原始文本字段
- 重置按钮以恢复默认值
✨ 功能特性
? 基于注解的 API
注解你的配置 POJO,界面即可自动构建:
@StarConfig — 标记该类为配置类
@Tab — 将字段分组到带有图标的标签页中
@Section — 将字段组织到带标签的分区中
@Range — 设置数值字段的最小/最大值
@DefaultValue — 定义默认值
@EnabledWhen — 根据其他值条件性地启用字段
@Hidden — 从生成的界面中排除字段
@Widget — 覆盖默认组件类型
? 流畅构建器 API
需要更多控制权?使用 StarConfigBuilder 进行完全编程式操作:
StarConfigBuilder.create("mymod")
.parent(parentScreen)
.tab("general", tab -> tab
.icon(Items.CRAFTING_TABLE)
.section("scanning", section -> section
.intSlider("scanRange", b -> b
.range(1, 64).defaultValue(16)
.binding(() -> config.scanRange,
v -> config.scanRange = v))
)
)
.onSave(() -> serializer.save())
.build();
? JSON 持久化
GsonConfigSerializer 负责以可读 JSON 格式加载和保存配置文件。文件存储在 config/<mod-id>.json 中,遵循 Fabric 约定。
?️ 丰富的组件类型
- Toggles(开关) 用于布尔值
- Sliders(滑块) 用于有范围限制的数值
- Steppers(步进器) 用于整数值
- Enum cycles(枚举循环) 用于枚举选择
- String fields(字符串字段) 用于文本输入
- Description entries(描述条目) 用于 informational 文本
? Mod Menu 集成
通过单个类注册你的配置界面:
public class MyModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return ModMenuConfigFactory.create("mymod", MyConfig.class, MyConfig::get);
}
}
? 条件性字段
使用 @EnabledWhen 创建依赖设置,当其条件未满足时显示为灰色不可用状态:
@EnabledWhen(field = "pacingMode", notEquals = "ADAPTIVE")
private int linesPerSecond = 4;
? 安装
对于模组开发者
添加到你的 build.gradle.kts:
dependencies {
modstitchModImplementation("com.starshadow:starshadow-config:${property("starshadow_version")}")
modstitchModImplementation("com.starshadow:starshadow-lib:${property("starshadow_version")}")
include("com.starshadow:starshadow-config:${property("starshadow_version")}")
include("com.starshadow:starshadow-lib:${property("starshadow_version")}")
}
对于玩家
Starshadow Config 已捆绑在使用它的模组内部——通常你不需要单独安装它。如果某个模组将其作为外部依赖项:
- 为你的 Minecraft 版本安装 Fabric Loader
- 安装 Fabric API
- 将 Starshadow Config 和 Starshadow Lib 的
.jar 文件放入 mods/ 文件夹
- 启动 Minecraft
支持: Minecraft 1.20.1 · 1.20.4 · 1.21.1 — 仅限 Fabric
? 兼容性
| Mod |
兼容性 |
| Fabric API |
✅ 必需 |
| Mod Menu |
✅ 可选 — 配置界面注册(如果安装了 Starshadow Menu 则不需要) |
| Starshadow Menu |
✅ 可选 — 配置界面发现 |
| Cloth Config |
✅ 可共存 — 不同的配置系统 |
? 依赖要求
| 依赖项 |
是否必需 |
| Fabric Loader |
✅ 是 |
| Fabric API |
✅ 是 |
| Starshadow Lib |
✅ 是 |
| Mod Menu 或 Starshadow Menu |
可选 — 任一均可提供配置界面访问权限 |
? 让配置变得简单
停止编写数百行配置界面代码。Starshadow Config 自动将你的配置类转化为美观、功能完善的设置界面。
由 Ghent Starshadow 用 ❤️ 制作
依据 MPL-2.0 许可协议授权 — 可免费使用、分享和修改。
★ Starshadow Config
Beautiful config screens from plain Java classes.
Starshadow Config is an annotation-driven configuration library for Fabric mods. Define your settings as a simple Java class, annotate the fields, and get a polished config screen — complete with tabs, sections, sliders, toggles, and enum dropdowns — with zero boilerplate UI code.
"Config screens shouldn't require a PhD in GUI programming."
? How It Works
For Mod Developers
- Add the dependency to your
build.gradle.kts
- Create a config class with annotated fields
- Done — Starshadow Config generates the entire screen
@StarConfig(modId = "mymod")
public class MyConfig {
@Tab(id = "general", icon = "minecraft:crafting_table")
@Section("scanning")
@Range(min = 1, max = 64)
@DefaultValue("16")
private int scanRange = 16;
@Section("display")
@DefaultValue("true")
private boolean showOverlay = true;
}
That's it. No screen builder class. No widget positioning. No layout math. Just your config fields with annotations.
For Players
If a mod uses Starshadow Config, you get:
- A tabbed settings screen accessible via Mod Menu
- Clean, consistent UI across all mods that use the library
- Sliders, toggles, and dropdowns instead of raw text fields
- Reset buttons to restore defaults
✨ Features
? Annotation-Driven API
Annotate your config POJO and the screen builds itself:
@StarConfig — marks the class as a config
@Tab — groups fields into tabs with icons
@Section — organizes fields into labeled sections
@Range — sets min/max for numeric fields
@DefaultValue — defines the default value
@EnabledWhen — conditionally enables fields based on other values
@Hidden — excludes fields from the generated screen
@Widget — overrides the default widget type
? Fluent Builder API
Need more control? Use StarConfigBuilder for a fully programmatic approach:
StarConfigBuilder.create("mymod")
.parent(parentScreen)
.tab("general", tab -> tab
.icon(Items.CRAFTING_TABLE)
.section("scanning", section -> section
.intSlider("scanRange", b -> b
.range(1, 64).defaultValue(16)
.binding(() -> config.scanRange,
v -> config.scanRange = v))
)
)
.onSave(() -> serializer.save())
.build();
? JSON Persistence
GsonConfigSerializer handles loading and saving config files as readable JSON. Files are stored in config/<mod-id>.json following Fabric conventions.
?️ Rich Widget Types
- Toggles for booleans
- Sliders for numbers with ranges
- Steppers for integer values
- Enum cycles for enum selections
- String fields for text input
- Description entries for informational text
? Mod Menu Integration
Register your config screen with a single class:
public class MyModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return ModMenuConfigFactory.create("mymod", MyConfig.class, MyConfig::get);
}
}
? Conditional Fields
Use @EnabledWhen to create dependent settings that gray out when their condition isn't met:
@EnabledWhen(field = "pacingMode", notEquals = "ADAPTIVE")
private int linesPerSecond = 4;
? Installation
For Mod Developers
Add to your build.gradle.kts:
dependencies {
modstitchModImplementation("com.starshadow:starshadow-config:${property("starshadow_version")}")
modstitchModImplementation("com.starshadow:starshadow-lib:${property("starshadow_version")}")
include("com.starshadow:starshadow-config:${property("starshadow_version")}")
include("com.starshadow:starshadow-lib:${property("starshadow_version")}")
}
For Players
Starshadow Config is bundled inside mods that use it — you typically don't need to install it separately. If a mod requires it as an external dependency:
- Install Fabric Loader for your Minecraft version
- Install Fabric API
- Drop the Starshadow Config and Starshadow Lib
.jar files into your mods/ folder
- Launch Minecraft
Supported: Minecraft 1.20.1 · 1.20.4 · 1.21.1 — Fabric only
? Compatibility
| Mod |
Compatibility |
| Fabric API |
✅ Required |
| Mod Menu |
✅ Optional — config screen registration (not needed if Starshadow Menu is installed) |
| Starshadow Menu |
✅ Optional — config screen discovery |
| Cloth Config |
✅ Can coexist — different config systems |
? Requirements
| Dependency |
Required? |
| Fabric Loader |
✅ Yes |
| Fabric API |
✅ Yes |
| Starshadow Lib |
✅ Yes |
| Mod Menu or Starshadow Menu |
Optional — either provides config screen access |
? Config Made Simple
Stop writing hundreds of lines of config screen code. Starshadow Config turns your config class into a beautiful, functional settings screen — automatically.
Made with ❤️ by Ghent Starshadow
Licensed under MPL-2.0 — free to use, share, and modify.
评论 0
登录后参与评分
还没有评论,来抢沙发吧