[PR #5661] [MERGED] Native mods: give a whole stack to any player (native_give_stack) #6422

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5661
Author: @lukehinojosa
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @levzzz5154

Base: main ← Head: feat/native-give-stack


📝 Commits (3)

  • b126de8 Native mods: give a whole stack to any player (native_give_stack)
  • a69a65d Merge remote-tracking branch 'hr/main' into pr-5661
  • 079292b Give stack: reach no other player inside a player's hook

📊 Changes

4 files changed (+168 additions, -44 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+60 -44)
📝 crates/horizon-client/src/game/native_server.rs (+98 -0)
📝 docs/native-mods.md (+4 -0)
➕ tools/native-hook-fragments/give_stack.json (+6 -0)

📄 Description

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

Closes #5655.

What and why

native_give_stack(uuid, stack) -> Option<ItemStack> in game/native_server.rs: gives a whole stack
(damage, name, enchantments kept) to any player from any server hook, as Inventory.add places it, and
returns what did not fit. All of it comes back for a player not on the server, dead, or out of reach while
another player's state is swapped in. Nothing is dropped. The plain-only helpers of API 9 are unchanged.

Game::give's slot loop moves into a free inventory_add that both use, so Inventory.add stays a single
port; Game::give behaves as before.

API number from the give_stack fragment (a local stamp gave 64; helper only, no hook).

Kind

  • extra: Horizon-only, off by default

Vanilla reference

Inventory.add → getSlotWithRemainingSpace (selected, off hand, 0..36), then getFreeSlot (0..36).

Tests

whole_stacks_are_given_onto_equal_stacks_only: a damaged sword never merges and keeps its damage; arrows
fill the selected slot, then the off hand, then a free slot, with the rest returned; an empty off hand is
never filled.

Proof

A minimal AutoPickup port (a native mod: native_destroy_block + native_entity_join_level + native_server_tick,
giving drops with native_give_stack), applied with horizon-mixins to this branch and built with --profile fast.
Driven with horizon-ctl in a fresh survival world (single player):

  • an oak log broken 4 blocks away, player standing still: in the inventory, no item entity left;
  • a chest holding 128 cobblestone: the chest and all 128 picked up, nothing on the ground;
  • a chest holding an iron sword [damage=100], 3 diamonds named "Lucky" and 2 plain diamonds: the sword kept
    damage: 100, the named and plain diamonds stayed separate stacks (/data get entity @s Inventory);
  • a full inventory, then a spruce log: it stayed on the ground as an item entity.

Not covered: a LAN guest (that path has the unit test only) and a dedicated server.

Self-check

pr_ready (tools/pr_ready.py --quick on DESKTOP-LMH2005, against origin/main at 74698584e, 5 min 25 s)

Check Result
Scope ✅ 4 files, +162 −44
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 510 passed (1 min 32 s)
rustfmt ✅ (12 s)
clippy ✅ (2 min 15 s)
tests: horizon-client ✅ 1575 passed (1 min 20 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)

🤖 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/5661 **Author:** [@lukehinojosa](https://github.com/lukehinojosa) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `feat/native-give-stack` --- ### 📝 Commits (3) - [`b126de8`](https://github.com/horizon-rust/horizon/commit/b126de85e3d0f622b56555bcb5371a87048ed6c5) Native mods: give a whole stack to any player (native_give_stack) - [`a69a65d`](https://github.com/horizon-rust/horizon/commit/a69a65d0998ebde7ce2d16d212b1df539448747d) Merge remote-tracking branch 'hr/main' into pr-5661 - [`079292b`](https://github.com/horizon-rust/horizon/commit/079292b6694c6e0fb16a5fba908934ce1ef3503b) Give stack: reach no other player inside a player's hook ### 📊 Changes **4 files changed** (+168 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+60 -44) 📝 `crates/horizon-client/src/game/native_server.rs` (+98 -0) 📝 `docs/native-mods.md` (+4 -0) ➕ `tools/native-hook-fragments/give_stack.json` (+6 -0) </details> ### 📄 Description > 🤖 Opened by lukehinojosa's AI agent (Claude Code, Claude Opus 5.5), not by lukehinojosa personally. Closes #5655. ## What and why `native_give_stack(uuid, stack) -> Option<ItemStack>` in `game/native_server.rs`: gives a whole stack (damage, name, enchantments kept) to any player from any server hook, as `Inventory.add` places it, and returns what did not fit. All of it comes back for a player not on the server, dead, or out of reach while another player's state is swapped in. Nothing is dropped. The plain-only helpers of API 9 are unchanged. `Game::give`'s slot loop moves into a free `inventory_add` that both use, so `Inventory.add` stays a single port; `Game::give` behaves as before. API number from the `give_stack` fragment (a local stamp gave 64; helper only, no hook). ## Kind - [x] extra: Horizon-only, off by default ## Vanilla reference `Inventory.add` → `getSlotWithRemainingSpace` (selected, off hand, 0..36), then `getFreeSlot` (0..36). ## Tests `whole_stacks_are_given_onto_equal_stacks_only`: a damaged sword never merges and keeps its damage; arrows fill the selected slot, then the off hand, then a free slot, with the rest returned; an empty off hand is never filled. ## Proof A minimal AutoPickup port (a native mod: `native_destroy_block` + `native_entity_join_level` + `native_server_tick`, giving drops with `native_give_stack`), applied with horizon-mixins to this branch and built with `--profile fast`. Driven with horizon-ctl in a fresh survival world (single player): - an oak log broken 4 blocks away, player standing still: in the inventory, no item entity left; - a chest holding 128 cobblestone: the chest and all 128 picked up, nothing on the ground; - a chest holding an iron sword `[damage=100]`, 3 diamonds named "Lucky" and 2 plain diamonds: the sword kept `damage: 100`, the named and plain diamonds stayed separate stacks (`/data get entity @s Inventory`); - a full inventory, then a spruce log: it stayed on the ground as an item entity. Not covered: a LAN guest (that path has the unit test only) and a dedicated server. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-LMH2005, against origin/main at 74698584e, 5 min 25 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +162 −44 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 510 passed (1 min 32 s) | | rustfmt | ✅ (12 s) | | clippy | ✅ (2 min 15 s) | | tests: horizon-client | ✅ 1575 passed (1 min 20 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) | 🤖 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 06:20:21 +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#6422
No description provided.