[PR #4566] [MERGED] A pillager shows the arrow in its loaded crossbow #5699

Closed
opened 2026-11-03 05:14:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4566
Author: @CocofireHD
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/pillager-crossbow


📝 Commits (1)

  • c1a5052 A pillager shows the arrow in its loaded crossbow

📊 Changes

3 files changed (+102 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/mob_blocks.rs (+7 -1)
📝 crates/horizon-client/src/game/remote.rs (+8 -1)
📝 crates/horizon-client/src/mobs/illager.rs (+87 -0)

📄 Description

🤖 Opened by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally.

Fixes #4521.

What

A pillager that has loaded its crossbow now shows the arrow in it.

Why it happened

Three places dropped the state:

  • The AI never set it. CrossbowItem.setCharged puts the loaded arrow into the stack's charged_projectiles component, and that component is what selects the charged crossbow model. RangedCrossbowAttackGoal in mobs/illager.rs tracked its own Crossbow::Charged state and the arm pose, but the held stack kept whatever it was spawned with.
  • The mob renderer discarded the stack. game/mob_blocks.rs rebuilt every non-local mob's held item as ItemStack::new(item, 1) from the name alone, so a mob's components never reached the item model — a server-sent loaded crossbow drew unloaded too.
  • The equipment packet discarded it as well. game/remote.rs's SetEquipment handler kept only the translated item name for the main hand.

The change

  • mobs/illager.rs: set_crossbow_charged() sets charged_projectiles to one arrow when the goal reaches Charged, and clears it on stop and after the shot; the held stack is created if the mob only had a name.
  • game/mob_blocks.rs: draw mob.extra.main_hand_stack() when there is one, as the local player's branch already did.
  • game/remote.rs: keep the stack the equipment packet sends for the main hand.

Two unit tests cover the component being set and cleared, and that a non-crossbow is left alone.

Evidence

Same seed, same platform, HUD hidden, two pillagers summoned side by side: the left one with a plain crossbow, the right one with components:{"minecraft:charged_projectiles":[{id:"minecraft:arrow"}]} (the game reports the component back for it in both runs).

Before, main: neither crossbow draws an arrow — the component is in the stack but the renderer never sees it.

before: both crossbows empty

After: the right one shows the loaded arrow.

after: the loaded crossbow shows its arrow

cargo test -p horizon-client --lib illager::tests → 16 passed, 0 failed. cargo fmt --all -- --check ✅.

🤖 Generated with Hermes Agent


🔄 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/4566 **Author:** [@CocofireHD](https://github.com/CocofireHD) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/pillager-crossbow` --- ### 📝 Commits (1) - [`c1a5052`](https://github.com/horizon-rust/horizon/commit/c1a5052c439e4b8872eb04d954f5839667d8368c) A pillager shows the arrow in its loaded crossbow ### 📊 Changes **3 files changed** (+102 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/mob_blocks.rs` (+7 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+8 -1) 📝 `crates/horizon-client/src/mobs/illager.rs` (+87 -0) </details> ### 📄 Description > 🤖 Opened by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally. Fixes #4521. ## What A pillager that has loaded its crossbow now shows the arrow in it. ## Why it happened Three places dropped the state: - **The AI never set it.** `CrossbowItem.setCharged` puts the loaded arrow into the stack's `charged_projectiles` component, and that component is what selects the charged crossbow model. `RangedCrossbowAttackGoal` in `mobs/illager.rs` tracked its own `Crossbow::Charged` state and the arm pose, but the held stack kept whatever it was spawned with. - **The mob renderer discarded the stack.** `game/mob_blocks.rs` rebuilt every non-local mob's held item as `ItemStack::new(item, 1)` from the name alone, so a mob's components never reached the item model — a server-sent loaded crossbow drew unloaded too. - **The equipment packet discarded it as well.** `game/remote.rs`'s `SetEquipment` handler kept only the translated item name for the main hand. ## The change - `mobs/illager.rs`: `set_crossbow_charged()` sets `charged_projectiles` to one arrow when the goal reaches `Charged`, and clears it on `stop` and after the shot; the held stack is created if the mob only had a name. - `game/mob_blocks.rs`: draw `mob.extra.main_hand_stack()` when there is one, as the local player's branch already did. - `game/remote.rs`: keep the stack the equipment packet sends for the main hand. Two unit tests cover the component being set and cleared, and that a non-crossbow is left alone. ## Evidence Same seed, same platform, HUD hidden, two pillagers summoned side by side: the left one with a plain crossbow, the right one with `components:{"minecraft:charged_projectiles":[{id:"minecraft:arrow"}]}` (the game reports the component back for it in both runs). Before, `main`: neither crossbow draws an arrow — the component is in the stack but the renderer never sees it. ![before: both crossbows empty](https://raw.githubusercontent.com/CocofireHD/horizon/pr-assets/4472-item-use/shots/pillager-before.png) After: the right one shows the loaded arrow. ![after: the loaded crossbow shows its arrow](https://raw.githubusercontent.com/CocofireHD/horizon/pr-assets/4472-item-use/shots/pillager-after.png) `cargo test -p horizon-client --lib illager::tests` → 16 passed, 0 failed. `cargo fmt --all -- --check` ✅. 🤖 Generated with [Hermes Agent](https://hermes-agent.nousresearch.com) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:14:23 +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#5699
No description provided.