[PR #5558] [MERGED] Native mods: a consumable's effect of a mod's own kind #6350

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5558
Author: @Qwerner88880
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: hooks-consume


📝 Commits (2)

  • 1742791 Native mods: a consumable's effect of a mod's own kind
  • fef6f80 Consume effects: an empty namespace is minecraft's

📊 Changes

5 files changed (+153 additions, -69 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+4 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+9 -0)
📝 crates/horizon-items/src/items.rs (+120 -69)
📝 docs/native-mods.md (+7 -0)
➕ tools/native-hook-fragments/consume_effect.json (+13 -0)

📄 Description

🤖 Opened by Qwerner88880's AI agent (ZCode, GLM-5.3), not by Qwerner88880 personally.

What and why

Fixes #5448. Part of #4953 ("More content registration") and #3911 (Mods).

A consumable's on_consume_effects entry of a type in a namespace of its own — where the old loader dropped it silently — reaches native_consume_effect(kind, data) when the item is consumed, on the server thread, for the acting player. The game's own effects, sounds, teleports and drops are open to the hook; an unclaimed kind does nothing. The hook sees the item's own consumable component, not a patch on the stack.

A bare type name without a namespace is minecraft's own — apply_effects is minecraft:apply_effects — so only a namespaced kind outside minecraft: becomes Native. An unknown minecraft: kind is dropped, as the old loader dropped everything it didn't know.

Behaviour change beside the hook: a vanilla kind without its minecraft: prefix used to be silently dropped; it now applies, as it always did with the prefix.

Kind

  • feature: something new for players (listed under New in the release notes)
  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • tooling
  • docs

Vanilla reference

Vanilla 26.3's ConsumeEffect is a closed interface with five kinds (apply(Level, ItemStack, LivingEntity) per subclass, jar-checked); NeoForge opens it with NeoForgeRegistries.Keys.INGREDIENT_TYPES-style registration. A mod's kind is a virtual apply here; the hook is the game's stand-in for it.

Other projects' code

none

Tests

Unit: parse_consume_effect covers four cases — a mod's own kind gives Native with its JSON; a bare vanilla name and its namespaced form both give the vanilla kind; an unknown minecraft: kind and a missing type are dropped.

Live, on this branch (HEAD after rebase, verified by Claude's agent on both a dedicated server with two clients and a single-player world): 21 checks, 0 failures. The hook fires once per consumed item with the right kind, data and acting player; minecraft:future_kind and a bare unknown never reach the hook; apply_effects without its namespace now applies (speed on the player) and doesn't go to the hook; vanilla bread is eaten with no hook firing.

Not verified: parity (CI's job — the items.rs parser is rewritten, watch it), a patch on the stack (/give ...[consumable=...]), and an unclaimed kind in a game without the bundle's hook (the empty function is harmless by reading, not by run).

Self-check

Check Result
Scope ✅ 5 files, +148 −69
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 510 passed (56 s)
rustfmt ✅ (9 s)
clippy ✅ (22 s)
tests: horizon-client, horizon-items ✅ 1613 passed (1 min 16 s)
doc tests ✅ 0 passed (2 s)
content root tests ✅ 14 passed
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 ZCode (GLM-5.3)


🔄 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/5558 **Author:** [@Qwerner88880](https://github.com/Qwerner88880) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `hooks-consume` --- ### 📝 Commits (2) - [`1742791`](https://github.com/horizon-rust/horizon/commit/1742791286b700099a149579b37eaf12993968c2) Native mods: a consumable's effect of a mod's own kind - [`fef6f80`](https://github.com/horizon-rust/horizon/commit/fef6f8080a5f0668be9f1819d9bd3e37f49e9e77) Consume effects: an empty namespace is minecraft's ### 📊 Changes **5 files changed** (+153 additions, -69 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+4 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+9 -0) 📝 `crates/horizon-items/src/items.rs` (+120 -69) 📝 `docs/native-mods.md` (+7 -0) ➕ `tools/native-hook-fragments/consume_effect.json` (+13 -0) </details> ### 📄 Description > 🤖 Opened by Qwerner88880's AI agent (ZCode, GLM-5.3), not by Qwerner88880 personally. ## What and why Fixes #5448. Part of #4953 ("More content registration") and #3911 (Mods). A consumable's `on_consume_effects` entry of a type in a namespace of its own — where the old loader dropped it silently — reaches `native_consume_effect(kind, data)` when the item is consumed, on the server thread, for the acting player. The game's own effects, sounds, teleports and drops are open to the hook; an unclaimed kind does nothing. The hook sees the item's own consumable component, not a patch on the stack. A bare type name without a namespace is minecraft's own — `apply_effects` is `minecraft:apply_effects` — so only a namespaced kind outside `minecraft:` becomes Native. An unknown `minecraft:` kind is dropped, as the old loader dropped everything it didn't know. **Behaviour change beside the hook:** a vanilla kind without its `minecraft:` prefix used to be silently dropped; it now applies, as it always did with the prefix. ## Kind - [x] feature: something new for players (listed under New in the release notes) - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] tooling - [ ] docs ## Vanilla reference Vanilla 26.3's `ConsumeEffect` is a closed interface with five kinds (`apply(Level, ItemStack, LivingEntity)` per subclass, jar-checked); NeoForge opens it with `NeoForgeRegistries.Keys.INGREDIENT_TYPES`-style registration. A mod's kind is a virtual `apply` here; the hook is the game's stand-in for it. ## Other projects' code none ## Tests **Unit:** `parse_consume_effect` covers four cases — a mod's own kind gives `Native` with its JSON; a bare vanilla name and its namespaced form both give the vanilla kind; an unknown `minecraft:` kind and a missing type are dropped. **Live, on this branch (HEAD after rebase, verified by Claude's agent on both a dedicated server with two clients and a single-player world):** 21 checks, 0 failures. The hook fires once per consumed item with the right kind, data and acting player; `minecraft:future_kind` and a bare unknown never reach the hook; `apply_effects` without its namespace now applies (speed on the player) and doesn't go to the hook; vanilla bread is eaten with no hook firing. **Not verified:** parity (CI's job — the items.rs parser is rewritten, watch it), a patch on the stack (`/give ...[consumable=...]`), and an unclaimed kind in a game without the bundle's hook (the empty function is harmless by reading, not by run). ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 5 files, +148 −69 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 510 passed (56 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (22 s) | | tests: horizon-client, horizon-items | ✅ 1613 passed (1 min 16 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ✅ 14 passed | | 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 ZCode (GLM-5.3) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:19:04 +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#6350
No description provided.