From be714b38bbc3e27aa2d5aa1b3f0244b490c7d16b Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:38:16 +0100 Subject: [PATCH] Only let a tame parrot land on its saved owner --- crates/horizon-client/src/game/shoulders.rs | 4 ++++ crates/horizon-client/src/mobs/tame.rs | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/game/shoulders.rs b/crates/horizon-client/src/game/shoulders.rs index 602c5a5af..7dfc2f355 100644 --- a/crates/horizon-client/src/game/shoulders.rs +++ b/crates/horizon-client/src/game/shoulders.rs @@ -27,6 +27,10 @@ impl Game<'_> { let Some(p) = self.player.as_ref() else { return; }; + // The acting player must be the saved owner (`getOwner`). + if !horizon_client::mobs::tame::owned_by(self.mobs[i].extra.owner, self.acting_uuid()) { + return; + } if self.riding.is_some() || !p.ground.on_ground || p.fluids.was_touching_water diff --git a/crates/horizon-client/src/mobs/tame.rs b/crates/horizon-client/src/mobs/tame.rs index 82d808b7f..3002ce1f7 100644 --- a/crates/horizon-client/src/mobs/tame.rs +++ b/crates/horizon-client/src/mobs/tame.rs @@ -123,13 +123,15 @@ impl Goal for LandOnOwnersShoulder { } fn can_use(&mut self, m: &mut Mob, cx: &mut Cx) -> bool { // ShoulderRidingEntity.canSitOnShoulder: rideCooldownCounter > 100. - owner(m, cx.w).is_some_and(|(_, _, spectator)| !spectator) + is_owner(m, cx.w) + && owner(m, cx.w).is_some_and(|(_, _, spectator)| !spectator) && !m.extra.sitting && m.age > 100 } fn tick(&mut self, m: &mut Mob, cx: &mut Cx) { if !m.extra.sitting && m.extra.leash.is_none() + && is_owner(m, cx.w) && cx .w .player @@ -172,6 +174,18 @@ fn owner(m: &Mob, w: &MobWorld) -> Option<(Vec3, f64, bool)> { let p = w.player.as_ref()?; Some((p.position, p.eye[1], p.spectator)) } +/// Whether the player the mob sees is the one saved as its owner (with +/// guests on, that player is whoever stands nearest). +fn is_owner(m: &Mob, w: &MobWorld) -> bool { + w.player + .as_ref() + .is_some_and(|p| owned_by(m.extra.owner, p.uuid)) +} +/// Whether `uuid` is the saved owner. A host with no UUID yet owns what it +/// tamed under the placeholder `[0, 0, 0, 1]`. +pub fn owned_by(owner: Option<[i32; 4]>, uuid: [i32; 4]) -> bool { + owner.is_some_and(|o| o == uuid || (o == [0, 0, 0, 1] && uuid == [0; 4])) +} /// `TamableAnimal.unableToMoveToOwner`. fn unable_to_move_to_owner(m: &Mob, w: &MobWorld) -> bool { m.extra.sitting || w.player.as_ref().is_some_and(|p| p.spectator)