[PR #4981] [MERGED] Pin the living use flags to vanilla's 1/3/2 wire values #5987

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4981
Author: @navinor
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: test/living-use-flags


📝 Commits (1)

  • d331af9 Pin the living use flags to vanilla's 1/3/2 wire values

📊 Changes

3 files changed (+33 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/game/lan.rs (+18 -1)
📝 crates/horizon-client/src/game/remote.rs (+5 -2)
📝 crates/horizon-client/src/game/remote_mob_data.rs (+10 -3)

📄 Description

🤖 Opened by navinor's AI agent (OpenCode, DeepSeek V4.1 Flash), not by navinor personally.

What and why

Pins LivingEntity.DATA_LIVING_ENTITY_FLAGS (entity data index 8) at both ends of the LAN path and records which flag bit means what.

Issue #4778 reads the pinned 26.3 code the wrong way round. startUsingItem calls setLivingEntityFlag(1, true) and then setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND) (LivingEntity.java:3499-3507), so an active off-hand use is 3, not 2. stopUsingItem clears only flag 1 (LivingEntity.java:3617-3621), so its stop is 2. A value of 2 is "not using, the last hand was the off hand": isUsingItem reads bit 0 and getUsedItemHand reads bit 1 (LivingEntity.java:3419-3424). Sending 2 for an active off-hand use would make a vanilla client drop the use.

This adds regression tests for the active and stopped off-hand values at the sender and both readers, and corrects the comments that invited the misreading. No behaviour changes.

Refs #4778 (the report's premise does not match the pinned game).

Kind

  • tooling: tools, CI, tests, harnesses

Vanilla reference

LivingEntity.startUsingItem, stopUsingItem, isUsingItem and getUsedItemHand (lines above). The existing harnesses already compare that model with 26.3: tools/test_item_use_start_parity.py with VanillaItemUseStartOracle.java records the exact setLivingEntityFlag calls for both start hands, and tools/test_use_flag_reaction_parity.py with VanillaUseFlagReactionOracle.java reads isUsingItem/getUsedItemHand for all 256 flag bytes. I ran the latter here: 366,331 output lines match on both the client and server jars.

Other projects' code

None.

Self-check

pr_ready (tools/pr_ready.py --quick on Aaron, against origin/main at 4de90a13d, 4 min 5 s)

Check Result
Scope ✅ 3 files, +33 −6
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 18 s)
rustfmt ✅ (13 s)
clippy ❌ failed (12 s)
tests: horizon-client ✅ 1310 passed (2 min 17 s)
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 ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The clippy failure is pre-existing on origin/main at crates/horizon-threads/src/lib.rs:438 (&vec![0; 100]); this PR does not touch that crate. The one-line fix is #4982.

🤖 Generated with OpenCode


🔄 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/4981 **Author:** [@navinor](https://github.com/navinor) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `test/living-use-flags` --- ### 📝 Commits (1) - [`d331af9`](https://github.com/horizon-rust/horizon/commit/d331af99623ab336dbb1691590f19da0658be84e) Pin the living use flags to vanilla's 1/3/2 wire values ### 📊 Changes **3 files changed** (+33 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan.rs` (+18 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+5 -2) 📝 `crates/horizon-client/src/game/remote_mob_data.rs` (+10 -3) </details> ### 📄 Description > 🤖 Opened by navinor's AI agent (OpenCode, DeepSeek V4.1 Flash), not by navinor personally. ## What and why Pins `LivingEntity.DATA_LIVING_ENTITY_FLAGS` (entity data index 8) at both ends of the LAN path and records which flag bit means what. Issue #4778 reads the pinned 26.3 code the wrong way round. `startUsingItem` calls `setLivingEntityFlag(1, true)` and then `setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND)` (`LivingEntity.java:3499-3507`), so an active off-hand use is 3, not 2. `stopUsingItem` clears only flag 1 (`LivingEntity.java:3617-3621`), so its stop is 2. A value of 2 is "not using, the last hand was the off hand": `isUsingItem` reads bit 0 and `getUsedItemHand` reads bit 1 (`LivingEntity.java:3419-3424`). Sending 2 for an active off-hand use would make a vanilla client drop the use. This adds regression tests for the active and stopped off-hand values at the sender and both readers, and corrects the comments that invited the misreading. No behaviour changes. Refs #4778 (the report's premise does not match the pinned game). ## Kind - [x] tooling: tools, CI, tests, harnesses ## Vanilla reference `LivingEntity.startUsingItem`, `stopUsingItem`, `isUsingItem` and `getUsedItemHand` (lines above). The existing harnesses already compare that model with 26.3: `tools/test_item_use_start_parity.py` with `VanillaItemUseStartOracle.java` records the exact `setLivingEntityFlag` calls for both start hands, and `tools/test_use_flag_reaction_parity.py` with `VanillaUseFlagReactionOracle.java` reads `isUsingItem`/`getUsedItemHand` for all 256 flag bytes. I ran the latter here: 366,331 output lines match on both the client and server jars. ## Other projects' code None. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Aaron, against origin/main at 4de90a13d, 4 min 5 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +33 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 18 s) | | rustfmt | ✅ (13 s) | | clippy | ❌ failed (12 s) | | tests: horizon-client | ✅ 1310 passed (2 min 17 s) | | 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 | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The clippy failure is pre-existing on `origin/main` at `crates/horizon-threads/src/lib.rs:438` (`&vec![0; 100]`); this PR does not touch that crate. The one-line fix is #4982. 🤖 Generated with [OpenCode](https://opencode.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:26 +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#5987
No description provided.