LowFrame Screen API
一个面向 Minecraft Fabric 模组的轻量级、已样式化的屏幕与组件工具包。
LowFrame Screen API 处理自定义 Minecraft 界面中的重复性工作——包括屏幕生命周期、组件渲染、鼠标和键盘事件分发、工具提示以及统一的样式——让你可以专注于屏幕的实际功能。
这是一个开发者库。单独安装它不会添加任何菜单或游戏内功能。它是使用 LowFrame Screen API 构建界面的模组所必需的依赖。
特性
- 轻量级的客户端 API
- 支持样式的按钮、文本字段、开关和滑块
- 用于自定义屏幕的简单基类
- 自动的组件渲染与输入分发
- 悬停检测与工具提示
- 屏幕级别的鼠标、键盘、字符输入、拖拽和滚动钩子
- 面板、矩形、边框、文本和颜色的辅助工具
- 通过
LFWidget 支持自定义组件
- 无 Fabric API 依赖
兼容性
| 要求 |
版本 |
| Minecraft |
1.21.11 |
| Mod 加载器 |
Fabric |
| Fabric Loader |
0.19.3 或更高版本 |
| Java |
21 或更高版本 |
| 环境 |
客户端 |
Minecraft 在不同版本间会更改其 GUI 方法。仅使用与你确切 Minecraft 版本匹配的 Screen API 发布版。
玩家安装指南
- 为 Minecraft 1.21.11 安装 Fabric Loader。
- 下载 LowFrame Screen API。
- 将 JAR 文件放入你的 Minecraft
mods 文件夹中。
- 安装需要 LowFrame Screen API 的模组。
开发者安装指南
下载 JAR 文件并将其放入你项目的 libs 目录中:
dependencies {
modImplementation files("libs/lowframe-screen-api-1.0.0.jar")
}
在你的 fabric.mod.json 中添加依赖:
{
"depends": {
"fabricloader": ">=0.19.3",
"minecraft": "~1.21.11",
"lowframe_screen_api": ">=1.0.0"
}
}
快速示例
import dev.lowframe.gui.api.LFButton;
import dev.lowframe.gui.api.LFScreen;
import dev.lowframe.gui.api.LFTextField;
import net.minecraft.client.gui.screen.Screen;
public final class ExampleScreen extends LFScreen {
private final Screen parent;
private LFTextField name;
public ExampleScreen(Screen parent) {
super("Example Screen");
this.parent = parent;
}
@Override
protected void build() {
int panelWidth = 220;
int x = (width - panelWidth) / 2;
int y = height / 2 - 30;
name = add(new LFTextField(x, y, panelWidth, 20, "Player name"));
LFButton save = add(new LFButton(
x, y + 28, panelWidth, 20, "Save",
() -> System.out.println(name.getText())
));
save.accent();
save.tooltip = "Save the entered name";
}
@Override
public void close() {
client.setScreen(parent);
}
}
从客户端代码打开屏幕:
MinecraftClient client = MinecraftClient.getInstance();
client.setScreen(new ExampleScreen(client.currentScreen));
内置组件
LFButton — 带有标签、动作、工具提示和强调样式的可点击按钮
LFTextField — 轻量级单行文本输入框
LFToggle — 使用 getter 和 setter 函数的布尔开关控件
LFSlider — 使用 getter 和 setter 函数的数值滑块
LFWidget — 用于创建自定义组件的基类
LFScreen — 带有渲染、生命周期、输入和工具提示处理的基屏幕
重要渲染说明
Minecraft 1.21.11 可能会在渲染你的屏幕之前应用菜单模糊效果。请勿在 LFScreen 中再次调用原版 renderBackground(...),因为 Minecraft 可能会崩溃并抛出以下异常:
IllegalStateException: Can only blur once per frame
请使用 super.renderScreen(...) 或自行绘制背景填充。
文档与源码
- 完整文档包含在源仓库的
wiki/index.html 中。
- 源代码仓库:
- 问题追踪器:
许可证
LowFrame Screen API 采用 LowFrame Attribution-ShareAlike License 1.0 许可证。
你可以出于任何目的使用、修改、重新分发、再许可和销售本库。如果你分发该 API 或基于它的实质性衍生作品,你必须:
- 给予 Astro Tech Inc. 合理的署名。
- 使用相同的许可证并包含其许可证文本。
私有修改无需公开。
LowFrame Screen API
A lightweight, styled screen and widget toolkit for Minecraft Fabric mods.
LowFrame Screen API handles the repetitive parts of custom Minecraft interfaces—screen lifecycle, widget rendering, mouse and keyboard dispatch, tooltips, and consistent styling—so you can focus on what your screen actually does.
This is a developer library. Installing it by itself does not add menus or gameplay features. It is required by mods that build their interfaces with LowFrame Screen API.
Features
- Lightweight client-side API
- Styled buttons, text fields, toggles, and sliders
- Simple base class for custom screens
- Automatic widget rendering and input dispatch
- Hover detection and tooltips
- Screen-level mouse, keyboard, character, drag, and scroll hooks
- Helpers for panels, rectangles, outlines, text, and colors
- Support for custom widgets through
LFWidget
- No Fabric API dependency
Compatibility
| Requirement |
Version |
| Minecraft |
1.21.11 |
| Mod loader |
Fabric |
| Fabric Loader |
0.19.3 or newer |
| Java |
21 or newer |
| Environment |
Client |
Minecraft changes its GUI methods between versions. Only use a Screen API release made for your exact Minecraft version.
Installation for players
- Install Fabric Loader for Minecraft 1.21.11.
- Download LowFrame Screen API.
- Place the JAR in your Minecraft
mods folder.
- Install a mod that requires LowFrame Screen API.
Installation for developers
Download the JAR and place it in your project's libs directory:
dependencies {
modImplementation files("libs/lowframe-screen-api-1.0.0.jar")
}
Add the dependency to your fabric.mod.json:
{
"depends": {
"fabricloader": ">=0.19.3",
"minecraft": "~1.21.11",
"lowframe_screen_api": ">=1.0.0"
}
}
Quick example
import dev.lowframe.gui.api.LFButton;
import dev.lowframe.gui.api.LFScreen;
import dev.lowframe.gui.api.LFTextField;
import net.minecraft.client.gui.screen.Screen;
public final class ExampleScreen extends LFScreen {
private final Screen parent;
private LFTextField name;
public ExampleScreen(Screen parent) {
super("Example Screen");
this.parent = parent;
}
@Override
protected void build() {
int panelWidth = 220;
int x = (width - panelWidth) / 2;
int y = height / 2 - 30;
name = add(new LFTextField(x, y, panelWidth, 20, "Player name"));
LFButton save = add(new LFButton(
x, y + 28, panelWidth, 20, "Save",
() -> System.out.println(name.getText())
));
save.accent();
save.tooltip = "Save the entered name";
}
@Override
public void close() {
client.setScreen(parent);
}
}
Open the screen from client-side code:
MinecraftClient client = MinecraftClient.getInstance();
client.setScreen(new ExampleScreen(client.currentScreen));
Included widgets
LFButton — clickable buttons with labels, actions, tooltips, and accent styling
LFTextField — lightweight single-line text input
LFToggle — boolean on/off control using getter and setter functions
LFSlider — numeric slider using getter and setter functions
LFWidget — base class for creating your own widgets
LFScreen — base screen with rendering, lifecycle, input, and tooltip handling
Important rendering note
Minecraft 1.21.11 may apply menu blur before rendering your screen. Do not call vanilla renderBackground(...) again from an LFScreen, because Minecraft can crash with:
IllegalStateException: Can only blur once per frame
Use super.renderScreen(...) or draw your own background fill instead.
Documentation and source
- Full documentation is included in
wiki/index.html in the source repository.
- Source repository:
- Issue tracker:
License
LowFrame Screen API uses the LowFrame Attribution-ShareAlike License 1.0.
You may use, modify, redistribute, sublicense, and sell it for any purpose. If you distribute the API or a substantially derived work, you must:
- Give reasonable credit to Astro Tech Inc.
- Use the same license and include its license text.
Private modifications do not need to be published.
评论 0
登录后参与评分
还没有评论,来抢沙发吧