CraftUI
一个用于在 Minecraft 中使用 Dear ImGui 的框架
在过去几年里,我注意到像 Flashback 这类实用模组中越来越多地使用 ImGui。然而,由于技术限制,这些模组之间无法互相兼容(即使能兼容,体验也极其糟糕)。
CraftUI 是一个旨在解决此问题的框架。作为 Dear ImGui 的 Minecraft 专用封装,它负责挂载和渲染 ImGui 原生代码、实现跨模组兼容,并提供一套额外的、针对 Minecraft 特定的实用系统。
注意:该框架仍处于开发阶段,公共 API 功能可能会发生变化。
此外,目前它尚不支持所有 Minecraft 版本。
示例

特性
CraftUI 基于 ImGui Java 构建,因此包含其所有特性。
在此基础上,它还额外包括:
- 基于资源包的字体加载
- 用户可定义的主题(同样基于资源包)
- 通过 Dock Space 调整游戏视口大小
- 原生文件浏览器访问权限
- 其他各种实用工具
入门指南
首先,在使用此库之前,重要的是要具备对 Dear ImGui 及其特定分支 ImGui Java 的基本理解。
任何关于 ImGui 本身的问题都将引导至相关文档。
接下来,要在你的 buildscript 的 repositories 部分添加以下内容以进行安装:
repositories {
// ...
maven { url = 'https://jitpack.io' }
}
然后,在你的 dependencies 部分添加以下内容,将 [version] 替换为你想要的版本:
dependencies {
// ...
modImplementation 'com.github.Igrium:CraftUI:[version]'
}
别忘了在 fabric.mod.json 中添加依赖!
一旦框架安装并构建完成,你可以通过扩展 CraftApp 来创建一个新的 UI 应用:
public class ExampleApp extends CraftApp {
@Override
protected void render(MinecraftClient client) {
// 在此处编写 ImGui 渲染代码
}
}
现在,要打开 UI,请调用:
AppManager.openApp(new ExampleApp());
该应用将在游戏之上渲染,直到通过 exampleApp.close() 关闭为止。有关更深入的示例,请参阅 testmod。
重要提示:
- 由于包含的原生库体积较大,不建议将该框架本身打包到你的模组中。
com.igrium.craftui.impl 包 不属于 公共 API 的一部分,且可能在不通知的情况下发生变化!
CraftUI
A framework to use Dear ImGui in Minecraft
Over the past few years, I've noticed a growing use of ImGui in utility mods such as Flashback. However,
due to technical constraints, none of these mods can be compatible with each other (and if they are, they're extremely jank).
CraftUI is a framework that attempts to fix this. Being a minecraft-specific wrapper for Dear ImGui, it handles mounting
and rendering the ImGui native code, cross-mod compatibility, as well as providing a set of extra, Minecraft-specific utility systems.
Note: This framework is still in development, and public API functionality might change.
It also doesn't support all Minecraft versions right now.
Examples

Features
CraftUI is built on ImGui Java, and by extension, contains all its features.
On top of that, it also includes:
- Resource-pack-based font loading
- User-definable themes (also resource-pack-based)
- Game viewport resizing via dock-space
- Native file browser access
- Other various utilities
Getting Started
To preface, it's important to have a basic understanding of Dear ImGui, and specifically ImGui Java, before using this library.
Any questions pertaining ImGui on its own will be redirected there.
With that said, to install, add the following to the repositories section of your buildscript:
repositories {
// ...
maven { url = 'https://jitpack.io' }
}
Then, in your dependencies section, add the following, replacing [version] with the desired version:
dependencies {
// ...
modImplementation 'com.github.Igrium:CraftUI:[version]'
}
And don't forget to add it as a dependency in fabric.mod.json!
Once you have the framework installed and building, you can create a new UI application by extending CraftApp:
public class ExampleApp extends CraftApp {
@Override
protected void render(MinecraftClient client) {
// ImGui rendering code here
}
}
Now, to open the UI, call:
AppManager.openApp(new ExampleApp());
The app will now render atop the game until it is closed with exampleApp.close(). See testmod for a more in-depth example.
Important Notes:
- Due to the size of the included native libraries, it is not recommended to bundle the framework itself with your mod.
- The package
com.igrium.craftui.impl is not considered part of the public API, and could change without warning!
评论 0
登录后参与评分
还没有评论,来抢沙发吧