你的网页应用,运行在 Minecraft 中。
WebGUI 在游戏中打开真正的网页——作为全屏界面,或作为游戏画面之上的透明叠加层。不是换皮的库存界面,也不是另一个需要学习的 UI 框架:而是由真正的 Chromium 渲染的真实 HTML、CSS 和 JavaScript。
如果你能构建一个网站,你就能构建 Minecraft 的界面。
人们用它构建什么
- 服务器商店:看起来像在线商店,带有图片、搜索功能和购物车
- 任务日志和百科全书:拥有真实的排版和布局
- 实时地图:使用 Leaflet 或你自己的 Canvas,跟随玩家移动
- HUD 叠加层:团队得分、计时器、血条、小地图等,绘制在世界之上
- 管理面板:供工作人员使用,与你已经在浏览器中运行的仪表板相同
- 自定义死亡屏幕:显示是谁杀了你,并让你重生
- 启动菜单和大厅屏幕,带有你服务器的专属品牌标识
- 完整的内置应用:任何你原本会构建为 Web 应用的东西
为什么感觉不同
你已经使用的东西都能正常工作。React、Vue、Svelte 或纯 JavaScript。Tailwind。你的组件库。你的动画、你的 API、你的 WebSocket。你在浏览器中进行开发并使用热重载,然后将模组指向该页面——它在游戏中的外观与在浏览器中完全相同。
这个页面不仅仅是装饰。它知道谁正在查看它以及周围发生了什么——玩家的名称、生命值、饥饿值、位置、朝向、准星下的方块或生物——随着玩家的移动而实时更新。并且它可以交互:页面上的点击变成服务器上的事件,所以商店可以真正售卖商品,按钮可以真正执行命令。
// 这就是整个集成代码
window.webgui.on('client', player => {
document.title = `${player.username} — ${player.health} HP`;
});
window.webgui.postToGame({ channel: 'shop:buy', item: 'diamond' });
对于 React、Vue 和 Svelte,有一个包含现成 hooks 和 stores 的包:
npm i @webgui/client
你甚至不需要 Web 主机
将文件放在服务器的文件夹中,并将模组指向它们。它们通过玩家已经使用的同一连接传输——无需域名、无需托管费用、无需打开端口,即使在 NAT 后面也能工作。编辑一个文件,运行一条命令,玩家打开的页面就会在他们面前刷新。
更喜欢使用自己的主机?没有任何变化:https:// 地址的工作方式与往常一样,两者可以自由混合使用。
面向服务器所有者
打开一个页面只需一条命令:
/webgui gui @a https://your-site.example/shop
/webgui hud @a webgui:/hud.html
页面也可以绑定到实体上,因此右键点击村民即可打开以该村民上下文为基础的商店。模组打开的每个 URL 都携带签名令牌,因此你的后端无需登录界面就能知道是哪个玩家在请求。没有安装模组的玩家会被告知他们缺少了什么,而不是安静地看到空白。
兼容性
| Minecraft |
Loader |
| 26.2 · 26.1.2 |
NeoForge |
| 1.21.5 – 1.21.11 |
Fabric · NeoForge |
| 1.21 – 1.21.1 |
Fabric · NeoForge |
| 1.20.1 |
Fabric |
Minecraft 26 目前仅支持 NeoForge —— Fabric 正在等待 26.x 的 Yarn 映射。
安装: 在 Fabric 上你需要 Fabric API,仅此而已——浏览器随 jar 包一起分发。在 NeoForge 上,请同时添加 Rinku;启动器会自动识别它们。Chromium(约 150 MB)会在首次启动时自行下载。需要 Java 21,或 Minecraft 26 所需的 Java 25。
链接
- 文档 — — 指南、完整 API 和可粘贴的示例
- GitHub — — 问题反馈和源代码
- npm —
Your web app, running inside Minecraft.
WebGUI opens a real web page in the game — as a full-screen interface or as a transparent overlay on top of gameplay. Not a reskinned inventory, not another UI framework to learn: actual HTML, CSS and JavaScript, rendered by actual Chromium.
If you can build a website, you can build a Minecraft interface.
What people build with it
- Server shops that look like an online store, with images, search and a cart
- Quest journals and codexes with real typography and layout
- Live maps — Leaflet or your own canvas, following the player as they walk
- HUD overlays — team scores, timers, health bars, a minimap, drawn over the world
- Admin panels for staff, with the same dashboard you already run in a browser
- Custom death screens that say who killed you and let you respawn
- Launch menus and lobby screens with your server's own branding
- Entire in-game apps — anything you would otherwise build as a web app
Why it feels different
Everything you already use keeps working. React, Vue, Svelte or plain JavaScript. Tailwind. Your component library. Your animations, your API, your WebSocket. You develop in a browser with hot reload, then point the mod at the page — and it looks exactly the same in the game.
The page is not a decoration, either. It knows who is looking at it and what is happening around them — the player's name, health, food, position, where they are looking, which block or mob is under the crosshair — updated as they move. And it can talk back: a click in the page becomes an event on the server, so a shop can actually sell, and a button can actually run a command.
// This is the whole integration
window.webgui.on('client', player => {
document.title = `${player.username} — ${player.health} HP`;
});
window.webgui.postToGame({ channel: 'shop:buy', item: 'diamond' });
For React, Vue and Svelte there is one package with hooks and stores ready to go:
npm i @webgui/client
You don't even need a web host
Put your files in a folder on the server and point the mod at them. They travel down the same connection the player is already on — no domain, no hosting bill, no port to open, works behind NAT. Edit a file, run one command, and the page a player has open refreshes in front of them.
Prefer your own host? Nothing changes: an https:// address works exactly as it always did, and the two mix freely.
For server owners
Opening a page is one command:
/webgui gui @a https://your-site.example/shop
/webgui hud @a webgui:/hud.html
Pages can also be bound to an entity, so right-clicking a villager opens your shop with that villager's context. Every URL the mod opens carries a signed token, so your backend knows which player is asking without a login screen. Players without the mod are told what they are missing instead of quietly seeing nothing.
Compatibility
| Minecraft |
Loader |
| 26.2 · 26.1.2 |
NeoForge |
| 1.21.5 – 1.21.11 |
Fabric · NeoForge |
| 1.21 – 1.21.1 |
Fabric · NeoForge |
| 1.20.1 |
Fabric |
Minecraft 26 is NeoForge-only for now — Fabric is waiting on Yarn mappings for 26.x.
Installing: on Fabric you need Fabric API, and that is it — the browser ships inside the jar. On NeoForge, add Rinku alongside it; launchers pick it up automatically. Chromium (~150 MB) downloads itself on first launch. Java 21, or Java 25 for Minecraft 26.
Links
- Documentation — — guides, the full API, and examples you can paste
- GitHub — — issues and source
- npm —
评论 0
登录后参与评分
还没有评论,来抢沙发吧