ApricityUI
使用 HTML + CSS + JS 构建用户界面。其语法尽可能遵循 Web 标准。

概述
ApricityUI 围绕一个目标构建:一个低摩擦、便捷且功能广泛的 UI 框架。这就是为什么它以经典的 HTML + CSS + JS 组合为核心。
JS 端目前依赖 KubeJS(可选),这意味着整合包作者可以用极低的学习曲线绘制任何他们想要的 UI。
有多低?你可以让 AI 为你生成所有与 ApricityUI 相关的内容。Web 框架非常流行,以至于 AI 对它们了如指掌——结果甚至可能比你亲手画的更好,而且你仍然能读懂它。
需要自定义 UI 的模组也可以依赖 ApricityUI 来构建高度可扩展的界面;JS 和 Java API 的功能大致相当。
这种扩展性体现在哪里?嵌套遮罩、平滑滚动、圆角边框、磨砂玻璃背景、自定义动画、自定义字体、GIF 播放——甚至是相互嵌套的滤镜、遮罩和阴影。在其他地方需要数百或数千行代码才能实现的功能,在这里只需几行。
ApricityUI 的语法本质上是固定的,并尽可能接近 Web 标准,因此你可以自由升级,并在不同游戏版本中使用它,而无需担心兼容性破坏。
从 1.2.5 开始,ApricityUI 还可以调用操作系统内置的 WebView,让你在游戏中嵌入一个真正的网站或网页,该网页仅接受硬件输入(包括视频播放)。
如果你不确定什么是 Web 框架,至少记住它的三个著名优势:
- 功能丰富:从简单的形状绘制到嵌套渲染效果——ApricityUI 甚至可以渲染到世界中的一个方块上。
- 易于使用:我见过的大多数速成教程都在三小时以内(最短的只有十分钟),而且 AI 对这个技术栈了如指掌。
- 易于调试:几乎所有内容都能即时热重载,便捷的开发者工具提供可视化调试。ApricityUI 两者兼备。
注意:ApricityUI 不捆绑 Chrome 运行时。它是完全用 Java 从头构建的;截至 1.2.4 版本,jar 包仅为 2.5 MB,不下载任何额外内容,使用安全。
展示
内置纯 CSS 主题
Ore 和 AE 主题是内置的,更多具有 Minecraft 风格(或故意非 Minecraft 风格)的通用主题将随后推出。它们都共享相同的 CSS 命名方案,因此在这之间切换是无缝的。
随时绘制
它与 Minecraft 的渲染完全集成——你想在哪里画就在哪里画。仅 KubeJS 就足以自定义物品提示框和径向菜单。
-
东方足道屿 物品提示框

-
简单径向菜单(由 SurpTalent 制作)

Canvas
Canvas 支持足以用于图表、SVG 绘图、复杂嵌套效果、涂鸦板等日常用途。
世界窗口
HTML 可以在世界内的某个位置进行渲染,并可配置角度、方块穿透、交互距离、视距、相机跟随、LOD 等细节。
-
东方足道屿 女仆足疗

-
生物血条和物品显示(由 ୧⍤⃝无月 制作)

原生 Minecraft 元素
以 HTML 的方式管理容器槽位、物品、流体、纹理、模型、精灵动画、翻译键以及其他原生元素。
富文本编辑器
富文本编辑器可以以数据驱动的方式构建。
- 内置富文本编辑器示例

WebView
为了让不同模组的 UI 保持独立又能相互交互,ApricityUI 采用了多文档架构。这消除了 iframe 标签的大部分意义,而且 Minecraft 很少需要嵌套界面——因此今天 ApricityUI 的 iframe 标签完全用于嵌入 WebView。
简单来说,使用 iframe 标签创建文档实际上会打开一个 WebView,并将其绘制在 iframe 区域内的屏幕外区域。
WebView 的缺点很明显:无论是从 Java 还是 KubeJS,都很难找到优雅的方式来与其进行逻辑交互,因此 ApricityUI 目前仅向其转发硬件输入。
其高内存占用也使得 WebView 不适合用于覆盖层和世界窗口。
少数环境根本不附带 WebView(例如 Linux),但该模组永远不会嵌入其中一个。
优点是 WebView 部分弥补了 ApricityUI 对浏览器标准支持不完整的缺陷。它可以渲染与游戏关系不大的复杂页面,或直接打开外部网站——例如实时文档、更新日志、模组教程视频——并支持构建世界内的影院功能。

面向开发者
注意:所有文档和技能(SKILL)已内置于模块文件中,AI 可直接使用。
使用 ApricityUI 无需了解源代码。如果需要,官方 Maven 仓库可用:
repositories {
maven {
url "https://maven.sighs.cc/repository/maven-public/"
}
}
dependencies {
implementation 'com.sighs:ApricityUI-forge-1.20.1:1.2.7'
}
使用 AI 开发 Web 应用非常简单——你甚至不需要 SKILL,ApricityUI 也是如此。
一个简单的示例:一句话即可生成界面。

不断生成随机设计直到满意为止,然后基于静态模板进行调整,这是一种高效的工作流。
新生成的静态模板可以直接导入并在资源管理器中预览;图像、音频、字体和其他静态资产也可以预览,右键菜单提供了快速参考。
为避免快捷键冲突,从 1.2.4 版本开始,资源管理器的快捷键默认未绑定——请在调试前自行绑定。

自 1.2.4 版本起,jar 包内包含完整文档,配置文件提供了自动截图选项(最多保留 20 张)以及文件变更时自动重新加载匹配界面的选项。所有这些功能都是为 AI 设计的。
在 AI 编码代理中,你可以这样表述以保持对设计的迭代优化:
任务是创建或修改 UI;仅允许更改 HTML/CSS/JS。
遵循捆绑文档中的指导。
已知:文件夹 run/screenshots/aui 每秒输出一次游戏截图;静态资产会自动监控,并在变更时触发重新加载。
测试循环:编辑 html/css/js 文件 -> 在日志中观察重新加载消息 -> 等待三秒,然后检查 screenshots 文件夹中的最新截图 -> 判断是否符合要求;如果不符合,继续编辑;如果符合,停止。
目标 HTML 文件:run/apricity/test/quest.html
所需结果:一个游戏内任务列表,现代扁平风格,红白配色
参考图片:run/screenshots/image_614748742442633.png
完整的 SKILL 详见 官方文档,并已随完整文档一起打包在 jar 文件中。
在 Minecraft 中,复杂的 UI 需求并不常见。通常来说,让 AI 阅读捆绑的文档就足以一次性完成大部分设计工作,并且使用内置主题后,效果已经相当不错。
当界面大致完成后,你可以调出类似浏览器的调试工具——同样,自 1.2.4 版本起默认未绑定快捷键。
在 DevTools 中,你可以定位并选取页面上的元素,直接编辑样式和内容,支持撤销和重做,然后保存样式或完整的 DOM 内容。
关于不支持的功能、语法错误、内部异常等问题的日志会镜像到 DevTools 控制台中。

你也可以借用 Codepen 上现成的样式。如果遇到缺失的 CSS 属性,请在 Github 上提交 Issue。
资产分发
ApricityUI 支持 HTML、CSS、Javascript、TTF/OTF 字体以及包括 GIF 在内的大多数图像格式作为静态资产;音频和视频正在计划中。
资产位于版本实例的 apricity 文件夹和资源包中。资源包的优先级较低,但全局默认样式和内置字体随模组自身的资源发布。
对于整合包开发者,推荐使用 apricity 文件夹。热重载默认绑定到 END 键,通常耗时不到一秒。
详细信息请参阅官方文档的 资源管理器 章节。
如果你想打包和分享,资源包或普通归档文件均可。由于资源包也需要重载游戏,建议使用简单的归档文件。
对于将 ApricityUI 作为依赖的模组,采用资源包形式更好:默认加载路径中包含最高优先级的开发用资源包路径,非常方便。
另一种选择是网络资产,例如图床或开源静态托管站点。ApricityUI 支持异步加载网络资产——只是不要滥用它。
ApricityUI 还提供了一种复古的“服务器向客户端发送 HTML 进行渲染”的工作流,让你能够完全从服务器端管理客户端 UI。
想了解更多?
- ApricityUI 还实现了类似浏览器的缩放功能:按住 CTRL 并在页面上滚动即可放大或缩小,从而让玩家能够适应任意窗口大小。
- KubeJS 为可选依赖项。若未安装此模组,则无法运行嵌入在 HTML 中的 JavaScript 代码,且控制台将不可用——但对于模组开发者而言这通常不是问题,因为 DOM 操作完全可以在 Java 中完成。
- 热重载速度极快:包含内联 JS、二十种不同 QQ 头像以及三种自定义字体在内的整个文档,仅需约一秒即可完成重载。如果你编写了 KubeJS 客户端脚本,甚至可以借此偷懒——不过资源路径方面不提供 PJS 自动补全。请注意,此次重载不会重新加载资源包。
- ApricityUI 在日常使用中并无明显性能瓶颈,且在 26.1 及以上版本中几乎无需担心性能问题。但由于作者无法测试所有场景——如果你遇到突然的卡顿现象,请立即报告。
- Vue 和 Svelte 等现代前端框架的轻量级移植版正在积极开发中。简单的 Vue 已有 kltyton 提交的 PR,而 Svelte 将在后续版本中集成。感兴趣的话欢迎加入群组!
截图展示
ApricityUI
Build UIs with HTML + CSS + JS. The syntax follows Web standards as closely as possible.

Overview
ApricityUI was built around one goal: a UI framework that is low-friction, convenient, and broadly capable. That is why it takes the classic HTML + CSS + JS trio as its core.
The JS side currently depends on KubeJS (optional), which means modpack authors can draw whatever UI they like with an extremely low learning curve.
How low? You can have AI generate everything ApricityUI-related for you. Web frameworks are popular enough that AI knows them well — the result may even look better than what you would draw yourself, and you can still read it.
Mods that need custom UI can also depend on ApricityUI to build highly extensible interfaces; the JS and Java APIs are broadly equivalent.
Where does that extensibility show? Nested masks, smooth scrolling, rounded borders, frosted-glass backgrounds, custom animations, custom fonts, GIF playback — even filters, masks, and shadows nested inside one another. Features that take hundreds or thousands of lines elsewhere are a few lines here.
ApricityUI's syntax is essentially fixed and stays as close to Web standards as possible, so you can upgrade freely and use it across game versions without worrying about compatibility breaks.
From 1.2.5 onward, ApricityUI can also call the WebView built into your operating system, letting you embed a real website or web page inside the game that accepts only hardware input (video playback included).
If you are not sure what a Web framework is, at least remember its three well-known advantages:
- Rich functionality, from simple shape drawing to nested rendering effects — ApricityUI can even render onto a block in the world.
- Easy to use: most crash courses I have seen are under three hours (the shortest is ten minutes), and AI knows the stack inside out.
- Easy to debug: almost everything hot-reloads instantly, and convenient developer tools provide visual debugging. ApricityUI has both.
Note: ApricityUI does not bundle a Chrome runtime. It is built entirely from scratch in Java; as of 1.2.4 the jar is only 2.5 MB, it downloads nothing extra, and it is safe to use.
Showcase
Built-in pure-CSS themes
The Ore and AE themes are built in, and more MC-flavored (or deliberately un-MC) general-purpose themes will follow. They all share the same CSS naming scheme, so switching between them is seamless.
Draw whenever you like
It integrates fully with Minecraft's rendering — draw wherever you want. KubeJS alone is enough to customize item tooltips and radial menus.
Canvas
Canvas support that is good enough for charts, SVG drawing, complex nested effects, doodle boards, and similar everyday work.
World windows
HTML can render at a position inside the world, with configurable angle, block pass-through, interaction distance, view distance, camera follow, LOD, and other details.
Native Minecraft elements
Manage container slots, items, fluids, textures, models, sprite animations, translation keys, and other native elements the HTML way.
Rich text editor
Rich text editors can be built in a data-driven way.
- Built-in rich text editor example

WebView
So that different mods' UIs can stay independent while still interacting with each other, ApricityUI uses a multi-document architecture. That removes most of the point of the iframe tag, and Minecraft rarely needs nested interfaces anyway — so today ApricityUI's iframe tag is used entirely to embed WebView.
Put simply, creating a document with an iframe tag actually opens a WebView and draws it off-screen into the iframe's area.
WebView's drawbacks are obvious: from either Java or KubeJS it is hard to find an elegant way to interact with it logically, so ApricityUI currently only forwards hardware input to it.
Its high memory use also makes WebView a poor fit for overlays and world windows.
A small number of environments do not ship a WebView at all (Linux, for example), but this mod will never embed one.
The upside is that WebView partly compensates for ApricityUI's incomplete coverage of browser standards. It can draw complex pages that have little to do with the game, or open external sites directly — live documentation, changelogs, mod tutorial videos — and it supports building an in-world cinema.

For developers
Note: All documents and skills are built into the module file, and AI is ready to use.
Using ApricityUI requires no knowledge of the source code. If you need it, the official Maven is available:
repositories {
maven {
url "https://maven.sighs.cc/repository/maven-public/"
}
}
dependencies {
implementation 'com.sighs:ApricityUI-forge-1.20.1:1.2.7'
}
Developing Web apps with AI is very easy — you do not even need a SKILL, and the same goes for ApricityUI.
A simple example: one sentence generates an interface.

Generating random designs until you like one, then adapting the static template, is a high-efficiency workflow.
A freshly generated static template can be imported and previewed directly in the resource manager; images, audio, fonts, and other static assets can be previewed too, and the context menu offers quick reference.
To avoid key conflicts, starting with 1.2.4 the resource manager shortcuts are unbound by default — bind them yourself before debugging.

Since 1.2.4 the jar bundles the complete documentation, and the config file has options for automatic screenshots (up to 20 kept) and for reloading the matching interface as soon as a file changes. All of these are designed for AI.
Inside an AI coding agent you can phrase it this way to keep iterating on a design:
The task is to create or modify a UI; only HTML/CSS/JS may be changed.
Follow the guidance in the bundled documentation.
Known: the folder run/screenshots/aui outputs a game screenshot every second; static assets are watched automatically and trigger a reload on change.
Test loop: edit the html/css/js files -> watch the log for the reload message -> wait three seconds, then check the newest screenshot in the screenshots folder -> judge whether it matches the requirement; if not, keep editing, if yes, stop.
Target HTML file: run/apricity/test/quest.html
Required result: an in-game quest list, modern flat style, red and white palette
Reference image: run/screenshots/image_614748742442633.png
The full SKILL is documented in the official docs and is bundled in the jar with the full docs.
Complex UI needs are rare in Minecraft. In general, letting AI read the bundled documentation is enough to finish most design work in one pass, and with a built-in theme the result already looks good.
Once the interface is roughly done, you can bring up debugging tools similar to a browser's — also unbound by default since 1.2.4.
In DevTools you can locate and pick elements on the page and edit styles and content directly, with undo and redo, then save the styles or the full DOM content.
Logs about unsupported features, syntax errors, internal exceptions, and similar problems are mirrored into the DevTools console.

You can also borrow ready-made styles from Codepen. If you hit a CSS property you need that is missing, open an issue on Github.
Asset distribution
ApricityUI supports HTML, CSS, Javascript, TTF/OTF fonts, and most image formats including GIF as static assets; audio and video are planned.
Assets live in the apricity folder of the version instance and in resource packs. Resource packs have lower priority, but the default global styles and built-in fonts ship in the mod's own resources.
For modpack developers, the apricity folder is the recommended location. Hot reload is bound to END by default and usually takes under a second.
See the Resource Manager chapter of the official docs for details.
If you want to package and share, either a resource pack or a plain archive works. Since a resource pack also requires reloading the game, a simple archive is recommended.
For mods that use ApricityUI as a dependency, the resource-pack form is better: the default load paths include the development resource-pack path with the highest priority, which is very convenient.
Another option is network assets, such as image hosts or open-source static hosting sites. ApricityUI supports loading network assets asynchronously — just do not do anything bad with it.
ApricityUI also offers a retro "server sends HTML to the client to render" workflow, which lets you manage the client UI entirely from the server.
Want to know more?
- ApricityUI also implements browser-style zoom: hold CTRL and scroll on a page to zoom in and out, so players can adapt to any window size.
- KubeJS is an optional dependency. Without it you cannot run the JavaScript written inside HTML, and the console is unavailable — but for mod developers that rarely matters, since DOM work can be done in Java.
- Hot reload is fast: twenty different QQ avatars plus three custom fonts, including inline JS, reload a whole document in about one second. If you write KubeJS client scripts you might even use it to cut corners — though the resource paths offer no PJS completion. Note that this reload does not reload resource packs.
- ApricityUI has no obvious performance bottleneck in normal use, and on 26.1 and above there is almost nothing to worry about. But the author cannot test every case — if you happen to hit a sudden stutter, please report it immediately.
- Lightweight ports of modern front-end frameworks such as Vue and Svelte are in active development. A simple Vue already has a PR from kltyton, and Svelte will be built in later. Join the group if you are interested!
Gallery
评论 0
登录后参与评分
还没有评论,来抢沙发吧