[PR #5244] [MERGED] Keep dropped item pickups stable across native hooks #6162

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5244
Author: @arismoko
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: pickup-invalidation


📝 Commits (2)

  • bd26b09 Keep item pickups stable across native hooks
  • 208bb01 Merge remote-tracking branch 'upstream/main' into pickup-invalidation

📊 Changes

1 file changed (+16 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+16 -7)

📄 Description

🤖 Opened by Aria's agent swarm, Dyna, not by Aria.

Fixes #5223.

A native pickup hook can remove or change any dropped item. Keep the candidate IDs instead of vector indices, then find the touched item again after the hook. Skip it if it is gone. If it remains, use its current stack. This also keeps another item's removal from changing which item a later iteration touches.

Vanilla 26.3 ItemEntity.playerTouch discards an entity when its stack is emptied by pickup. Vanilla has no native hook at this point. The other supported dropped-item paths were checked: hopper insertion and item ticks do not call a Game native hook able to mutate the dropped-item vector while their index is live.

In-game proof on arch: A throwaway native mod removed the touched diamond from native_item_picked_up using native_set_item_entity. On upstream main, both an allowed pickup and a canceled pickup produced an index-out-of-bounds panic. With this fix, both cases left the game responsive. The test ran on the integrated server thread and on a dedicated server, before and after the fix. horizon-machine-sample is the recommended end-to-end test route. This test used a throwaway mod instead because it needed a hook that removes the touched item.

Tested head bd26b09bddac4a2b29a0268c305f688c7bec600f.

pr_ready (tools/pr_ready.py --base 981693933 on arch, against 981693933 at 981693933, 1 min 15 s)

Check Result
Scope ✅ 1 files, +16 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 499 passed (41 s)
rustfmt ✅ (9 s)
clippy ✅ (10 s)
tests: horizon-client ✅ 1403 passed (13 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 (no vanilla data here): 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)

🔄 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/5244 **Author:** [@arismoko](https://github.com/arismoko) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `pickup-invalidation` --- ### 📝 Commits (2) - [`bd26b09`](https://github.com/horizon-rust/horizon/commit/bd26b09bddac4a2b29a0268c305f688c7bec600f) Keep item pickups stable across native hooks - [`208bb01`](https://github.com/horizon-rust/horizon/commit/208bb011e8d7e33d797ebf301420b62fa9f54ff9) Merge remote-tracking branch 'upstream/main' into pickup-invalidation ### 📊 Changes **1 file changed** (+16 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+16 -7) </details> ### 📄 Description > 🤖 Opened by Aria's agent swarm, Dyna, not by Aria. Fixes #5223. A native pickup hook can remove or change any dropped item. Keep the candidate IDs instead of vector indices, then find the touched item again after the hook. Skip it if it is gone. If it remains, use its current stack. This also keeps another item's removal from changing which item a later iteration touches. Vanilla 26.3 `ItemEntity.playerTouch` discards an entity when its stack is emptied by pickup. Vanilla has no native hook at this point. The other supported dropped-item paths were checked: hopper insertion and item ticks do not call a Game native hook able to mutate the dropped-item vector while their index is live. **In-game proof on arch:** A throwaway native mod removed the touched diamond from `native_item_picked_up` using `native_set_item_entity`. On upstream main, both an allowed pickup and a canceled pickup produced an index-out-of-bounds panic. With this fix, both cases left the game responsive. The test ran on the integrated server thread and on a dedicated server, before and after the fix. [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample) is the recommended end-to-end test route. This test used a throwaway mod instead because it needed a hook that removes the touched item. Tested head `bd26b09bddac4a2b29a0268c305f688c7bec600f`. **pr_ready** (`tools/pr_ready.py --base 981693933` on arch, against 981693933 at 981693933, 1 min 15 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +16 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 499 passed (41 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (10 s) | | tests: horizon-client | ✅ 1403 passed (13 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 (no vanilla data here): 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) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:15:14 +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#6162
No description provided.