From 6489cdf8295b4db51b94bfb7c12e37faa3c52d60 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 22:08:12 +0100 Subject: [PATCH] Fire player_interacted_with_entity for leashing, feeding and repairing Vanilla's PlayerInteractTrigger fires after a successful item use on an entity: leashing, feeding a baby sniffer, repairing wolf armour. Item predicates now check the damage component, and guests' interactions fire it too. --- crates/horizon-client/src/advancements.rs | 5 +++++ crates/horizon-client/src/game/advancements.rs | 3 --- crates/horizon-client/src/game/creatures.rs | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/advancements.rs b/crates/horizon-client/src/advancements.rs index 0846132df..cffaed046 100644 --- a/crates/horizon-client/src/advancements.rs +++ b/crates/horizon-client/src/advancements.rs @@ -540,6 +540,11 @@ pub fn item(v: &Value, it: &ItemView, w: &dyn World) -> bool { { return false; } + if let Some(d) = comps["minecraft:damage"].as_u64() + && u64::from(it.damage) != d + { + return false; + } let preds = &v["predicates"]; if let Some(list) = preds["minecraft:enchantments"].as_array() { for e in list { diff --git a/crates/horizon-client/src/game/advancements.rs b/crates/horizon-client/src/game/advancements.rs index c2130145e..fc64009f2 100644 --- a/crates/horizon-client/src/game/advancements.rs +++ b/crates/horizon-client/src/game/advancements.rs @@ -877,9 +877,6 @@ impl Game<'_> { stack: &ItemStack, target: &EntityView, ) { - if self.lan_acting.is_some() { - return; - } let me = self.player_entity(); let it = item_view(stack); self.trigger(name, |c, w| adv::item_entity(c, &me, target, &it, w)); diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index 74bc46743..940a5a43b 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -3254,7 +3254,16 @@ impl Game<'_> { } { let item = self.held().map(|h| h.item.to_string()).unwrap_or_default(); + let used = self.held().cloned(); if self.interact_leash(index, &item) { + if let Some(stack) = &used { + let target = self.mob_entity(&self.mobs[index]); + self.trigger_item_entity( + "minecraft:player_interacted_with_entity", + stack, + &target, + ); + } self.swing_arm(); return Ok(true); } @@ -3828,6 +3837,11 @@ impl Game<'_> { if !handled { return Ok(false); } + // PlayerInteractTrigger: the item used on the mob, once the interaction took. + if let Some(stack) = &held { + let target = self.mob_entity(&self.mobs[index]); + self.trigger_item_entity("minecraft:player_interacted_with_entity", stack, &target); + } // Turtle.ageBoundaryReached: food that finishes a baby's growth. if baby_turtle && !self.mobs[index].is_baby() { self.handle_mob_events(vec![MobEvent::GiftLoot {