[PR #5564] [MERGED] feat(mods): content mods declare their own thrown entity types #6355

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

📋 Pull Request Information

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

Base: main ← Head: feat/content-entity-types


📝 Commits (1)

  • 88d6988 feat(mods): content mods declare their own thrown entity types

📊 Changes

16 files changed (+469 additions, -48 deletions)

View changed files

📝 crates/horizon-client/src/content_identity.rs (+7 -3)
📝 crates/horizon-client/src/game/creatures.rs (+54 -5)
📝 crates/horizon-client/src/game/debug_keys.rs (+6 -3)
📝 crates/horizon-client/src/game/lan_pvp.rs (+7 -3)
📝 crates/horizon-client/src/game/mods.rs (+22 -0)
📝 crates/horizon-client/src/game/remote.rs (+1 -0)
📝 crates/horizon-client/src/game/remote_projectiles.rs (+1 -1)
📝 crates/horizon-client/src/lan/tracking.rs (+8 -6)
📝 crates/horizon-client/src/mod_content.rs (+37 -10)
📝 crates/horizon-client/src/mod_content_tests.rs (+52 -0)
📝 crates/horizon-client/src/projectiles.rs (+118 -7)
📝 crates/horizon-mods/src/content.rs (+130 -4)
📝 crates/horizon-mods/src/manifest.rs (+3 -1)
📝 docs/api/stability.md (+1 -1)
📝 docs/modpacks.md (+1 -1)
📝 docs/mods.md (+21 -3)

📄 Description

What and why

Part of #5212

Content mods need their own entity types, and a thrown item projectile is the first one they ask for
A content mod now declares one in data/<id>/horizon/entity_type/<name>.json:

{ "template": "minecraft:snowball", "item": "example:gem", "damage": 2.0 }

template is minecraft:snowball only for now
item is one of the mod's own items, and one item throws one type
So no vanilla item loses its own use to a mod type
damage is optional (0 by default) and is dealt to anything it hits as thrown damage from the thrower
The snowball's 3 damage to blazes is not copied
Unknown keys, another template, a vanilla or unknown item, an item two types share and a negative damage are refused at load

The type <id>:<name> gets a network id after vanilla's, in id order, in registries.json
The server's tracker and a Horizon client map it through that report, as with mod mob effects
It also joins command-registries.json (entity_types and the minecraft:entity_type ids)
The content identity now covers minecraft:entity_type, so two Horizons with different mod types refuse to join

Using its item throws it as SnowballItem.use does: sound, shootFromRotation(0, 1.5, 1.0), the use_cooldown side effect, and one item used outside creative
It flies with ThrowableProjectile's gravity and inertia, and its box and tracking settings are the snowball's
A hit on a mob goes through damage_projectile (knockback along its flight), and the thrower gets the kill and player_hurt_entity
A player takes its damage too, but no 0 damage
Then it sends entity event 3 and is removed
The crumbs are the type's item, at rest, as Snowball.handleEntityEvent does
It breaks what impact projectiles break (chorus flowers, decorated pots, pointed dripstone), as the snowball it copies does
The client draws it with its item's model in the GROUND context, turned to the camera (ThrownItemRenderer)
So the mod declares no renderer: its item model is what flies

Tests: the declaration and its refusals, the registry ids in a full content root, the identity, the template's tracking settings, and a mod type that flies tick for tick as a snowball, then hits a mob's box and is gone
The hit itself runs on Game, which no unit test can build, so it was checked in real games with a small test mod (a mod item and a type with 4 damage):
Server thread (default): the bolt is tracked and drawn in flight, the item count goes down, three hits kill a pig
In-frame (--in-frame): the pig goes 10, 6, 2, then dies
LAN between two Horizons with the mod: a guest's bolts take a pig 10, 6, 2, then kill it, and the kill counts for the guest
Dedicated servers share the LAN code, untested

Without a mod nothing new runs per tick
The new arms only match ProjectileKind::Thrown, which only a mod creates
The lookups by item and by id are #[cold] and only run on an item use, a client spawn of an unknown type, and a tracker miss

Left as is: a thrown mod projectile is not saved, as vanilla snowballs are not saved yet
Left as is: /summon doesn't know the type, and it has no entity-types.json row (execute anchored eyes, spawner type checks)
Left as is: DATA_ITEM_STACK is not sent, so a renamed or changed stack draws as the declared item
Left as is: a vanilla client on a server with a mod type may be disconnected when one spawns (unknown registry id)
Left as is: a dispenser doesn't throw it
Left as is: the throw awards no used stat, as snowballs on main don't
Left as is: no hooks yet (hit, tick)
Left as is: a mod's block item can be the item, so clicking a block places it and using it in the air throws it

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

world/item/SnowballItem.java:24-43 (use: sound, spawnProjectileFromRotation(.., 0.0F, 1.5F, 1.0F), consume(1))
world/entity/projectile/throwableitemprojectile/Snowball.java:45-71 (event 3 crumbs of its item, thrown damage, discard on any hit)
world/entity/projectile/ThrowableProjectile.java:44-62 (gravity, inertia, hit)
world/entity/EntityTypes.java:917-920 (SNOWBALL: sized(0.25F, 0.25F).clientTrackingRange(4).updateInterval(10))
world/damagesource/DamageSources.java:239-240 (thrown(entity, owner))
world/entity/player/Player.java:695 (no 0 damage)
client/renderer/entity/ThrownItemRenderer.java:35-53 and client/renderer/entity/EntityRenderers.java:219

Other projects' code

none

Self-check

The 13 failures are all in tests/lan_bot.rs
They fail on main too with prepared data (since #4698)
The launcher failure is a_replaced_binary_is_replaced_again_at_its_path (launcher/src/backend.rs)
It fails on main too with prepared data

Check Result
Scope ✅ 16 files, +469 −48
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 510 passed (1 min 3 s)
rustfmt ✅ (9 s)
clippy ✅ (1 min 53 s)
tests: horizon-client, horizon-mods ❌ 1558 passed, 13 failed (5 min 35 s)
doc tests ✅ 0 passed (2 s)
content root tests ✅ 16 passed (1 min 17 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅ (1 min 11 s)
launcher tests ❌ 340 passed, 1 failed (2 min 18 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/5564 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/content-entity-types` --- ### 📝 Commits (1) - [`88d6988`](https://github.com/horizon-rust/horizon/commit/88d6988d8e8fdaed7f39f8c3ce3bdd5be5607cde) feat(mods): content mods declare their own thrown entity types ### 📊 Changes **16 files changed** (+469 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/content_identity.rs` (+7 -3) 📝 `crates/horizon-client/src/game/creatures.rs` (+54 -5) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+6 -3) 📝 `crates/horizon-client/src/game/lan_pvp.rs` (+7 -3) 📝 `crates/horizon-client/src/game/mods.rs` (+22 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -0) 📝 `crates/horizon-client/src/game/remote_projectiles.rs` (+1 -1) 📝 `crates/horizon-client/src/lan/tracking.rs` (+8 -6) 📝 `crates/horizon-client/src/mod_content.rs` (+37 -10) 📝 `crates/horizon-client/src/mod_content_tests.rs` (+52 -0) 📝 `crates/horizon-client/src/projectiles.rs` (+118 -7) 📝 `crates/horizon-mods/src/content.rs` (+130 -4) 📝 `crates/horizon-mods/src/manifest.rs` (+3 -1) 📝 `docs/api/stability.md` (+1 -1) 📝 `docs/modpacks.md` (+1 -1) 📝 `docs/mods.md` (+21 -3) </details> ### 📄 Description ## What and why Part of #5212 Content mods need their own entity types, and a thrown item projectile is the first one they ask for A content mod now declares one in `data/<id>/horizon/entity_type/<name>.json`: ```json { "template": "minecraft:snowball", "item": "example:gem", "damage": 2.0 } ``` `template` is `minecraft:snowball` only for now `item` is one of the mod's own items, and one item throws one type So no vanilla item loses its own use to a mod type `damage` is optional (0 by default) and is dealt to anything it hits as `thrown` damage from the thrower The snowball's 3 damage to blazes is not copied Unknown keys, another template, a vanilla or unknown item, an item two types share and a negative damage are refused at load The type `<id>:<name>` gets a network id after vanilla's, in id order, in `registries.json` The server's tracker and a Horizon client map it through that report, as with mod mob effects It also joins `command-registries.json` (`entity_types` and the `minecraft:entity_type` ids) The content identity now covers `minecraft:entity_type`, so two Horizons with different mod types refuse to join Using its item throws it as `SnowballItem.use` does: sound, `shootFromRotation(0, 1.5, 1.0)`, the `use_cooldown` side effect, and one item used outside creative It flies with `ThrowableProjectile`'s gravity and inertia, and its box and tracking settings are the snowball's A hit on a mob goes through `damage_projectile` (knockback along its flight), and the thrower gets the kill and `player_hurt_entity` A player takes its damage too, but no 0 damage Then it sends entity event 3 and is removed The crumbs are the type's item, at rest, as `Snowball.handleEntityEvent` does It breaks what impact projectiles break (chorus flowers, decorated pots, pointed dripstone), as the snowball it copies does The client draws it with its item's model in the `GROUND` context, turned to the camera (`ThrownItemRenderer`) So the mod declares no renderer: its item model is what flies Tests: the declaration and its refusals, the registry ids in a full content root, the identity, the template's tracking settings, and a mod type that flies tick for tick as a snowball, then hits a mob's box and is gone The hit itself runs on `Game`, which no unit test can build, so it was checked in real games with a small test mod (a mod item and a type with 4 damage): Server thread (default): the bolt is tracked and drawn in flight, the item count goes down, three hits kill a pig In-frame (`--in-frame`): the pig goes 10, 6, 2, then dies LAN between two Horizons with the mod: a guest's bolts take a pig 10, 6, 2, then kill it, and the kill counts for the guest Dedicated servers share the LAN code, untested Without a mod nothing new runs per tick The new arms only match `ProjectileKind::Thrown`, which only a mod creates The lookups by item and by id are `#[cold]` and only run on an item use, a client spawn of an unknown type, and a tracker miss Left as is: a thrown mod projectile is not saved, as vanilla snowballs are not saved yet Left as is: `/summon` doesn't know the type, and it has no `entity-types.json` row (`execute anchored eyes`, spawner type checks) Left as is: `DATA_ITEM_STACK` is not sent, so a renamed or changed stack draws as the declared item Left as is: a vanilla client on a server with a mod type may be disconnected when one spawns (unknown registry id) Left as is: a dispenser doesn't throw it Left as is: the throw awards no `used` stat, as snowballs on `main` don't Left as is: no hooks yet (hit, tick) Left as is: a mod's block item can be the `item`, so clicking a block places it and using it in the air throws it ## 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 `world/item/SnowballItem.java:24-43` (`use`: sound, `spawnProjectileFromRotation(.., 0.0F, 1.5F, 1.0F)`, `consume(1)`) `world/entity/projectile/throwableitemprojectile/Snowball.java:45-71` (event 3 crumbs of its item, `thrown` damage, discard on any hit) `world/entity/projectile/ThrowableProjectile.java:44-62` (gravity, inertia, hit) `world/entity/EntityTypes.java:917-920` (`SNOWBALL`: `sized(0.25F, 0.25F).clientTrackingRange(4).updateInterval(10)`) `world/damagesource/DamageSources.java:239-240` (`thrown(entity, owner)`) `world/entity/player/Player.java:695` (no 0 damage) `client/renderer/entity/ThrownItemRenderer.java:35-53` and `client/renderer/entity/EntityRenderers.java:219` ## Other projects' code none ## Self-check The 13 failures are all in `tests/lan_bot.rs` They fail on `main` too with prepared data (since #4698) The launcher failure is `a_replaced_binary_is_replaced_again_at_its_path` (`launcher/src/backend.rs`) It fails on `main` too with prepared data | Check | Result | | --- | --- | | Scope | ✅ 16 files, +469 −48 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 510 passed (1 min 3 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 min 53 s) | | tests: horizon-client, horizon-mods | ❌ 1558 passed, 13 failed (5 min 35 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ✅ 16 passed (1 min 17 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ (1 min 11 s) | | launcher tests | ❌ 340 passed, 1 failed (2 min 18 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 06:19:08 +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#6355
No description provided.