你的网页应用,运行在 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
你甚至不需要网络主机
将文件放在服务器的文件夹中,并将模组指向它们。这些文件通过玩家已经使用的同一连接传输——无需域名、无需托管费用、无需开放端口,在 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 |
| 1.20.1 – 26.3 |
Paper 插件,仅限服务器端 |
Paper 服务器可以从本页面安装 WebGUI 插件,而不是安装模组;客户端仍需安装模组。以上所有内容在 Paper 上也适用,除了绑定到实体的 GUI,目前仅限模组支持。
安装说明: 在 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 |
| 1.20.1 – 26.3 |
Paper plugin, server only |
Paper servers can install the WebGUI plugin from this page instead of the mod; players still need the client mod. Everything above works on Paper too, except GUIs bound to entities, which are mod-only for now.
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
登录后参与评分
还没有评论,来抢沙发吧