[PR #5763] [MERGED] Native mods: player-use drops through native_loot_drops #6482

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

📋 Pull Request Information

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

Base: main ← Head: feat/native-interaction-drops


📝 Commits (3)

  • aa80524 Native mods: player-use drops through native_loot_drops
  • 6d74415 Merge remote-tracking branch 'hr/main' into pr-5763
  • a9c6d86 Spill: a use whose loot came out empty still reaches the hook and is drained

📊 Changes

8 files changed (+248 additions, -27 deletions)

View changed files

📝 crates/horizon-client/src/game/brush.rs (+18 -5)
📝 crates/horizon-client/src/game/creatures.rs (+46 -8)
📝 crates/horizon-client/src/game/frames.rs (+18 -4)
📝 crates/horizon-client/src/game/native_hooks.rs (+39 -2)
📝 crates/horizon-client/src/game/pumpkin.rs (+11 -4)
📝 crates/horizon-client/src/game/spill.rs (+105 -3)
📝 docs/native-mods.md (+5 -1)
➕ tools/native-hook-fragments/use_drops.json (+6 -0)

📄 Description

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

Closes #5762.

What and why

native_loot_drops heard block breaks and mob deaths only. Now a player's use drops through it too, with the
acting player in player and the new NativeLootDrops::used set:

Use Where table Context
Shears on a sheep creatures.rs interact_mob minecraft:shearing/sheep/<color> entity
Shears on a mooshroom same empty (five mushrooms, no table) entity
Shears on a snow golem or a bogged interact_shear_mob its shearing table entity
Brush on an armadillo interact_armadillo minecraft:brush/armadillo entity
Brush on a suspicious block brush.rs brushing_completed empty (the unpacked item) block
Shears carving a pumpkin pumpkin.rs minecraft:carve/pumpkin block
Picking sweet berries or cave vines spill.rs drop_interact_loot its harvest table block
A hit taking an item frame or its item frames.rs drop_frame_items empty entity (the frame)

One helper, native_use_drops, builds the context (native_acting_id for the player) and drops empty stacks, as
native_block_drops does. A mod can add, change or take out stacks; the spawn code places them as before. The
sheep's and mooshroom's drops were (String, u32) pairs, now ItemStacks, so a mod's components survive.

Berries and cave vines pop inside the block behaviour (GameLevel), which can't reach the hooks. Their run of
spill.spawns is tagged (UsedDrops) and flush_spill, right after with_level and still as the acting
player, retells it with retell_runs: each stack keeps its spot, motion and delay, so with no mod the spawns and
the random draws are as before; a stack a mod adds takes the run's last spot.

Left out: dispenser shears (no player), frames an explosion breaks, and leads.

The hook's signature doesn't change, so its catalog contract stays at version 1 (the field is additive). API number
from the use_drops fragment (no new hook).

Kind

  • extra: Horizon-only, off by default

Vanilla reference

Sheep.shear, MushroomCow.shear, SnowGolem.shear, Bogged.shear, Armadillo.brushOffScute,
BrushableBlockEntity.dropContent, PumpkinBlock.useItemOn, Block.dropFromBlockInteractLootTable,
ItemFrame.dropItem.

Tests

a_used_run_is_retold_in_place: a run between two other spawns, where the mod removes one stack and adds one,
keeps its spots and the spawns around it.

Proof

The AutoPickup test port (gives every player-named native_loot_drops stack with native_give_stack, #5661),
applied with horizon-mixins and built with --profile fast on this branch plus #5661, #5748 and a local fix for
#5678, driven with horizon-ctl in a fresh survival world. Each went into the inventory with nothing left on the
ground:

  • shears: sheep → 1 red wool; mooshroom → 5 red mushrooms (it became a cow); snow golem → carved pumpkin; bogged →
    a red and a brown mushroom; pumpkin → 4 pumpkin seeds;
  • brush: armadillo → a scute; suspicious sand holding an emerald → the emerald (the block turned to sand);
  • sweet berry bush at age 3 → 3 sweet berries (age 1 after);
  • item frame holding a diamond: first hit → the diamond, second → the item frame.

Not covered in-game: cave vines (same path as the berry bush), a LAN guest on another machine, a dedicated
server.

Self-check

Run on Windows (DESKTOP-LMH2005) against origin/main at 9cf948a10:

Check Result
Scope 8 files (see the diff)
rustfmt ✅
clippy --all-targets -D warnings ✅
tests: horizon-client (lib) ✅ 1114 passed
tests: horizon-client (bin) ⚠️ 488 passed, 1 failed: the CRLF test below, failing on main too
Parity ➖ CI's parity job picks the affected harnesses

Known on Windows: game::native_hooks::tests::loot_table_load_stays_hookable fails on a checkout with
core.autocrlf=true, on main as well; CI's Linux checkout passes.

🤖 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/5763 **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-interaction-drops` --- ### 📝 Commits (3) - [`aa80524`](https://github.com/horizon-rust/horizon/commit/aa805243b63fabb30177b018a93a9ea92b6aac23) Native mods: player-use drops through native_loot_drops - [`6d74415`](https://github.com/horizon-rust/horizon/commit/6d744151ac0cb06da8f102f05766c1fd858f4b39) Merge remote-tracking branch 'hr/main' into pr-5763 - [`a9c6d86`](https://github.com/horizon-rust/horizon/commit/a9c6d86b39edae9bbef5fc325fc60b4ce0021957) Spill: a use whose loot came out empty still reaches the hook and is drained ### 📊 Changes **8 files changed** (+248 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/brush.rs` (+18 -5) 📝 `crates/horizon-client/src/game/creatures.rs` (+46 -8) 📝 `crates/horizon-client/src/game/frames.rs` (+18 -4) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+39 -2) 📝 `crates/horizon-client/src/game/pumpkin.rs` (+11 -4) 📝 `crates/horizon-client/src/game/spill.rs` (+105 -3) 📝 `docs/native-mods.md` (+5 -1) ➕ `tools/native-hook-fragments/use_drops.json` (+6 -0) </details> ### 📄 Description > 🤖 Opened by lukehinojosa's AI agent (Claude Code, Claude Opus 5.5), not by lukehinojosa personally. Closes #5762. ## What and why `native_loot_drops` heard block breaks and mob deaths only. Now a player's use drops through it too, with the acting player in `player` and the new `NativeLootDrops::used` set: | Use | Where | `table` | Context | | --- | --- | --- | --- | | Shears on a sheep | `creatures.rs` `interact_mob` | `minecraft:shearing/sheep/<color>` | entity | | Shears on a mooshroom | same | empty (five mushrooms, no table) | entity | | Shears on a snow golem or a bogged | `interact_shear_mob` | its shearing table | entity | | Brush on an armadillo | `interact_armadillo` | `minecraft:brush/armadillo` | entity | | Brush on a suspicious block | `brush.rs` `brushing_completed` | empty (the unpacked item) | block | | Shears carving a pumpkin | `pumpkin.rs` | `minecraft:carve/pumpkin` | block | | Picking sweet berries or cave vines | `spill.rs` `drop_interact_loot` | its harvest table | block | | A hit taking an item frame or its item | `frames.rs` `drop_frame_items` | empty | entity (the frame) | One helper, `native_use_drops`, builds the context (`native_acting_id` for the player) and drops empty stacks, as `native_block_drops` does. A mod can add, change or take out stacks; the spawn code places them as before. The sheep's and mooshroom's drops were `(String, u32)` pairs, now `ItemStack`s, so a mod's components survive. Berries and cave vines pop inside the block behaviour (`GameLevel`), which can't reach the hooks. Their run of `spill.spawns` is tagged (`UsedDrops`) and `flush_spill`, right after `with_level` and still as the acting player, retells it with `retell_runs`: each stack keeps its spot, motion and delay, so with no mod the spawns and the random draws are as before; a stack a mod adds takes the run's last spot. Left out: dispenser shears (no player), frames an explosion breaks, and leads. The hook's signature doesn't change, so its catalog contract stays at version 1 (the field is additive). API number from the `use_drops` fragment (no new hook). ## Kind - [x] extra: Horizon-only, off by default ## Vanilla reference `Sheep.shear`, `MushroomCow.shear`, `SnowGolem.shear`, `Bogged.shear`, `Armadillo.brushOffScute`, `BrushableBlockEntity.dropContent`, `PumpkinBlock.useItemOn`, `Block.dropFromBlockInteractLootTable`, `ItemFrame.dropItem`. ## Tests `a_used_run_is_retold_in_place`: a run between two other spawns, where the mod removes one stack and adds one, keeps its spots and the spawns around it. ## Proof The AutoPickup test port (gives every player-named `native_loot_drops` stack with `native_give_stack`, #5661), applied with horizon-mixins and built with `--profile fast` on this branch plus #5661, #5748 and a local fix for #5678, driven with horizon-ctl in a fresh survival world. Each went into the inventory with nothing left on the ground: - shears: sheep → 1 red wool; mooshroom → 5 red mushrooms (it became a cow); snow golem → carved pumpkin; bogged → a red and a brown mushroom; pumpkin → 4 pumpkin seeds; - brush: armadillo → a scute; suspicious sand holding an emerald → the emerald (the block turned to sand); - sweet berry bush at age 3 → 3 sweet berries (age 1 after); - item frame holding a diamond: first hit → the diamond, second → the item frame. Not covered in-game: cave vines (same path as the berry bush), a LAN guest on another machine, a dedicated server. ## Self-check Run on Windows (DESKTOP-LMH2005) against origin/main at 9cf948a10: | Check | Result | | --- | --- | | Scope | 8 files (see the diff) | | rustfmt | ✅ | | clippy `--all-targets -D warnings` | ✅ | | tests: horizon-client (lib) | ✅ 1114 passed | | tests: horizon-client (bin) | ⚠️ 488 passed, 1 failed: the CRLF test below, failing on main too | | Parity | ➖ CI's parity job picks the affected harnesses | Known on Windows: `game::native_hooks::tests::loot_table_load_stays_hookable` fails on a checkout with `core.autocrlf=true`, on main as well; CI's Linux checkout passes. 🤖 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:21: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#6482
No description provided.