[GH-ISSUE #6197] Native mods: a mod's loot functions on block and entity drops, with the block entity #2010

Closed
opened 2026-11-02 15:51:19 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @reservedbytes on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6197

Follows #6142

A mod's own loot function (#6142) only runs in the main loot engine, so it never touches block drops or entity drops, and its context has no block entity
Vanilla runs every function on block and entity drops too (Block.getDrops, LivingEntity.dropFromLootTable), and a block's drop can copy data from its block entity (LootContextParams.BLOCK_ENTITY, as CopyComponentsFunction does)

What's missing

  • native_loot_function called for block drops, entity drops and interact_loot, like the condition hook already is
  • the block entity in NativeLootContext when the roll has one, so a function can copy its data into the drop
Originally created by @reservedbytes on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6197 Follows #6142 A mod's own loot function (#6142) only runs in the main loot engine, so it never touches block drops or entity drops, and its context has no block entity Vanilla runs every function on block and entity drops too (`Block.getDrops`, `LivingEntity.dropFromLootTable`), and a block's drop can copy data from its block entity (`LootContextParams.BLOCK_ENTITY`, as `CopyComponentsFunction` does) What's missing - `native_loot_function` called for block drops, entity drops and `interact_loot`, like the condition hook already is - the block entity in `NativeLootContext` when the roll has one, so a function can copy its data into the drop
Author
Owner

@reservedbytes commented on GitHub (Nov 1, 2026):

same two gaps as #6199 and #6200, one pr can close all three

<!-- gh-comment-id:6561832378 --> @reservedbytes commented on GitHub (Nov 1, 2026): same two gaps as #6199 and #6200, one pr can close all three
Author
Owner

@reservedbytes commented on GitHub (Nov 1, 2026):

also the tool in the context is only an id and enchantments (no components or damage), and it's None on a real mob death while /loot … kill fills it

<!-- gh-comment-id:6561868765 --> @reservedbytes commented on GitHub (Nov 1, 2026): also the tool in the context is only an id and enchantments (no components or damage), and it's None on a real mob death while `/loot … kill` fills it
Author
Owner

@breachato commented on GitHub (Nov 2, 2026):

🤖 Agent: comment by breachato's AI agent (Claude Code, Claude Opus 5.5), not by breachato personally.

Both points look done on main (be95d4595):

  • Block and entity drops, and interact loot. These roll in the items engine. Its modifiers now has a mod-kind arm that calls native_loot_function (crates/horizon-items/src/items.rs, "A mod's own kind: the function hook changes the stack"), from #6512, which closed #6199.
  • The block entity. NativeLootContext has block_entity: Option<Tag>, along with the roll's position and level (crates/horizon-world/src/loot.rs, 26103c104e, for #6200).

So this can probably be closed as covered by #6199 and #6200.

<!-- gh-comment-id:6573196117 --> @breachato commented on GitHub (Nov 2, 2026): 🤖 Agent: comment by breachato's AI agent (Claude Code, Claude Opus 5.5), not by breachato personally. Both points look done on main (`be95d4595`): - **Block and entity drops, and interact loot.** These roll in the items engine. Its `modifiers` now has a mod-kind arm that calls `native_loot_function` (`crates/horizon-items/src/items.rs`, "A mod's own kind: the function hook changes the stack"), from #6512, which closed #6199. - **The block entity.** `NativeLootContext` has `block_entity: Option<Tag>`, along with the roll's position and level (`crates/horizon-world/src/loot.rs`, 26103c104e, for #6200). So this can probably be closed as covered by #6199 and #6200.
Author
Owner

@reservedbytes commented on GitHub (Nov 2, 2026):

covered by #6512 and #6396

<!-- gh-comment-id:6582084495 --> @reservedbytes commented on GitHub (Nov 2, 2026): covered by #6512 and #6396
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#2010
No description provided.