[PR #5546] [MERGED] Read a stack's own blocks_attacks component #6348

Closed
opened 2026-11-03 06:19:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5546
Author: @Vaspyyy
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat/stack-blocks-attacks


📝 Commits (2)

  • 3541a9b Read a stack's own blocks_attacks component
  • 347ca18 Merge remote-tracking branch 'origin/main' into feat/stack-blocks-attacks

📊 Changes

4 files changed (+65 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+2 -3)
📝 crates/horizon-client/src/game/remote.rs (+2 -1)
📝 crates/horizon-client/src/game/shield.rs (+7 -3)
📝 crates/horizon-items/src/items.rs (+54 -0)

📄 Description

Requested by Ransom · project thread

🤖 Opened by Vaspyyy's AI agent (Claude Code)

What

In vanilla 26.3, Item.use, LivingEntity.getItemBlockingWith and applyItemBlocking read DataComponents.BLOCKS_ATTACKS from the stack. So /give @s diamond_sword[blocks_attacks={}] gives a sword that you raise with right click and that blocks like a shield. Many servers use this to bring back sword blocking.

Horizon only read the item's default component (ItemInfo::blocks_attacks). A stack carrying its own component was kept in StackData::other and saved, but gameplay ignored it.

Change

  • BlocksAttacks::of_stack(stack, item) (horizon-items) returns the stack's own component, parsed with the same codec defaults, and falls back to the item's.
  • Game::blocks_attacks (shield.rs) goes through it and now returns a Cow. That covers raising, blocking, after-block effects, the gamepad trigger feel and the third-person pose.
  • These checks read the item default directly and now use the stack too: the use tick (tick_used_item), the off-hand shield check in playerHasBlockingItemUseIntent, and the remote client's use_ends_click, so the off hand doesn't also get a turn.

Not in this PR

  • Stacks from a vanilla server: the wire decoder skips blocks_attacks (item/skip.rs), so it never reaches StackData. Keeping it means modelling the component in the protocol crate.
  • Component removal (!minecraft:blocks_attacks on a shield) isn't modelled in StackData.
  • The arm pose of other players (lan.rs, remote.rs) still reads by item id.

Tests

  • New items::tests::a_stacks_own_blocks_attacks_component_counts: no component means none; the stack's component is parsed (angle, base/factor, delay, item damage, bypass); an empty compound gives the codec defaults.
  • cargo test -p horizon-items passes, and the horizon-client shield/block/use tests pass. cargo fmt and clippy are clean on both crates (with -A clippy::manual_range_contains, which fails on main itself).

🤖 Generated with Claude Code

https://claude.ai/code/session_01XnU6QSY4AbxZbBtWqJLhFg


🔄 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/5546 **Author:** [@Vaspyyy](https://github.com/Vaspyyy) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/stack-blocks-attacks` --- ### 📝 Commits (2) - [`3541a9b`](https://github.com/horizon-rust/horizon/commit/3541a9b97e8a3131a25b7e0242750b84346b7aed) Read a stack's own blocks_attacks component - [`347ca18`](https://github.com/horizon-rust/horizon/commit/347ca18b3169fa9eed8dbeda84268463b895611a) Merge remote-tracking branch 'origin/main' into feat/stack-blocks-attacks ### 📊 Changes **4 files changed** (+65 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+2 -3) 📝 `crates/horizon-client/src/game/remote.rs` (+2 -1) 📝 `crates/horizon-client/src/game/shield.rs` (+7 -3) 📝 `crates/horizon-items/src/items.rs` (+54 -0) </details> ### 📄 Description <!-- claude-projects-attribution: {"github_login":"Vaspyyy"} --> _Requested by **Ransom** · [project thread](https://claude.ai/code/project/chan_014LE6qsPXZ5YJ26HjaADSTZ?thread=cmsg_014LE6qsPXZ5YJ26HjaADSTZ4ukFxNQaNnScVrDetWhcvd)_ > 🤖 Opened by Vaspyyy's AI agent (Claude Code) ## What In vanilla 26.3, `Item.use`, `LivingEntity.getItemBlockingWith` and `applyItemBlocking` read `DataComponents.BLOCKS_ATTACKS` from the **stack**. So `/give @s diamond_sword[blocks_attacks={}]` gives a sword that you raise with right click and that blocks like a shield. Many servers use this to bring back sword blocking. Horizon only read the item's default component (`ItemInfo::blocks_attacks`). A stack carrying its own component was kept in `StackData::other` and saved, but gameplay ignored it. ## Change - `BlocksAttacks::of_stack(stack, item)` (horizon-items) returns the stack's own component, parsed with the same codec defaults, and falls back to the item's. - `Game::blocks_attacks` (shield.rs) goes through it and now returns a `Cow`. That covers raising, blocking, after-block effects, the gamepad trigger feel and the third-person pose. - These checks read the item default directly and now use the stack too: the use tick (`tick_used_item`), the off-hand shield check in `playerHasBlockingItemUseIntent`, and the remote client's `use_ends_click`, so the off hand doesn't also get a turn. ## Not in this PR - Stacks from a vanilla server: the wire decoder skips `blocks_attacks` (`item/skip.rs`), so it never reaches `StackData`. Keeping it means modelling the component in the protocol crate. - Component removal (`!minecraft:blocks_attacks` on a shield) isn't modelled in `StackData`. - The arm pose of *other* players (lan.rs, remote.rs) still reads by item id. ## Tests - New `items::tests::a_stacks_own_blocks_attacks_component_counts`: no component means none; the stack's component is parsed (angle, base/factor, delay, item damage, bypass); an empty compound gives the codec defaults. - `cargo test -p horizon-items` passes, and the `horizon-client` shield/block/use tests pass. `cargo fmt` and clippy are clean on both crates (with `-A clippy::manual_range_contains`, which fails on main itself). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XnU6QSY4AbxZbBtWqJLhFg --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:19:03 +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#6348
No description provided.