From 6145077d7e094b19a0940fbf94bd13de10a03a37 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:44:11 +0100 Subject: [PATCH] Make a tame parrot answer only to its owner --- crates/horizon-client/src/game/creatures.rs | 10 ++++++++-- crates/horizon-client/src/game/lan_mobs.rs | 15 ++++++++++++++- crates/horizon-client/src/mobs/tame.rs | 6 +++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 8eb4cc911..1b9a31679 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2565,6 +2565,7 @@ impl Game<'_> { .item_tags .get("minecraft:parrot_poisonous_food") .is_some_and(|t| t.contains(&*item)); + let acting = self.acting_uuid(); let m = &mut self.mobs[index]; if !m.alive() { return Ok(false); @@ -2772,7 +2773,12 @@ impl Game<'_> { } // Parrot.mobInteract: the owner makes a tame parrot on the ground // sit or stand (poisonous food is handled apart). - Species::Parrot if m.extra.tame && m.on_ground && !parrot_poisonous => { + Species::Parrot + if m.extra.tame + && m.extra.owner == Some(acting) + && m.on_ground + && !parrot_poisonous => + { m.extra.sitting = !m.extra.sitting; self.world.modified.insert(( m.position.x.floor() as i32 >> 4, @@ -2841,7 +2847,7 @@ impl Game<'_> { let tamed = m.random.next_int_bound(10).unwrap_or(1) == 0; if tamed { m.extra.tame = true; - m.extra.owner = self.level.player_uuid.or(Some([0, 0, 0, 1])); + m.extra.owner = Some(acting); } let kind = if tamed { "heart" } else { "smoke" }; // TamableAnimal.spawnTamingParticles (entity event 7 or 6). diff --git a/crates/horizon-client/src/game/lan_mobs.rs b/crates/horizon-client/src/game/lan_mobs.rs index 4f53cec60..39bbd9794 100644 --- a/crates/horizon-client/src/game/lan_mobs.rs +++ b/crates/horizon-client/src/game/lan_mobs.rs @@ -5,7 +5,7 @@ //! (hits, pushes, fire, its projectiles) runs with that guest swapped in. use super::{Game, lan::LanHost}; use horizon_client::{ - mobs::{Mob, MobEvent, PlayerView, Who}, + mobs::{Mob, MobEvent, PlayerView, Species, Who}, projectiles::{Hit, Projectile}, }; use horizon_core::geometry::{Aabb, Vec3}; @@ -26,6 +26,19 @@ pub(super) fn player_for( guests: &GuestViews, bound: Option, ) -> Option { + // A tame parrot sees its owner (`TamableAnimal.getOwner`), while they + // are in play, whoever is nearer. + if m.species() == Species::Parrot + && m.extra.tame + && let Some(owner) = m.extra.owner + { + if host.is_some_and(|v| v.alive && v.uuid == owner) { + return None; + } + if let Some((conn, _)) = guests.iter().find(|(_, v)| v.alive && v.uuid == owner) { + return Some(*conn); + } + } let targeting = m.ai.target == Some(Who::Player) || m.ai.last_hurt_by == Some(Who::Player) && m.age as i32 - m.ai.last_hurt_by_time <= 100; choose(m.position, targeting, host, guests, bound) diff --git a/crates/horizon-client/src/mobs/tame.rs b/crates/horizon-client/src/mobs/tame.rs index 0043ff9ef..d757db0fe 100644 --- a/crates/horizon-client/src/mobs/tame.rs +++ b/crates/horizon-client/src/mobs/tame.rs @@ -135,12 +135,16 @@ pub fn set_tame(m: &mut Mob, tame: bool) { m.attrs.max_health = 8.0; } } -/// The owner (the local player) when tame. +/// The owner (the local player) when tame. A parrot's owner is the player +/// its saved UUID names (`TamableAnimal.getOwner`), not whoever is nearest. fn owner(m: &Mob, w: &MobWorld) -> Option<(Vec3, f64, bool)> { if !m.extra.tame { return None; } let p = w.player.as_ref()?; + if m.species() == Species::Parrot && m.extra.owner != Some(p.uuid) { + return None; + } Some((p.position, p.eye[1], p.spectator)) } /// `TamableAnimal.unableToMoveToOwner`.