From 512e003cbd50f13572286ee759a26a33ef0b08dc Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:43:50 +0100 Subject: [PATCH] Wolf armor: check the acting player's UUID and keep the armor's components --- crates/horizon-client/src/entity_nbt.rs | 8 +++++--- crates/horizon-client/src/game/creatures.rs | 11 +++++++---- crates/horizon-client/src/game/lan.rs | 6 +++++- crates/horizon-client/src/game/lan_mobs.rs | 8 ++++++++ crates/horizon-client/src/mobs.rs | 3 +++ crates/horizon-client/src/mobs/drops.rs | 1 + 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/crates/horizon-client/src/entity_nbt.rs b/crates/horizon-client/src/entity_nbt.rs index 18f89d884..8e64652c9 100644 --- a/crates/horizon-client/src/entity_nbt.rs +++ b/crates/horizon-client/src/entity_nbt.rs @@ -551,6 +551,7 @@ pub fn mob_to_nbt(m: &Mob, uuid: [i32; 4], raw: Option<&Tag>) -> Tag { { let mut stack = crate::items::ItemStack::new(id, 1); stack.damage = m.extra.body_damage.max(0) as u32; + stack.extra = m.extra.body_extra.clone(); equipment.insert(slot.into(), crate::save::item_to_nbt(&stack)); continue; } @@ -790,11 +791,12 @@ pub fn mob_from_nbt(tag: &Tag, types: &HashMap>, id: u32) - crate::mobs::tame::set_tame(&mut m, tame); m.health = health; m.extra.sitting = flag(tag, "Sitting"); - m.extra.body_damage = tag + let armor = tag .get("equipment") .and_then(|e| e.get("body")) - .and_then(crate::save::item_from_nbt) - .map_or(0, |s| s.damage as i32); + .and_then(crate::save::item_from_nbt); + m.extra.body_damage = armor.as_ref().map_or(0, |s| s.damage as i32); + m.extra.body_extra = armor.and_then(|s| s.extra); m.extra.color = number(tag.get("CollarColor")).map_or(crate::mobs::tame::RED, |c| (c as u8) & 15); if let Some(Tag::String(v)) = tag.get("variant") { diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index a72d53c6b..7f470252c 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -2559,10 +2559,11 @@ impl Game<'_> { .items() .get(&item) .is_some_and(|i| i.max_damage > 0); - let me = self.level.player_uuid.or(Some([0, 0, 0, 1])); + let me = self.acting_owner(); let sneaking = self.keys.contains(&winit::keyboard::KeyCode::ShiftLeft) || self.keys.contains(&winit::keyboard::KeyCode::ShiftRight); let held_damage = held.as_ref().map_or(0, |h| h.damage as i32); + let held_extra = held.as_ref().and_then(|h| h.extra.clone()); let m = &mut self.mobs[index]; if !m.alive() { return Ok(false); @@ -2653,6 +2654,7 @@ impl Game<'_> { { let mut stack = ItemStack::new("minecraft:wolf_armor", 1); stack.damage = m.extra.body_damage.max(0) as u32; + stack.extra = m.extra.body_extra.take(); armor_drop = Some(stack); m.extra.head = None; m.extra.body_damage = 0; @@ -2682,6 +2684,7 @@ impl Game<'_> { { m.extra.head = Some(item.as_str().into()); m.extra.body_damage = held_damage; + m.extra.body_extra = held_extra; consume = true; eat = Some(("item.armor.equip_wolf", 1.0, 1.0)); } @@ -2745,7 +2748,7 @@ impl Game<'_> { let tamed = m.random.next_int_bound(3).unwrap_or(1) == 0; if tamed { horizon_client::mobs::tame::set_tame(m, true); - m.extra.owner = self.level.player_uuid.or(Some([0, 0, 0, 1])); + m.extra.owner = me; m.persistent = true; m.nav_stop(); m.ai.target = None; @@ -2821,7 +2824,7 @@ impl Game<'_> { let tamed = m.random.next_int_bound(3).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 = me; m.extra.sitting = true; } eat = eating_sound(m, &mut self.world.random); @@ -2877,7 +2880,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 = me; } let kind = if tamed { "heart" } else { "smoke" }; // TamableAnimal.spawnTamingParticles (entity event 7 or 6). diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index 7897b5c57..2000a0db5 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -385,7 +385,11 @@ fn mob_equipment( } else { 0 }, - extra: None, + extra: if slot == 5 && m.species() == horizon_client::mobs::Species::Wolf { + e.body_extra.clone() + } else { + None + }, }; out.push((slot, hub.stack(&Some(stack)))); } diff --git a/crates/horizon-client/src/game/lan_mobs.rs b/crates/horizon-client/src/game/lan_mobs.rs index 4f53cec60..d1f0e16cd 100644 --- a/crates/horizon-client/src/game/lan_mobs.rs +++ b/crates/horizon-client/src/game/lan_mobs.rs @@ -328,6 +328,14 @@ impl Game<'_> { .collect() } /// The UUID of the player acting: the guest `as_guest` runs, else the host. + /// The owner a wolf, cat or parrot gets when the acting player tames it + /// (a host with no UUID yet owns under `[0, 0, 0, 1]`). + pub(super) fn acting_owner(&self) -> Option<[i32; 4]> { + self.lan_acting_uuid + .map(horizon_client::lan::playerdata::uuid_ints) + .or(self.level.player_uuid) + .or(Some([0, 0, 0, 1])) + } pub(super) fn acting_uuid(&self) -> [i32; 4] { self.lan_acting_uuid .map(horizon_client::lan::playerdata::uuid_ints) diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index f9a53f0f2..81f2b90f0 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -663,6 +663,8 @@ pub struct Extra { pub saddled: bool, /// The durability a wolf's body armor (`extra.head`) has lost. pub body_damage: i32, + /// The components (dye, name...) of that armor stack. + pub body_extra: Option>, /// The saddle's components (name, enchantments...) when it is not a bare /// one; `saddled` stays the gameplay flag. pub saddle_stack: Option, @@ -1858,6 +1860,7 @@ impl Mob { if after >= WOLF_ARMOR_DURABILITY { self.extra.head = None; self.extra.body_damage = 0; + self.extra.body_extra = None; self.outbox .push(MobEvent::Sound("item.wolf_armor.break", at, 1.0, 1.0)); } else { diff --git a/crates/horizon-client/src/mobs/drops.rs b/crates/horizon-client/src/mobs/drops.rs index 28ba2a0cd..be3a06174 100644 --- a/crates/horizon-client/src/mobs/drops.rs +++ b/crates/horizon-client/src/mobs/drops.rs @@ -286,6 +286,7 @@ pub fn clear_slot(m: &mut Mob, slot: &str) { "body" if body => { m.extra.head = None; m.extra.body_damage = 0; + m.extra.body_extra = None; return; } "saddle" => {