World Switcher
在一个服务器上运行多个世界,让玩家通过一条命令即可在世界之间切换 —— 类似 Multiverse,但专为 NeoForge 打造。
100% 服务端:无需客户端安装。Vanilla 1.21.1 客户端可以在不安装该模组的情况下加入服务器,因为 World Switcher 不会注册任何物品、方块或网络数据包——自定义世界使用原版的 minecraft:overworld 维度类型,并带有 worldswitcher:* 键值,原版客户端可以接受这一设定。
? AI 协作声明:本项目的大部分开发工作是在与 Anthropic 的 Claude AI(以及 JetBrains 的 Junie 作为辅助助手)合作下完成的。AI 在代码实现、文档编写和项目结构方面提供了帮助。虽然核心创意和方向来自人类的创造力,但 AI 的协助使该项目更加稳健且功能完善。我们主张对 AI 的使用保持透明,同时庆祝人机协作在软件开发中的潜力。
特性
-
/ws <world> — 即时切换世界,无需重启服务器。单独输入 /ws 可列出所有世界(可点击)。default 对应原版世界组(主世界/下界/末地),始终可用。
-
/wsc — 供管理员使用的世界管理命令,按作用对象分组:world(create、import、rename、load、unload、info、delete、gamerule、difficulty、gamemode、access)、player(tp、state …)、group 和 config。所有 1.5.0 版本之前的命令仍可作为已弃用的别名使用。
-
每位玩家、每个世界的玩家状态(可选,默认开启):库存、末影箱、经验值、生命值、饥饿值、效果、游戏模式以及最后位置,都会为每个世界分别保存。原版维度(主世界/下界/末地)被视为一个组。
-
基于模组化的玩家状态,支持按世界独立配置且无依赖项,并可通过按键进行配置:生成的带注释文件 serverconfig/worldswitcher-playerdata.toml 列出了服务器上找到的所有内容——NeoForge 数据附加组件(例如整个 Curios 饰品栏)、持久化玩家 NBT(NeoForgeData,被 Waystones/Quark 等模组使用……)、Tough As Nails 的口渴/温度值,以及拥有自己存储系统的模组如 Cosmetic Armor Reworked ——每项均包含所属模组名称、描述,以及简单的 true(按世界生效)/ false(全局生效)选项。使用 /wsc config playerdata scan 和 … set <key> <true|false> 可实时查看和修改。
-
世界组:将任意一组世界放入同一个库存组中,它们将共享单一的玩家状态——这是保持世界同步的诚实做法。使用 /wsc group set <world> <group>。组 default 对应原版维度,因此将某个世界放入该组意味着玩家会保留其主要物品(即旧的 shareinventory 行为,仍作为别名提供)。
-
在世界间移动玩家的状态:使用 /wsc player state show|copy|move|swap|clear,包括离线玩家。位置不会随之转移;其余一切(包括模组化状态)都会转移。
-
按世界设置的游戏模式:世界可以提供一个 默认 模式用于初始化玩家的首次访问,或 强制 模式在每次进入时重新应用——这区分了“这是创造模式世界”与“这里不允许离开冒险模式”。使用 /wsc world gamemode <world> <mode> [forced]。
-
受限世界:通过 /wsc world access <world> <0-4> 为世界设置最低权限等级。此限制适用于 /ws 命令、通往该世界的传送门以及登录时;对于无权进入的玩家,受限世界也会从 Tab 补全列表中隐藏。
-
按世界设置的游戏规则、时间、天气与难度:每个受管世界都保留自己的时钟、天气、规则和难度。/gamerule、/time、/weather 和 /difficulty 是
-
上下文敏感:按世界单独冻结时间或保持永恒黑夜,睡眠仅跳过当前所在世界的夜晚。同时兼容模组规则,例如 Serene Seasons 的 doSeasonCycle。
-
命令钩子:在世界事件发生时自动执行管理员定义的命令——包括 firstPlayerJoin(玩家数从 0 → 1)、lastPlayerLeave(玩家数从 1 → 0)以及 playerMoved(玩家切换世界)。可在 serverconfig/worldswitcher-hooks.json 中全局或按世界定义这些钩子,支持使用 {{worldName}}、{{worldId}}、{{playerName}} 和 {{playerUuid}} 变量,并可指定每个钩子的执行身份(server/player)。通过 /wsc config hooks reload 实现热重载。非常适合在世界为空时暂停 doDaylightCycle/doWeatherCycle(或 Serene Seasons 的 doSeasonCycle)。
-
可点击的世界切换公告:当有人切换世界时,其他玩家会在聊天栏看到一条消息,其中包含世界名称作为可点击的 /ws <world> 链接,方便跟随切换。
-
正确的世界导入方式:仅复制主世界数据,从源 level.dat 读取种子与出生点信息,确保地形在导入边界之外继续无缝生成。旧版世界(1.18+)会自动实时升级。
-
安全重命名:显示名称与内部世界 ID 解耦——物品栏、床的重生位置和世界文件夹在重命名后均能保留。
-
持久化:注册的世界会在服务器启动时自动重新加载。
边缘情况处理
- 默认世界组内的下界传送门不会触及你的物品栏。
- 跨越不同世界组的传送门会交换玩家状态,类似于
/ws 命令的效果(可配置)。
- 在没有床的世界中死亡时,你会在默认世界中以默认状态重生——你的物品仍保留在原世界的死亡地点。
- 如果在你离线期间某个世界被删除,你将在登录时被安全地重新同步到主世界。
配置
请参阅 world/serverconfig/worldswitcher-server.toml,例如 separateInventories(默认 true)、
wsPermissionLevel(0 = 所有人均可使用 /ws)、worldsFolder(导入文件夹,默认
worlds)、autoLoadOnStartup、restoreLastPosition、handlePortalGroupChanges、
perWorldGameRules、perWorldTimeAndWeather、perWorldDifficulty、announceSwitches 以及
enableCommandHooks / hookDefaultRunAs。旁边有两个生成的文件:
用于命令钩子的 worldswitcher-hooks.json,以及用于关于哪些模组玩家数据按世界划分、哪些为全局的每键决策的 worldswitcher-playerdata.toml。
注意事项
- 本质上始终为全局:硬核模式、难度锁定、
sendCommandFeedback、
logAdminCommands、spawnChunkRadius。
- 地图模组(如 BlueMap 等)将看到额外的维度,可能需要按维度配置。
/execute in worldswitcher:<id> run ... 可照常工作——便于调试。
关于 AI 辅助
本项目展示了人机协作在软件开发中的潜力。AI 助手协助了代码实现、文档编写、项目结构、CI/CD 设置和错误修复。虽然 AI 提供了技术支持,但所有创意决策、功能构想和项目方向均来自人类输入。我们认为,对 AI 使用的这种透明度对于开源社区至关重要。
完整文档见 GitHub。
World Switcher
Run multiple worlds on one server and let players switch between them with a single
command — Multiverse-style, but for NeoForge.
100% server-side: no client installation needed. Vanilla 1.21.1 clients can join without the
mod, because World Switcher registers no items, blocks or network payloads — custom worlds use the
vanilla minecraft:overworld dimension type with a worldswitcher:* key that vanilla clients
accept.
? AI Collaboration Notice: The bulk of this project was developed in collaboration with
Anthropic's Claude AI (with JetBrains' Junie as a complementary assistant). The AI helped with
code implementation, documentation, and project structure. While the core ideas and direction
came from human creativity, the AI's assistance made this project more robust and feature-complete.
We believe in transparency about AI usage while celebrating the potential of human-AI
collaboration in software development.
Features
/ws <world> — switch worlds instantly, no server restart. Bare /ws lists all worlds
(clickable). default is the vanilla world group (overworld/nether/end) and is always available.
/wsc — world management for operators, grouped by what it acts on: world
(create, import, rename, load, unload, info, delete, gamerule, difficulty,
gamemode, access), player (tp, state …), group and config. Every pre-1.5.0
command still works as a deprecated alias.
- Per-player, per-world player state (optional, on by default): inventory, ender chest, XP,
health, hunger, effects, game mode and last position are kept separately for every world. The
vanilla dimensions (overworld/nether/end) count as one group.
- Modded player state per world, dependency-free, and configurable per key: a generated,
commented
serverconfig/worldswitcher-playerdata.toml lists everything found on your server —
NeoForge data attachments (e.g. the whole Curios inventory), persistent player NBT
(NeoForgeData, used by Waystones/Quark, …), Tough As Nails thirst/temperature, and mods
that keep their own storage such as Cosmetic Armor Reworked — each with the owning mod, a
description, and a simple true (per world) / false (global). Inspect and change it live with
/wsc config playerdata scan and … set <key> <true|false>.
- World groups: put any set of worlds into one inventory group and they share a single player
state — the honest way to keep worlds in sync.
/wsc group set <world> <group>. The group
default is the vanilla dimensions, so putting a world there means players keep their main
items (the old shareinventory behaviour, still available as an alias).
- Move a player's state between worlds:
/wsc player state show|copy|move|swap|clear, offline
players included. Position never travels; everything else does, modded state and all.
- Per-world game mode: a world can hand out a mode as a default that seeds a player's first
visit, or forced, re-applied on every entry — the difference between "this is the creative
world" and "nobody leaves adventure mode here".
/wsc world gamemode <world> <mode> [forced].
- Restricted worlds: give a world a minimum permission level with
/wsc world access <world> <0-4>. Enforced for /ws, for portals leading into it and at login;
restricted worlds also disappear from tab completion for players who cannot enter them.
- Per-world game rules, time, weather & difficulty: each managed world keeps its own clock,
weather, rules and difficulty.
/gamerule, /time, /weather and /difficulty are
context-sensitive; freeze time or keep eternal night per world, and sleeping only skips your own
world's night. Works with modded rules too, e.g. Serene Seasons' doSeasonCycle.
- Command hooks: run admin-defined commands automatically on world events —
firstPlayerJoin (0 → 1 players), lastPlayerLeave (1 → 0 players) and playerMoved (a player
switches world). Define them globally and per world in
serverconfig/worldswitcher-hooks.json, with {{worldName}}, {{worldId}}, {{playerName}}
and {{playerUuid}} variables and per-hook run-as (server/player). Live-reload with
/wsc config hooks reload. Perfect for pausing doDaylightCycle/doWeatherCycle (or Serene
Seasons' doSeasonCycle) while a world is empty.
- Clickable switch announcements: when someone switches world, everyone else sees a chat
message whose world name is a clickable
/ws <world> link to follow along.
- World import done right: copies only the overworld data, reads seed & spawn from the source
level.dat, so terrain keeps generating seamlessly beyond the imported border. Old worlds
(1.18+) are upgraded on the fly.
- Safe renaming: display names are decoupled from the internal world id — inventories, bed
spawns and world folders survive renames.
- Persistent: registered worlds are re-loaded automatically at server start.
Edge cases handled
- Nether portals inside the default world group don't touch your inventory.
- Portals that cross world groups swap the player state like
/ws would (configurable).
- Dying in a world without a bed respawns you in the default world with your default state — your
items stay at the death spot in the other world.
- If a world is deleted while you're offline in it, you're safely reconciled into the overworld on
login.
Configuration
See world/serverconfig/worldswitcher-server.toml, e.g. separateInventories (default true),
wsPermissionLevel (0 = everyone may use /ws), worldsFolder (import folder, default
worlds), autoLoadOnStartup, restoreLastPosition, handlePortalGroupChanges,
perWorldGameRules, perWorldTimeAndWeather, perWorldDifficulty, announceSwitches and
enableCommandHooks / hookDefaultRunAs. Two generated files sit next to it:
worldswitcher-hooks.json for the command hooks, and worldswitcher-playerdata.toml for the
per-key decisions about which modded player data is per world and which is global.
Notes
- Always global by nature: hardcore, the difficulty lock,
sendCommandFeedback,
logAdminCommands, spawnChunkRadius.
- Map mods (BlueMap etc.) will see the extra dimensions and may need per-dimension config.
/execute in worldswitcher:<id> run ... works as usual — handy for debugging.
About AI Assistance
This project demonstrates the potential of human-AI collaboration in software development. The AI
assistant helped with code implementation, documentation, project structure, CI/CD setup and bug
fixes. While the AI provided technical assistance, all creative decisions, feature ideas and
project direction came from human input. We believe this transparency about AI usage is important
for the open-source community.
Full documentation on GitHub.
评论 0
登录后参与评分
还没有评论,来抢沙发吧