From 3c72bf2d791ff71e0751658f5ffa69dea1865d85 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 22:07:25 +0100 Subject: [PATCH] Fire spear_mobs when a spear stabs several mobs in one use Vanilla's KineticWeapon fires SPEAR_MOBS with the number of living entities stabbed in the use, so stabbing five or more completes the spear advancement. --- crates/horizon-client/src/game/advancements.rs | 14 ++++++++++++++ crates/horizon-client/src/game/spear.rs | 3 +++ 2 files changed, 17 insertions(+) diff --git a/crates/horizon-client/src/game/advancements.rs b/crates/horizon-client/src/game/advancements.rs index 39d4718ca..008311e74 100644 --- a/crates/horizon-client/src/game/advancements.rs +++ b/crates/horizon-client/src/game/advancements.rs @@ -1065,6 +1065,20 @@ impl Game<'_> { }) }); } + /// `SpearMobsTrigger`: the living entities the spear stabbed in this use. + pub(super) fn trigger_spear_mobs(&mut self, stabbed: usize) { + let me = self.player_entity(); + self.trigger("minecraft:spear_mobs", move |c, w| { + let pctx = adv::Entities { + this: Some(&me), + origin: me.position, + tool: None, + block_pos: None, + }; + adv::conditions(&c["player"], &pctx, w) + && c["count"].as_u64().is_none_or(|n| stabbed as u64 >= n) + }); + } /// A trigger with only the player condition (slept_in_bed, started_riding). pub(super) fn trigger_player(&mut self, name: &str) { let me = self.player_entity(); diff --git a/crates/horizon-client/src/game/spear.rs b/crates/horizon-client/src/game/spear.rs index f7d1b5e4e..aec479ed8 100644 --- a/crates/horizon-client/src/game/spear.rs +++ b/crates/horizon-client/src/game/spear.rs @@ -193,6 +193,9 @@ impl Game<'_> { } let who = actor.map_or(OWN, |conn| conn as i32); self.kinetic_hit_feedback(who, &kinetic, [feet.x, feet.y, feet.z]); + // SPEAR_MOBS_TRIGGER: the living entities stabbed in this use. + let stabbed = self.stabbed.keys().filter(|(who, _)| *who == actor).count(); + self.trigger_spear_mobs(stabbed); } }