From 743cc8e0696e4d54fc2a9f2f3564dc89a119287f Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 22 Oct 2026 09:51:21 +0200 Subject: [PATCH] Ender pearls: a server always sends the thrower the teleport ThrownEnderpearl.onHit teleports the owner to oldPosition() (where the pearl started its last tick) with ServerPlayer.teleport, which sends the position packet whatever the distance. A guest's turn sent a teleport only when the player moved more than 0.01 blocks, and the pearl took the hit point: a pearl thrown at one's feet often lands within that, and the dedicated_server harness saw "teleported 0 time(s)" where vanilla's server sends 1 (about one run in four on the desktop). The pearl now moves the player to its previous position and marks the teleport (PlayerMotion.teleported), which the end of the guest's turn sends even when the player stays put. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/creatures.rs | 15 +++++++++++---- crates/horizon-client/src/game/lan_actions.rs | 6 ++++-- crates/horizon-client/src/motion.rs | 5 +++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 78efc708d..d36e0adec 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2107,15 +2107,22 @@ impl Game<'_> { let from = pl.position; self.spawn_mob("minecraft:endermite", [from.x, from.y, from.z], false); } + // To where the pearl started its last tick (oldPosition). + let to = p.previous; if let Some(pl) = self.player.as_mut() { - pl.position = at; + pl.position = to; pl.velocity = Vec3::ZERO; pl.fall_distance = 0.0; + pl.teleported = true; } - self.previous_position = at; + self.previous_position = to; self.hurt_player_by("minecraft:ender_pearl", 5.0); - self.audio - .play("minecraft:entity.player.teleport", Some(atp), 1.0, 1.0); + self.audio.play( + "minecraft:entity.player.teleport", + Some([to.x, to.y, to.z]), + 1.0, + 1.0, + ); } } (ProjectileKind::SmallFireball, hit) => match hit { diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index b261e8ad2..c5cece06c 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -532,12 +532,14 @@ impl Game<'_> { g.health = m.health.health(); g.food = m.health.food.food; g.saturation = m.health.food.saturation; - // A teleport (commands) moves the guest. + // A teleport (commands, a pearl) moves the guest; a pearl's is + // sent even to where they stand (ServerPlayer.teleport). let at = [m.position.x, m.position.y, m.position.z]; m.sprinting = false; + let teleported = std::mem::take(&mut m.teleported); let moved: f64 = (0..3).map(|k| (at[k] - g.position[k]).powi(2)).sum(); g.motion = Some(Box::new(m)); - if moved > 0.0001 || turned { + if moved > 0.0001 || turned || teleported { host.hub.teleport(i, Some(at)); } } diff --git a/crates/horizon-client/src/motion.rs b/crates/horizon-client/src/motion.rs index 7bdaea785..36460f1c1 100644 --- a/crates/horizon-client/src/motion.rs +++ b/crates/horizon-client/src/motion.rs @@ -262,6 +262,10 @@ pub struct PlayerMotion { pub steps: MovementDistances, pub needs_sync: bool, pub sync_position: bool, + /// Moved by an ender pearl (`ServerPlayer.teleport`): a server sends the + /// position packet even when the player lands where they stood. The + /// server takes it at the end of a guest's turn. + pub teleported: bool, pub events: Vec, pub attributes: LiveAttributes i32>>, pub impulse: ImpulseContext, @@ -428,6 +432,7 @@ impl PlayerMotion { }, needs_sync: false, sync_position: false, + teleported: false, events: Vec::new(), attributes, fluids: PlayerFluids::default(),