[PR #2682] [MERGED] Implement the spear's right-click charge #4535

Closed
opened 2026-11-03 04:17:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2682
Author: @kacpherek
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

Base: main ← Head: feat/spear-use


📝 Commits (2)

  • e2a48d1 Implement the spear's use action: charge, stab, knockback, dismount
  • 6d4b5c3 Merge main into feat/spear-use

📊 Changes

20 files changed (+878 additions, -16 deletions)

View changed files

📝 crates/horizon-client/src/first_person.rs (+17 -0)
📝 crates/horizon-client/src/game.rs (+34 -0)
📝 crates/horizon-client/src/game/commands/world_cmds.rs (+2 -1)
📝 crates/horizon-client/src/game/creatures.rs (+1 -0)
📝 crates/horizon-client/src/game/dispense_fixture.rs (+1 -0)
📝 crates/horizon-client/src/game/enchant_effects.rs (+3 -3)
📝 crates/horizon-client/src/game/item_draw.rs (+3 -0)
📝 crates/horizon-client/src/game/lan.rs (+20 -1)
📝 crates/horizon-client/src/game/lan_actions.rs (+6 -0)
📝 crates/horizon-client/src/game/mace.rs (+18 -6)
📝 crates/horizon-client/src/game/remote.rs (+10 -2)
➕ crates/horizon-client/src/game/spear.rs (+330 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/mobs.rs (+10 -0)
📝 crates/horizon-client/src/mobs/anim.rs (+48 -1)
📝 crates/horizon-client/src/mobs/creaking.rs (+1 -0)
📝 crates/horizon-client/src/mobs/guardian.rs (+4 -1)
📝 crates/horizon-client/src/mobs/render.rs (+17 -1)
📝 crates/horizon-client/src/mobs/sulfur_cube.rs (+1 -0)
➕ crates/horizon-client/src/spear.rs (+351 -0)

📄 Description

What and why

Right-clicking with a spear did nothing. It now charges the spear like vanilla 26.3: hold the use button and, after the spear's delay, every mob in front of you is stabbed according to your speed.

  • Damage is 1 + floor(relative speed * damage multiplier), where the relative speed is your speed along your view minus the target's (a mob's root vehicle counts). It needs a relative speed of 4.6 blocks/s, and stops after the damage window of the spear's material.
  • Knockback (needs your own speed of 5.1 blocks/s) and dismounting a rider (needs 9 to 14 blocks/s depending on the material) have their own windows, shorter than the damage one.
  • Each target can be stabbed once every 10 ticks, the reach is 2 to 4.5 blocks (6.5 in creative) plus your own forward movement, and the stab passes through blocks without collision such as tall grass.
  • Sharpness, Smite, Bane and Knockback apply, the spear wears by one per stab and counts as "used", and the kill is a spear damage type (death.attack.spear).
  • The use sound plays when the charge starts, the hit sound when a stab lands (entity event 2), and the spear pulls back in your hand for a moment on a hit.
  • Animations: the first-person spear charge (raise, sway, lower, hit feedback), the third-person arm pose of any held spear (at rest and charging) and the spear's own pose in the hand while it charges.

Single player on the server thread, --in-frame and LAN guests all go through the same server code. A guest's speed comes from the moves their client sent.

Not done, to keep this small: the left-click jab (PiercingWeapon, the Lunge enchantment and its sounds), stabbing other players, boats, minecarts, armor stands and the dragon, the spear_mobs advancement trigger, the other players' hit feedback in third person, and spear poses for mobs. Fixes #2624.

Vanilla reference

Item.use, Item.getUseAnimation and getUseDuration (a kinetic weapon is used for 72000 ticks), Item.Properties.spear (the numbers per material), ItemStack.onUseTick, KineticWeapon.damageEntities and Condition.test, LivingEntity.startUsingItem / stopUsingItem (recentKineticEnemies), LivingEntity.stabAttack, Player.stabAttack, LivingEntity.onKineticHit (entity event 2), ProjectileUtil.getHitEntitiesAlong, AttackRange, ServerPlayer.getKnownMovement, SpearAnimations, FirstPersonHandsAndItemsRenderer (SPEAR), HumanoidModel.ArmPose.SPEAR, AvatarRenderer.getArmPose and ItemInHandLayer.

Self-check

  • cargo clippy -p horizon-client --all-targets -- -D warnings passes and the changed files are rustfmt-clean.
  • Not run in game: the animations and the stab timing are written from the vanilla code but have not been seen on screen, and the single player, in-frame and LAN paths have not been exercised.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2682 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/spear-use` --- ### 📝 Commits (2) - [`e2a48d1`](https://github.com/horizon-rust/horizon/commit/e2a48d1c36b04f0349326dee852bad403a88d92b) Implement the spear's use action: charge, stab, knockback, dismount - [`6d4b5c3`](https://github.com/horizon-rust/horizon/commit/6d4b5c345f481deac3cd21b2180f27afc22ccf07) Merge main into feat/spear-use ### 📊 Changes **20 files changed** (+878 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/first_person.rs` (+17 -0) 📝 `crates/horizon-client/src/game.rs` (+34 -0) 📝 `crates/horizon-client/src/game/commands/world_cmds.rs` (+2 -1) 📝 `crates/horizon-client/src/game/creatures.rs` (+1 -0) 📝 `crates/horizon-client/src/game/dispense_fixture.rs` (+1 -0) 📝 `crates/horizon-client/src/game/enchant_effects.rs` (+3 -3) 📝 `crates/horizon-client/src/game/item_draw.rs` (+3 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+20 -1) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+6 -0) 📝 `crates/horizon-client/src/game/mace.rs` (+18 -6) 📝 `crates/horizon-client/src/game/remote.rs` (+10 -2) ➕ `crates/horizon-client/src/game/spear.rs` (+330 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs.rs` (+10 -0) 📝 `crates/horizon-client/src/mobs/anim.rs` (+48 -1) 📝 `crates/horizon-client/src/mobs/creaking.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/guardian.rs` (+4 -1) 📝 `crates/horizon-client/src/mobs/render.rs` (+17 -1) 📝 `crates/horizon-client/src/mobs/sulfur_cube.rs` (+1 -0) ➕ `crates/horizon-client/src/spear.rs` (+351 -0) </details> ### 📄 Description ## What and why Right-clicking with a spear did nothing. It now charges the spear like vanilla 26.3: hold the use button and, after the spear's delay, every mob in front of you is stabbed according to your speed. - Damage is `1 + floor(relative speed * damage multiplier)`, where the relative speed is your speed along your view minus the target's (a mob's root vehicle counts). It needs a relative speed of 4.6 blocks/s, and stops after the damage window of the spear's material. - Knockback (needs your own speed of 5.1 blocks/s) and dismounting a rider (needs 9 to 14 blocks/s depending on the material) have their own windows, shorter than the damage one. - Each target can be stabbed once every 10 ticks, the reach is 2 to 4.5 blocks (6.5 in creative) plus your own forward movement, and the stab passes through blocks without collision such as tall grass. - Sharpness, Smite, Bane and Knockback apply, the spear wears by one per stab and counts as "used", and the kill is a `spear` damage type (`death.attack.spear`). - The use sound plays when the charge starts, the hit sound when a stab lands (entity event 2), and the spear pulls back in your hand for a moment on a hit. - Animations: the first-person spear charge (raise, sway, lower, hit feedback), the third-person arm pose of any held spear (at rest and charging) and the spear's own pose in the hand while it charges. Single player on the server thread, `--in-frame` and LAN guests all go through the same server code. A guest's speed comes from the moves their client sent. Not done, to keep this small: the left-click jab (`PiercingWeapon`, the Lunge enchantment and its sounds), stabbing other players, boats, minecarts, armor stands and the dragon, the `spear_mobs` advancement trigger, the other players' hit feedback in third person, and spear poses for mobs. Fixes #2624. ## Vanilla reference `Item.use`, `Item.getUseAnimation` and `getUseDuration` (a kinetic weapon is used for 72000 ticks), `Item.Properties.spear` (the numbers per material), `ItemStack.onUseTick`, `KineticWeapon.damageEntities` and `Condition.test`, `LivingEntity.startUsingItem` / `stopUsingItem` (`recentKineticEnemies`), `LivingEntity.stabAttack`, `Player.stabAttack`, `LivingEntity.onKineticHit` (entity event 2), `ProjectileUtil.getHitEntitiesAlong`, `AttackRange`, `ServerPlayer.getKnownMovement`, `SpearAnimations`, `FirstPersonHandsAndItemsRenderer` (SPEAR), `HumanoidModel.ArmPose.SPEAR`, `AvatarRenderer.getArmPose` and `ItemInHandLayer`. ## Self-check - `cargo clippy -p horizon-client --all-targets -- -D warnings` passes and the changed files are rustfmt-clean. - Not run in game: the animations and the stab timing are written from the vanilla code but have not been seen on screen, and the single player, in-frame and LAN paths have not been exercised. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:17:53 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4535
No description provided.