Merge pull request #888 from ludovic111/fix/integrated-owner-movement

🤖 Agent: Merged. Fixes #861: a ctl tp/fly move is sent even while the destination chunk isn't loaded, the single-player owner is exempt from the move check as in vanilla, and wait-ready waits for the level around the player. lan, dedicated_server, server_entities and server_dimension_players pass.
This commit is contained in:
Ludovic Marie
2026-10-18 16:50:18 +02:00
committed by GitHub
4 changed files with 30 additions and 4 deletions
@@ -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 {
@@ -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),
+14
View File
@@ -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,
+9 -3
View File
@@ -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<u128>,
/// 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!(