From 348054d26e848f42f9dec6cf0d38586e225c181d Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 22:52:16 +0100 Subject: [PATCH 1/2] Draw F3+B hitboxes for every entity --- crates/horizon-client/src/game/debug_keys.rs | 167 ++++++++++++++++++- crates/horizon-client/src/game/fireworks.rs | 2 +- crates/horizon-client/src/game/fishing.rs | 8 +- crates/horizon-client/src/game/trident.rs | 2 +- crates/horizon-client/src/gizmos.rs | 13 ++ 5 files changed, 184 insertions(+), 8 deletions(-) diff --git a/crates/horizon-client/src/game/debug_keys.rs b/crates/horizon-client/src/game/debug_keys.rs index 16e7fc6e7..1428ae9b2 100644 --- a/crates/horizon-client/src/game/debug_keys.rs +++ b/crates/horizon-client/src/game/debug_keys.rs @@ -13,7 +13,7 @@ use horizon_client::{ save::VERSION_NAME, text::Text, }; -use horizon_core::geometry::Axis; +use horizon_core::geometry::{Axis, Vec3}; use winit::keyboard::KeyCode; /// `ChatFormatting.YELLOW` and `RED`. @@ -766,7 +766,8 @@ impl Game<'_> { } let lerp = |a: f64, b: f64| a + f64::from(alpha) * (b - a); let lerpf = |a: f32, b: f32| a + alpha * (b - a); - for m in &self.mobs { + let guests = self.lan.iter().flat_map(|h| h.models.values()); + for m in self.mobs.iter().chain(guests) { if m.removed || m.invisible || m.has_effect("minecraft:invisibility") { continue; } @@ -796,6 +797,159 @@ impl Game<'_> { // EntityType.ITEM: 0.25 by 0.25, eyes at 0.2125. g.hitbox(pos, (0.25, 0.25), 0.2125, false, (0.0, 0.0)); } + // The other entities (EntityTypes sizes; eyes at 0.85 of the height + // unless the type sets one). `at` is the interpolated position. + let at = |previous: Vec3, now: Vec3| { + [ + lerp(previous.x, now.x), + lerp(previous.y, now.y), + lerp(previous.z, now.z), + ] + }; + for p in &self.paintings { + let (min, max) = p.bounds(); + let centre = std::array::from_fn(|i| (min[i] + max[i]) / 2.0); + g.entity_box(min, max, centre, 0.425, false, step_view(p.step())); + } + for f in self.item_frames.iter().filter(|f| !f.invisible) { + let (min, max) = f.bounds(); + let centre = std::array::from_fn(|i| (min[i] + max[i]) / 2.0); + g.entity_box(min, max, centre, 0.0, false, step_view(f.step())); + } + for c in &self.cushions { + let (min, max) = c.bounds(); + let p = c.position; + g.entity_box(min, max, [p.x, p.y, p.z], 0.2125, false, (0.0, c.yaw)); + } + for a in self.armor_stands.iter().filter(|a| !a.invisible) { + // ArmorStand.getDimensions: a marker has none, a small one is + // half scale with its eyes at 0.9875. + let (size, eye) = match (a.marker, a.small) { + (true, _) => ((0.0, 0.0), 0.0), + (_, true) => ((0.25, 0.9875), 0.9875), + _ => ((0.5, 1.975), 1.7775), + }; + let p = a.position; + g.hitbox([p.x, p.y, p.z], size, eye, true, (0.0, a.yaw)); + } + for b in &self.boats { + let h = super::boats::HEIGHT as f32; + g.hitbox( + at(b.previous, b.position), + (super::boats::WIDTH as f32, h), + h, + false, + (0.0, b.yaw), + ); + } + for c in &self.carts { + let (w, h) = ( + super::minecarts::WIDTH as f32, + super::minecarts::HEIGHT as f32, + ); + g.hitbox( + at(c.previous, c.position), + (w, h), + h * 0.85, + false, + (0.0, c.yaw), + ); + } + for o in &self.orbs { + g.hitbox( + at(o.previous, o.position), + (0.5, 0.5), + 0.425, + false, + (0.0, 0.0), + ); + } + for f in &self.falling { + g.hitbox( + at(f.previous, f.position), + (0.98, 0.98), + 0.833, + false, + (0.0, 0.0), + ); + } + for t in &self.tnts { + g.hitbox( + at(t.previous, t.position), + (0.98, 0.98), + 0.15, + false, + (0.0, 0.0), + ); + } + for c in &self.crystals { + let p = c.position; + g.hitbox([p.x, p.y, p.z], (2.0, 2.0), 1.7, false, (0.0, 0.0)); + } + for p in &self.creatures.projectiles { + use horizon_client::projectiles::ProjectileKind as K; + let (size, eye) = match p.kind { + K::Arrow { .. } => (0.5, 0.13), + K::Snowball | K::Egg | K::EnderPearl | K::LlamaSpit | K::Potion { .. } => { + (0.25, 0.2125) + } + K::SmallFireball | K::ShulkerBullet { .. } | K::WitherSkull { .. } => { + (0.3125, 0.265_625) + } + K::WindCharge | K::BreezeWindCharge => (0.3125, 0.0), + K::LargeFireball { .. } => (1.0, 0.85), + }; + g.hitbox( + at(p.previous, p.position), + (size, size), + eye, + false, + (p.pitch, p.yaw), + ); + } + for t in &self.tridents { + g.hitbox( + at(t.previous, t.position), + (0.5, 0.5), + 0.13, + false, + (t.pitch, t.yaw), + ); + } + for r in &self.rockets { + // Projectile.updateRotation: the look follows the motion. + let v = r.velocity; + let yaw = v.x.atan2(v.z).to_degrees() as f32; + let pitch = v.y.atan2(v.x.hypot(v.z)).to_degrees() as f32; + g.hitbox( + at(r.previous, r.position), + (0.25, 0.25), + 0.2125, + false, + (pitch, yaw), + ); + } + for h in self + .hook + .iter() + .map(|h| (h.previous, h.position)) + .chain(self.remote_hooks.iter().map(|h| (h.previous, h.position))) + { + g.hitbox(at(h.0, h.1), (0.25, 0.25), 0.2125, false, (0.0, 0.0)); + } + for b in &self.bolts { + g.hitbox(b.at, (0.0, 0.0), 0.0, false, (0.0, 0.0)); + } + // The dragon: 16 by 8, a living entity; its parts follow. + if let Some(d) = &self.dragon { + g.hitbox( + at(d.previous, d.position), + (16.0, 8.0), + 6.8, + true, + (0.0, d.yaw), + ); + } // The dragon's parts. for (id, b) in self.special_targets() { if (super::dragon::SPECIAL..super::dragon::SPECIAL + 8).contains(&id) { @@ -828,3 +982,12 @@ impl Game<'_> { g } } + +/// The (x, y) rotations whose view vector is the step of a direction. +fn step_view(step: [i32; 3]) -> (f32, f32) { + let [x, y, z] = step.map(f64::from); + ( + (-y).asin().to_degrees() as f32, + (-x.atan2(z)).to_degrees() as f32, + ) +} diff --git a/crates/horizon-client/src/game/fireworks.rs b/crates/horizon-client/src/game/fireworks.rs index 38fd74ed8..5aa540fcd 100644 --- a/crates/horizon-client/src/game/fireworks.rs +++ b/crates/horizon-client/src/game/fireworks.rs @@ -23,7 +23,7 @@ pub(super) struct Rocket { /// The entity id a server tracks it by (0 until it is tracked). pub id: u32, pub(super) position: Vec3, - previous: Vec3, + pub(super) previous: Vec3, pub(super) velocity: Vec3, life: i32, lifetime: i32, diff --git a/crates/horizon-client/src/game/fishing.rs b/crates/horizon-client/src/game/fishing.rs index 39f9e5ffe..b308b9f1d 100644 --- a/crates/horizon-client/src/game/fishing.rs +++ b/crates/horizon-client/src/game/fishing.rs @@ -30,8 +30,8 @@ enum State { pub(super) struct Hook { /// Its entity id, which a server's players track it under. id: u32, - position: Vec3, - previous: Vec3, + pub(super) position: Vec3, + pub(super) previous: Vec3, velocity: Vec3, state: State, life: i32, @@ -770,8 +770,8 @@ impl Game<'_> { pub(super) struct RemoteHook { id: u32, owner: u32, - position: Vec3, - previous: Vec3, + pub(super) position: Vec3, + pub(super) previous: Vec3, } impl Hook { diff --git a/crates/horizon-client/src/game/trident.rs b/crates/horizon-client/src/game/trident.rs index d934e85aa..af3dc418b 100644 --- a/crates/horizon-client/src/game/trident.rs +++ b/crates/horizon-client/src/game/trident.rs @@ -21,7 +21,7 @@ pub(super) struct ThrownTrident { pub id: u32, pub(super) stack: ItemStack, pub(super) position: Vec3, - previous: Vec3, + pub(super) previous: Vec3, pub(super) velocity: Vec3, pub(super) yaw: f32, pub(super) pitch: f32, diff --git a/crates/horizon-client/src/gizmos.rs b/crates/horizon-client/src/gizmos.rs index d4125710e..70e2b87f3 100644 --- a/crates/horizon-client/src/gizmos.rs +++ b/crates/horizon-client/src/gizmos.rs @@ -204,6 +204,19 @@ impl Gizmos { position[1] + f64::from(size.1), position[2] + half, ]; + self.entity_box(min, max, position, eye_height, living, view); + } + /// The same for an entity whose box is not centred on its position + /// (a painting or an item frame): `min` and `max` are the box. + pub fn entity_box( + &mut self, + min: [f64; 3], + max: [f64; 3], + position: [f64; 3], + eye_height: f32, + living: bool, + view: (f32, f32), + ) { self.cuboid(min, max, WHITE, STROKE_WIDTH); if living { let eye = min[1] + f64::from(eye_height); From d53114fa82f8af75b60fca4c9cf5a996ba0e97fc Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 27 Oct 2026 06:58:31 +0100 Subject: [PATCH 2/2] Size a drowned's thrown trident in F3+B Main's ProjectileKind::Trident (a mob's trident) is the trident's 0.5 box with its 0.13 eye height, as the player's tridents below. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/debug_keys.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/horizon-client/src/game/debug_keys.rs b/crates/horizon-client/src/game/debug_keys.rs index 1428ae9b2..dc79bf8c1 100644 --- a/crates/horizon-client/src/game/debug_keys.rs +++ b/crates/horizon-client/src/game/debug_keys.rs @@ -889,7 +889,7 @@ impl Game<'_> { for p in &self.creatures.projectiles { use horizon_client::projectiles::ProjectileKind as K; let (size, eye) = match p.kind { - K::Arrow { .. } => (0.5, 0.13), + K::Arrow { .. } | K::Trident => (0.5, 0.13), K::Snowball | K::Egg | K::EnderPearl | K::LlamaSpit | K::Potion { .. } => { (0.25, 0.2125) }