Server: one level per dimension, so players can be in different dimensions
A server (the dedicated server and single player's server thread) now holds a level per dimension, like vanilla's `MinecraftServer.levels`. Each server tick runs every level with players in it, one at a time, by swapping its fields into place (game/levels.rs), so the world tick code runs unchanged. Before this, a portal did nothing while two or more players were online. - Levels: the parked levels keep the world, streaming, save, block ticks, entities, block entity state, raids, sculk and creaking scans. The Overworld stays loaded; another level is saved and closed after 300 ticks with nobody in it. Saving saves every level. - Hub: `tick` is split into `poll` (the network, once per tick), `tick_level` (the packets, chunks, block changes, containers and entities of the players in the level in place) and `end_tick` (latency). Each guest has a dimension; time, weather, sounds and events reach only the players in their level, and the clock and weather last sent are kept per level. - Travel: every player has their own portal state; a portal moves only that player into the destination's level (`ServerPlayer.teleport` packets as before). Respawning brings a player back to the Overworld's level. - Player data saves and loads each player's dimension, and a returning player is placed in their own level. - tools/lan_e2e.py --server-thread --check portals: the guest goes to the Nether while the host stays, then the host goes to the End while the guest is in the Nether, and both come back. The in-frame game keeps its one level that follows its player. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,10 @@ pub fn apply(guest: &mut Guest, level: &Level) {
|
||||
guest.selected = (level.selected_slot.max(0) as usize).min(8);
|
||||
guest.saved = level.player_extra.clone();
|
||||
guest.recipe_book = level.recipe_book.clone();
|
||||
guest.dimension = match level.dimension.as_str() {
|
||||
d @ ("minecraft:the_nether" | "minecraft:the_end") => d.to_owned(),
|
||||
_ => "minecraft:overworld".to_owned(),
|
||||
};
|
||||
if level.ender_items.len() == 27 {
|
||||
guest.ender_items = level.ender_items.clone();
|
||||
}
|
||||
@@ -100,7 +104,6 @@ pub fn apply(guest: &mut Guest, level: &Level) {
|
||||
pub fn save(guest: &Guest, world: &Path) {
|
||||
let mut level = Level {
|
||||
player_uuid: Some(uuid_ints(guest.uuid)),
|
||||
dimension: "minecraft:overworld".into(),
|
||||
..Level::default()
|
||||
};
|
||||
store(guest, &mut level);
|
||||
@@ -114,6 +117,7 @@ pub fn save(guest: &Guest, world: &Path) {
|
||||
/// Put a guest's state in `level`'s player fields.
|
||||
pub fn store(guest: &Guest, level: &mut Level) {
|
||||
level.position = Some(guest.position);
|
||||
level.dimension = guest.dimension.clone();
|
||||
level.rotation = [guest.yaw, guest.pitch];
|
||||
level.health = guest.health;
|
||||
level.food = guest.food;
|
||||
|
||||
Reference in New Issue
Block a user