你的 Web 应用,运行在 Minecraft 中。
WebGUI 在游戏中打开一个真正的网页——作为全屏界面,或作为游戏画面之上的透明覆盖层。不是换皮的物品栏,也不是另一个需要学习的 UI 框架:而是由真正的 Chromium 渲染的实际 HTML、CSS 和 JavaScript。
如果你能构建网站,你就能构建 Minecraft 界面。
人们用它构建什么
- 服务器商店,看起来像在线商店,带有图片、搜索功能和购物车
- 任务日志和法典,具有真实的排版和布局
- 实时地图——Leaflet 或你自己的 Canvas,跟随玩家移动
- HUD 覆盖层——团队得分、计时器、血条、小地图,绘制在世界之上
- 管理员面板供工作人员使用,与你已经在浏览器中运行的仪表板相同
- 自定义死亡屏幕,显示是谁杀了你并让你重生
- 启动菜单和大厅屏幕,带有你服务器的品牌标识
- 完整的内置应用——任何你原本会作为 Web 应用构建的东西
为什么感觉不同
你 already 使用的所有东西都能正常工作。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.3 · 26.2 |
Fabric · NeoForge |
| 26.1 – 26.1.2 |
Fabric |
| 26.1.2 |
NeoForge |
| 1.21.11 |
Fabric · NeoForge |
| 1.21 – 1.21.1 |
Fabric · NeoForge |
| 1.20.1 |
Fabric |
安装: 在 Fabric 上你需要 Fabric API;在 NeoForge 上,不需要其他任何东西。浏览器引擎打包在 jar 中,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.3 · 26.2 |
Fabric · NeoForge |
| 26.1 – 26.1.2 |
Fabric |
| 26.1.2 |
NeoForge |
| 1.21.11 |
Fabric · NeoForge |
| 1.21 – 1.21.1 |
Fabric · NeoForge |
| 1.20.1 |
Fabric |
Installing: on Fabric you need Fabric API; on NeoForge, nothing else. The browser engine ships inside the jar, and Chromium (~150 MB) downloads itself on first launch, once per machine. 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
登录后参与评分
还没有评论,来抢沙发吧