[GH-ISSUE #6276] Native mods: an entity's size, EntityEvent.Size (design needed, not claimed) #2042

Open
opened 2026-11-02 15:51:34 +07:00 by bsakaguchi · 0 comments
Owner

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

🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally.

Part of #4953 ("Entity: tick, mount, size, projectile impact").

A native mod that makes an entity bigger or smaller (a giant zombie, a shrunk player, a taller boat) has no way to change the size Horizon uses for its collision box, eye height and pickup range. This is the one item of the tracker line that needs a decision before code, so this issue lays out what is needed and what I recommend. It is not claimed.

Vanilla and NeoForge 26.3:

  • Vanilla Entity.refreshDimensions() recomputes dimensions from getDimensions(pose) and stores it (dimensions, eyeHeight), then repositions the box around the entity (reapplyPosition). It runs at construction, on a pose change, a scale attribute change, a baby/age change, and so on. The size is a cached field.
  • NeoForge posts EntityEvent.Size (not cancellable) from refreshDimensions (and once at construction) with the pose, the old size and the new size; a handler calls setNewSize and the stored dimensions is the handler's result. Because it is stored, a mod's size holds until the next refresh.

What Horizon has:

  • Only the player has the same shape: PlayerMotion.refresh_dimensions (pose.rs) stores PlayerMotion.dimensions from pose.dimensions(scale), and a guest's dimensions() reads that. PlayerMotion is in the client lib, below Game, so it can't call a native_ hook itself.
  • A mob has no stored size: Mob::dims() (mobs/living.rs) recomputes it from the species, baby, pufferfish/slime/phantom size, goat jump, camel sitting, warden digging and so on every call, and width(), height() and eye_height() are called from about 50 files (physics, AI, pathing, rendering, damage). There is no refresh point, no pose for mobs, and no &mut Game in those callers.
  • Boats, carts, items, projectiles and arrows each have a fixed size in their own code (arrows.rs width(), boats, carts...).

So EntityEvent.Size can't be ported as an event at one refresh point for all entities; it would be a new cached dimensions on each kind, with a refresh at every place the inputs change.

Options:

  1. Player only (recommended first step). Add native_player_dimensions(dimensions of the player, pose, width, height, eye_height) as a mod-settable override, called by the server after a player's refresh_dimensions and stored beside PlayerMotion.dimensions, so the collision box, eye height and reach follow it for the server and for the client prediction (the size would have to be sent: the client predicts movement with its own box, so a mod's size has to reach it, or the client mismatches and rubber-bands). Small, self-contained, and it is what mods ask for most (shrink or grow a player).
  2. Mobs: store dims on the mob, refresh it when baby/size/pose-like state changes (the inputs of dims() are few and known), and call the hook there. Medium: dims() has about 50 callers but they would read a field instead of calling a function, so they need no change; the refresh points are the work. Rendering scale must follow.
  3. Everything else (boats, carts, items, projectiles): each needs its own cached size first. Last, and probably not worth it.

Open questions for the maintainers: whether a size override must reach clients (and by which packet: vanilla syncs size only through the scale attribute, so a size set by a mod that is not a scale change has no vanilla way to reach a client, and the alternative is a mod setting the scale attribute instead, which Horizon already supports); and whether option 1 should wait for a registry-style "attribute modifiers from mods" API, which would cover growing and shrinking without an event. If the answer to the second is yes, EntityEvent.Size may be better skipped from the tracker in favour of that API.

Originally created by @levzzz5154 on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6276 > 🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #4953 ("Entity: tick, mount, size, projectile impact"). A native mod that makes an entity bigger or smaller (a giant zombie, a shrunk player, a taller boat) has no way to change the size Horizon uses for its collision box, eye height and pickup range. This is the one item of the tracker line that needs a decision before code, so this issue lays out what is needed and what I recommend. It is not claimed. Vanilla and NeoForge 26.3: - Vanilla `Entity.refreshDimensions()` recomputes `dimensions` from `getDimensions(pose)` and stores it (`dimensions`, `eyeHeight`), then repositions the box around the entity (`reapplyPosition`). It runs at construction, on a pose change, a `scale` attribute change, a baby/age change, and so on. The size is a cached field. - NeoForge posts `EntityEvent.Size` (not cancellable) from `refreshDimensions` (and once at construction) with the pose, the old size and the new size; a handler calls `setNewSize` and the stored `dimensions` is the handler's result. Because it is stored, a mod's size holds until the next refresh. What Horizon has: - Only the player has the same shape: `PlayerMotion.refresh_dimensions` (`pose.rs`) stores `PlayerMotion.dimensions` from `pose.dimensions(scale)`, and a guest's `dimensions()` reads that. `PlayerMotion` is in the client lib, below `Game`, so it can't call a `native_` hook itself. - A mob has no stored size: `Mob::dims()` (`mobs/living.rs`) recomputes it from the species, baby, pufferfish/slime/phantom size, goat jump, camel sitting, warden digging and so on every call, and `width()`, `height()` and `eye_height()` are called from about 50 files (physics, AI, pathing, rendering, damage). There is no refresh point, no pose for mobs, and no `&mut Game` in those callers. - Boats, carts, items, projectiles and arrows each have a fixed size in their own code (`arrows.rs` `width()`, boats, carts...). So `EntityEvent.Size` can't be ported as an event at one refresh point for all entities; it would be a new cached `dimensions` on each kind, with a refresh at every place the inputs change. Options: 1. Player only (recommended first step). Add `native_player_dimensions(dimensions of the player, pose, width, height, eye_height)` as a mod-settable override, called by the server after a player's `refresh_dimensions` and stored beside `PlayerMotion.dimensions`, so the collision box, eye height and reach follow it for the server and for the client prediction (the size would have to be sent: the client predicts movement with its own box, so a mod's size has to reach it, or the client mismatches and rubber-bands). Small, self-contained, and it is what mods ask for most (shrink or grow a player). 2. Mobs: store `dims` on the mob, refresh it when baby/size/pose-like state changes (the inputs of `dims()` are few and known), and call the hook there. Medium: `dims()` has about 50 callers but they would read a field instead of calling a function, so they need no change; the refresh points are the work. Rendering scale must follow. 3. Everything else (boats, carts, items, projectiles): each needs its own cached size first. Last, and probably not worth it. Open questions for the maintainers: whether a size override must reach clients (and by which packet: vanilla syncs size only through the `scale` attribute, so a size set by a mod that is not a `scale` change has no vanilla way to reach a client, and the alternative is a mod setting the `scale` attribute instead, which Horizon already supports); and whether option 1 should wait for a registry-style "attribute modifiers from mods" API, which would cover growing and shrinking without an event. If the answer to the second is yes, `EntityEvent.Size` may be better skipped from the tracker in favour of that API.
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#2042
No description provided.