[PR #4840] [MERGED] feat(mods): content mods declare their own mob effects #5887

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4840
Author: @reservedbytes
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: feat/mod-mob-effects


📝 Commits (3)

  • 50cd606 feat(mods): content mods declare their own mob effects
  • a49b9a6 Address review: simplify mob_effect_id, read effects through Builtin::parse, test command-registries, docs
  • 27c38eb Merge hr/main into feat/mod-mob-effects

📊 Changes

22 files changed (+481 additions, -62 deletions)

View changed files

📝 crates/cargo-horizon-mod/template/content/horizon-mod.toml (+2 -2)
📝 crates/horizon-client-core/src/potions.rs (+83 -4)
📝 crates/horizon-client-render/src/brewing.rs (+3 -4)
📝 crates/horizon-client-render/src/effects.rs (+27 -2)
📝 crates/horizon-client-render/src/hud_overlays.rs (+1 -1)
📝 crates/horizon-client-render/src/inventory_effects.rs (+1 -1)
📝 crates/horizon-client/src/content_identity.rs (+59 -4)
📝 crates/horizon-client/src/entity_nbt.rs (+31 -0)
📝 crates/horizon-client/src/game/advancements.rs (+4 -1)
📝 crates/horizon-client/src/game/chat.rs (+2 -3)
📝 crates/horizon-client/src/game/commands/effects.rs (+1 -1)
📝 crates/horizon-client/src/game/mods.rs (+29 -0)
📝 crates/horizon-client/src/game/potions.rs (+2 -15)
📝 crates/horizon-client/src/lan/hub.rs (+2 -2)
📝 crates/horizon-client/src/mod_content.rs (+34 -6)
📝 crates/horizon-client/src/mod_content_tests.rs (+82 -2)
📝 crates/horizon-mods/src/content.rs (+92 -4)
📝 crates/horizon-mods/src/manifest.rs (+3 -3)
📝 docs/api/data-formats.md (+1 -0)
📝 docs/api/stability.md (+1 -1)

...and 2 more files

📄 Description

What and why

Content mods can add blocks and items but not mob effects, so a mod's food, potion or weapon can only give vanilla ones

A mod declares an effect in data/<id>/horizon/mob_effect/<name>.json, with what vanilla's MobEffect takes

{ "category": "harmful", "color": 9154528 }

It gets a minecraft:mob_effect network id after vanilla's, /effect give @s <id>:<name> works, players and mobs keep it in their saves, and its name comes from the mod's lang (effect.<id>.<name>)
Same on the server thread, LAN and dedicated servers

A client with a different set of mod effects is refused when it joins, as with mod blocks, instead of reading the wrong effect
The list is fixed when the game starts, a mod switched on later logs that a restart is needed

No icon yet, the HUD shows the effect's frame and the inventory its frame and name (icons come in the next PR)
No behaviour of its own yet either, that needs hook points

Nothing changes without a mod that declares an effect, and vanilla effect lookups take the same time as before (timed, within noise)

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

MobEffect(MobEffectCategory, int color) (world/effect/MobEffect.java:55)
The name key is Util.makeDescriptionId("effect", id) (MobEffect.java:114-118, util/Util.java:162-164)

Self-check

Check Result
Scope ✅ 21 files, +461 −48
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (54 s)
rustfmt ✅ (9 s)
clippy ✅ (2 min 23 s)
tests: cargo-horizon-mod, horizon-client, horizon-client-core, horizon-client-render, horizon-mods ✅ 1958 passed (6 min 34 s)
doc tests ✅ 0 passed (3 s)
content root tests ✅ 7 passed (1 min 10 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅ (1 min 23 s)
launcher tests ✅ 300 passed (2 min 34 s)
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)

🔄 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/4840 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `feat/mod-mob-effects` --- ### 📝 Commits (3) - [`50cd606`](https://github.com/horizon-rust/horizon/commit/50cd60645b668f4da113d8d1c634e71de15fce22) feat(mods): content mods declare their own mob effects - [`a49b9a6`](https://github.com/horizon-rust/horizon/commit/a49b9a6b88ad1043c6aa8e984d88415a36f7eac9) Address review: simplify mob_effect_id, read effects through Builtin::parse, test command-registries, docs - [`27c38eb`](https://github.com/horizon-rust/horizon/commit/27c38eb27b070386f8f51cba3466686fde2bc6cc) Merge hr/main into feat/mod-mob-effects ### 📊 Changes **22 files changed** (+481 additions, -62 deletions) <details> <summary>View changed files</summary> 📝 `crates/cargo-horizon-mod/template/content/horizon-mod.toml` (+2 -2) 📝 `crates/horizon-client-core/src/potions.rs` (+83 -4) 📝 `crates/horizon-client-render/src/brewing.rs` (+3 -4) 📝 `crates/horizon-client-render/src/effects.rs` (+27 -2) 📝 `crates/horizon-client-render/src/hud_overlays.rs` (+1 -1) 📝 `crates/horizon-client-render/src/inventory_effects.rs` (+1 -1) 📝 `crates/horizon-client/src/content_identity.rs` (+59 -4) 📝 `crates/horizon-client/src/entity_nbt.rs` (+31 -0) 📝 `crates/horizon-client/src/game/advancements.rs` (+4 -1) 📝 `crates/horizon-client/src/game/chat.rs` (+2 -3) 📝 `crates/horizon-client/src/game/commands/effects.rs` (+1 -1) 📝 `crates/horizon-client/src/game/mods.rs` (+29 -0) 📝 `crates/horizon-client/src/game/potions.rs` (+2 -15) 📝 `crates/horizon-client/src/lan/hub.rs` (+2 -2) 📝 `crates/horizon-client/src/mod_content.rs` (+34 -6) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+82 -2) 📝 `crates/horizon-mods/src/content.rs` (+92 -4) 📝 `crates/horizon-mods/src/manifest.rs` (+3 -3) 📝 `docs/api/data-formats.md` (+1 -0) 📝 `docs/api/stability.md` (+1 -1) _...and 2 more files_ </details> ### 📄 Description ## What and why Content mods can add blocks and items but not mob effects, so a mod's food, potion or weapon can only give vanilla ones A mod declares an effect in `data/<id>/horizon/mob_effect/<name>.json`, with what vanilla's `MobEffect` takes ```json { "category": "harmful", "color": 9154528 } ``` It gets a `minecraft:mob_effect` network id after vanilla's, `/effect give @s <id>:<name>` works, players and mobs keep it in their saves, and its name comes from the mod's lang (`effect.<id>.<name>`) Same on the server thread, LAN and dedicated servers A client with a different set of mod effects is refused when it joins, as with mod blocks, instead of reading the wrong effect The list is fixed when the game starts, a mod switched on later logs that a restart is needed No icon yet, the HUD shows the effect's frame and the inventory its frame and name (icons come in the next PR) No behaviour of its own yet either, that needs hook points Nothing changes without a mod that declares an effect, and vanilla effect lookups take the same time as before (timed, within noise) ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `MobEffect(MobEffectCategory, int color)` (`world/effect/MobEffect.java:55`) The name key is `Util.makeDescriptionId("effect", id)` (`MobEffect.java:114-118`, `util/Util.java:162-164`) ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 21 files, +461 −48 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (54 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (2 min 23 s) | | tests: cargo-horizon-mod, horizon-client, horizon-client-core, horizon-client-render, horizon-mods | ✅ 1958 passed (6 min 34 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ✅ 7 passed (1 min 10 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ (1 min 23 s) | | launcher tests | ✅ 300 passed (2 min 34 s) | | 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) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:41 +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#5887
No description provided.