From 9aabeb39eee0dfe14a733f150d94703256576a43 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:18:50 +0100 Subject: [PATCH 1/2] Make /tp facing look from the feet, or the eyes under anchored eyes --- crates/horizon-client/src/game/commands.rs | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/crates/horizon-client/src/game/commands.rs b/crates/horizon-client/src/game/commands.rs index 8f934ad8a..d760397f4 100644 --- a/crates/horizon-client/src/game/commands.rs +++ b/crates/horizon-client/src/game/commands.rs @@ -1312,7 +1312,7 @@ impl Game<'_> { { return Err(err("commands.teleport.invalidPosition", &[])); } - let mut rotation = match ctx.get("rotation") { + let rotation = match ctx.get("rotation") { Some(Arg::Coords(c)) => Some(c.rotation(self.source_rotation())), _ => None, }; @@ -1327,21 +1327,31 @@ impl Game<'_> { (Some(f), _) => Some(f), (None, Some(_)) => { let e = self.entities(ctx, "facingEntity", false)?[0]; + // EntityAnchorArgument.Anchor.apply: the feet, or the eyes. let eyes = matches!(ctx.get("facingAnchor"), Some(Arg::Anchor(true))); + let eye_height = if eyes { self.target_eye_height(e) } else { 0.0 }; self.target_position(e) - .map(|p| [p[0], p[1] + if eyes { 1.62 } else { 0.0 }, p[2]]) + .map(|p| [p[0], p[1] + eye_height, p[2]]) } _ => None, }; - if let Some(f) = facing { - let eye = pos[1] + 1.62; + // Entity.lookAt: from the source's anchor (the feet, unless `anchored + // eyes`) on the teleported entity, so the eyes depend on the target. + let anchored_eyes = self.command_source.is_some_and(|s| s.eyes); + let look_at = |this: &Self, t: Target| { + let f = facing?; + let eye = if anchored_eyes { + pos[1] + this.target_eye_height(t) + } else { + pos[1] + }; let (dx, dy, dz) = (f[0] - pos[0], f[1] - eye, f[2] - pos[2]); let horizontal = (dx * dx + dz * dz).sqrt(); - rotation = Some([ + Some([ ((dz.atan2(dx).to_degrees()) - 90.0) as f32, (-(dy.atan2(horizontal).to_degrees())) as f32, - ]); - } + ]) + }; // A server's player in another level than the source's (`execute // in`, the console's Overworld) moves there (ServerPlayer.teleport // into another level), after the command. @@ -1351,6 +1361,7 @@ impl Game<'_> { None => self.dim, }; for &t in &targets { + let rotation = look_at(self, t).or(rotation); if self.teleport_across(t, source_level, pos, rotation) { continue; } From fbdd04d8172a884dd281cdf8897a12744eff2976 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 19:58:03 +0100 Subject: [PATCH 2/2] Use armor stand, boat, cart and item eye heights for facing entity eyes --- crates/horizon-client/src/entities.rs | 11 +++++++++++ crates/horizon-client/src/game/commands/execute.rs | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/crates/horizon-client/src/entities.rs b/crates/horizon-client/src/entities.rs index 69e053411..3a23a6c32 100644 --- a/crates/horizon-client/src/entities.rs +++ b/crates/horizon-client/src/entities.rs @@ -713,6 +713,17 @@ pub struct ArmorStand { } impl ArmorStand { pub const SLOTS: [&'static str; 6] = ["mainhand", "offhand", "feet", "legs", "chest", "head"]; + /// The eye height of `getDimensionsMarker`: none for a marker, halved + /// (with `BABY_DIMENSIONS`' 0.9875) when small. + pub fn eye_height(&self) -> f64 { + if self.marker { + 0.0 + } else if self.small { + f64::from(0.9875f32) + } else { + f64::from(1.7775f32) + } + } pub fn new(id: u32, position: Vec3, yaw: f32) -> Self { Self { fire_ticks: 0, diff --git a/crates/horizon-client/src/game/commands/execute.rs b/crates/horizon-client/src/game/commands/execute.rs index 3f7e4c2a0..cda51eabb 100644 --- a/crates/horizon-client/src/game/commands/execute.rs +++ b/crates/horizon-client/src/game/commands/execute.rs @@ -145,6 +145,18 @@ impl Game<'_> { .iter() .find(|m| m.id == id) .map_or(0.0, |m| m.eye_y() - m.position.y), + Target::Stand(id) => self + .armor_stands + .iter() + .find(|a| a.id == id) + .map_or(0.0, |a| a.eye_height()), + // EntityType eyeHeight: boats 0.5625, items 0.2125; the rest keep + // the default of 0.85 of the height (minecarts 0.7, experience + // orbs and paintings 0.5), item frames 0. + Target::Boat(_) => f64::from(0.5625f32), + Target::Item(_) => f64::from(0.2125f32), + Target::Cart(_) => f64::from(0.7f32 * 0.85), + Target::Orb(_) | Target::Painting(_) => f64::from(0.5f32 * 0.85), _ => 0.0, } }