diff --git a/crates/horizon-client/src/bin/horizon-ctl/main.rs b/crates/horizon-client/src/bin/horizon-ctl/main.rs index 2e1b1bb56..27d9d5ba1 100644 --- a/crates/horizon-client/src/bin/horizon-ctl/main.rs +++ b/crates/horizon-client/src/bin/horizon-ctl/main.rs @@ -215,7 +215,12 @@ impl Session { let deadline = Instant::now() + Duration::from_secs_f64(limit.max(0.0)); loop { let status = self.game("status")?; - if !status["player"].is_null() && status["pending_chunks"] == 0 { + // On a server (single player's server thread too), also the + // level around the player. + if !status["player"].is_null() + && status["pending_chunks"] == 0 + && status["server"]["loaded"] != false + { return Ok(status); } if Instant::now() > deadline { diff --git a/crates/horizon-client/src/game/integrated.rs b/crates/horizon-client/src/game/integrated.rs index b2c0a2e7f..56d71ca96 100644 --- a/crates/horizon-client/src/game/integrated.rs +++ b/crates/horizon-client/src/game/integrated.rs @@ -316,6 +316,7 @@ impl Game<'_> { // The owner is an operator when the world allows commands // (`IntegratedPlayerList`, `MinecraftServer.getProfilePermissions`). host.hub.ops.insert(owner, if commands { 4 } else { 0 }); + host.hub.singleplayer_owner = Some(owner); host.owner = Some(Owner { uuid: owner, saved: Some(saved), diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index d33334949..441eaf3db 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -2421,6 +2421,17 @@ impl Game<'_> { (player.position.z.floor() as i32) >> 4, ); if !self.streaming.is_lit(cx, cz) { + // Moved where nothing is loaded by horizon-ctl (`tp`, `fly`): + // the server hears of it, and sends the chunks there. A player + // who walked there has already sent that move. + let pos = [player.position.x, player.position.y, player.position.z]; + if let Some(r) = self.remote.as_ref() + && r.loaded_sent + && r.last_pos != pos + { + let input = r.last_input; + self.remote_send_state(input); + } return Ok(()); } if self.remote.as_ref().is_some_and(|r| !r.loaded_sent) { @@ -3712,6 +3723,9 @@ impl Game<'_> { "address": horizon_client::net::shown_address(&r.session.address), "name": r.session.name, "joined": r.joined, + // ServerboundPlayerLoadedPacket sent: the level around the + // player is ready, and the client ticks and sends its moves. + "loaded": r.loaded_sent, "status": r.status, "entity_id": r.entity_id, "dimension": r.dimension.name, diff --git a/crates/horizon-client/src/lan/hub.rs b/crates/horizon-client/src/lan/hub.rs index 5d593be2d..ca198b7b6 100644 --- a/crates/horizon-client/src/lan/hub.rs +++ b/crates/horizon-client/src/lan/hub.rs @@ -132,6 +132,9 @@ pub struct Hub { /// The `player_movement_check` and `elytra_movement_check` game rules, /// set by the game before each tick. pub movement_checks: (bool, bool), + /// An integrated server's owner (`MinecraftServer.isSingleplayerOwner`), + /// whose moves are never checked. + pub singleplayer_owner: Option, /// Who rides what, set by the game before each tick. pub riding: super::entity::Riding, last_clock: i64, @@ -265,6 +268,7 @@ impl Hub { sync, ticks: 0, movement_checks: (true, true), + singleplayer_owner: None, riding: Default::default(), last_clock: i64::MIN, last_rate: 0.0, @@ -1893,6 +1897,7 @@ impl Hub { ) { let (frozen, (check, elytra_check)) = (self.ticking.1, self.movement_checks); let g = &mut self.guests[i]; + let owner = self.singleplayer_owner == Some(g.uuid); let to = [ to[0].clamp(-3.0E7, 3.0E7), to[1].clamp(-2.0E7, 2.0E7), @@ -1916,9 +1921,10 @@ impl Hub { if packets > 5 { packets = 1; } - // shouldCheckPlayerMovement. The server holds no velocity for a - // guest (getDeltaMovement), so nothing is expected. - if check && (!g.fall_flying || elytra_check) { + // shouldCheckPlayerMovement (never the single-player owner). + // The server holds no velocity for a guest (getDeltaMovement), + // so nothing is expected. + if !owner && check && (!g.fall_flying || elytra_check) { let limit = if g.fall_flying { 300.0 } else { 100.0 }; if moved > limit * f64::from(packets) { events.push(HostEvent::Warn(format!(