[PR #4216] [MERGED] Lower the shield when a server stops the player's use #5490

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

📋 Pull Request Information

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

Base: main ← Head: fix/shield-server-stop


📝 Commits (1)

  • 6f42cbb Lower the shield when a server stops the player's use

📊 Changes

1 file changed (+62 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+62 -0)

📄 Description

🤖 Opened by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally.

What

On a server, the client now follows the server's DATA_LIVING_ENTITY_FLAGS (entity data index 8) for its own player:

  • if the server clears the "using" bit while the client is using an item, the client stops the use;
  • if the server sets the bit while the client isn't using one, the client starts the use in the flagged hand (it needs an item in that hand).

Until now the client ignored this flag for its own player. So when an axe hit disabled a raised shield (Player.disableShield → stopUsingItem on the server), the shield stayed up on screen while hits still landed. The shield now drops. With right click still held it stays down, because remote_use_item already checks the item cooldown the server sends.

Why (vanilla 26.3)

  • LocalPlayer.onSyncedDataUpdated(EntityDataAccessor): for DATA_LIVING_ENTITY_FLAGS, using = flags & 1, hand = flags & 2 ? OFF_HAND : MAIN_HAND. If using && !startedUsingItem, it calls startUsingItem(hand). If !using && startedUsingItem, it calls stopUsingItem().
  • LocalPlayer.startUsingItem only starts when the hand holds an item; LocalPlayer.isUsingItem returns startedUsingItem.
  • Server side: Player.disableShield → stopUsingItem, which clears the flag that goes to the player.

Horizon's own LAN/dedicated hub doesn't send a guest its own entity data (lan/entity.rs skips v.entity_id), so nothing changes there. This affects vanilla and third-party servers (the report is from mcpvp.club).

Checked

  • New unit tests in game/remote.rs cover synced_local_use: the server stopping a raised off-hand shield, starting a use in either hand, an empty hand not starting one, and matching flags leaving a running use alone. The tests and the rest of the game binary's tests pass (209 + 18).
  • Not checked in game: on this Windows machine the vanilla 26.3 server crashes at startup (failed to open a new selector / Unable to establish loopback connection), so I couldn't reproduce an axe-disabled shield against a real server.
  • Known unrelated Windows failures in pr_ready:
    • title::tests::each_world_preset_writes_its_own_generator (Windows path error);
    • clippy: new clippy 1.96 lints in other code; cargo clippy -p horizon-client --bins --tests -- -D warnings -A clippy::manual_range_contains -A clippy::nonminimal_bool -A clippy::overly_complex_bool_expr is clean;
    • Parity: tools/parity.py needs fcntl, so the harnesses are left to CI (run-parity).

Fixes #4115

pr_ready (tools/pr_ready.py --base upstream/main on DenisPC, against upstream/main at bd9b32587, 4 min 3 s)

Check Result
Scope ✅ 1 files, +62 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (57 s)
rustfmt ✅ (7 s)
clippy ❌ failed (19 s) (clippy 1.96 lints in other code, see above)
tests: horizon-client ❌ 726 passed, 1 failed (2 min 31 s) (title world_preset, Windows-only)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ❌ 362 affected (fcntl: not runnable on Windows)

🤖 Generated with Claude Code


🔄 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/4216 **Author:** [@DenisHumen](https://github.com/DenisHumen) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/shield-server-stop` --- ### 📝 Commits (1) - [`6f42cbb`](https://github.com/horizon-rust/horizon/commit/6f42cbb13f009fb0f9e6e378b5d19adebc69d66c) Lower the shield when a server stops the player's use ### 📊 Changes **1 file changed** (+62 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+62 -0) </details> ### 📄 Description > 🤖 Opened by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally. ## What On a server, the client now follows the server's `DATA_LIVING_ENTITY_FLAGS` (entity data index 8) for its own player: - if the server clears the "using" bit while the client is using an item, the client stops the use; - if the server sets the bit while the client isn't using one, the client starts the use in the flagged hand (it needs an item in that hand). Until now the client ignored this flag for its own player. So when an axe hit disabled a raised shield (`Player.disableShield` → `stopUsingItem` on the server), the shield stayed up on screen while hits still landed. The shield now drops. With right click still held it stays down, because `remote_use_item` already checks the item cooldown the server sends. ## Why (vanilla 26.3) - `LocalPlayer.onSyncedDataUpdated(EntityDataAccessor)`: for `DATA_LIVING_ENTITY_FLAGS`, `using = flags & 1`, `hand = flags & 2 ? OFF_HAND : MAIN_HAND`. If `using && !startedUsingItem`, it calls `startUsingItem(hand)`. If `!using && startedUsingItem`, it calls `stopUsingItem()`. - `LocalPlayer.startUsingItem` only starts when the hand holds an item; `LocalPlayer.isUsingItem` returns `startedUsingItem`. - Server side: `Player.disableShield` → `stopUsingItem`, which clears the flag that goes to the player. Horizon's own LAN/dedicated hub doesn't send a guest its own entity data (`lan/entity.rs` skips `v.entity_id`), so nothing changes there. This affects vanilla and third-party servers (the report is from mcpvp.club). ## Checked - New unit tests in `game/remote.rs` cover `synced_local_use`: the server stopping a raised off-hand shield, starting a use in either hand, an empty hand not starting one, and matching flags leaving a running use alone. The tests and the rest of the game binary's tests pass (209 + 18). - Not checked in game: on this Windows machine the vanilla 26.3 server crashes at startup (`failed to open a new selector` / `Unable to establish loopback connection`), so I couldn't reproduce an axe-disabled shield against a real server. - Known unrelated Windows failures in pr_ready: - `title::tests::each_world_preset_writes_its_own_generator` (Windows path error); - clippy: new clippy 1.96 lints in other code; `cargo clippy -p horizon-client --bins --tests -- -D warnings -A clippy::manual_range_contains -A clippy::nonminimal_bool -A clippy::overly_complex_bool_expr` is clean; - Parity: `tools/parity.py` needs `fcntl`, so the harnesses are left to CI (`run-parity`). Fixes #4115 **pr_ready** (`tools/pr_ready.py --base upstream/main` on DenisPC, against upstream/main at bd9b32587, 4 min 3 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +62 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (57 s) | | rustfmt | ✅ (7 s) | | clippy | ❌ failed (19 s) (clippy 1.96 lints in other code, see above) | | tests: horizon-client | ❌ 726 passed, 1 failed (2 min 31 s) (title world_preset, Windows-only) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ❌ 362 affected (fcntl: not runnable on Windows) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:12:57 +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#5490
No description provided.