[PR #3965] [MERGED] Entity shadows follow the entity's scale and age #5325

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3965
Author: @GIGABAIT93
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix/shadow-scale


📝 Commits (1)

  • d7f9535 Entity shadows follow the entity's scale and age

📊 Changes

2 files changed (+114 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+8 -5)
📝 crates/horizon-client/src/shadows.rs (+106 -5)

📄 Description

🤖 Opened by GIGABAIT93's AI agent (Claude Code, Claude Opus 5.5), not by GIGABAIT93 directly.

What and why

Entity shadows always had the type's radius from shadow_params. Vanilla sizes a living entity's shadow with the entity. So a 2× mannequin kept a 1× shadow, and a baby villager cast a full-sized one.

  • mob_shadow_radius (shadows.rs) follows vanilla's getShadowRadius chain for living entities:
    • LivingEntityRenderer: the type's radius × minecraft:scale (extra.model_scale). Players and mannequins (AvatarRenderer) stop here.
    • MobRenderer: × LivingEntity.getAgeScale. That is 0.5 for a baby, or the species' own value: armadillo and camel 0.6, dolphin 0.65, goat 0.55, happy ghast 0.2375, turtle 0.3.
    • VillagerRenderer and StriderRenderer halve a baby's shadow again, and TurtleRenderer takes 0.83 of it. A baby villager's shadow is 0.5 × 0.5 × 0.5 = 0.125.
    • AbstractCubeMobRenderer (slime, magma cube, sulfur cube) returns size * 0.25, and PufferfishRenderer returns 0.1 + 0.1 * puffState. Neither applies scale or age. Until now they had a fixed 0.25 and 0.2.
  • mob_casters now yields each mob's radius. Items and experience orbs aren't living, so they keep their fixed radius.

extra.model_scale is set for the local player's own model and, with #3922, for other players and mannequins from their attribute updates. No other mob carries a scale on the client yet, so for them only the age part changes. The local player casts no shadow in Horizon today: the casters are self.mobs, dropped items and orbs, and the player's own model isn't among them. So this change doesn't reach 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

Checked with javap -c against the 26.3 client jar:

  • LivingEntityRenderer.getShadowRadius(LivingEntityRenderState): super.getShadowRadius(state) * state.scale. extractRenderState sets state.scale = LivingEntity.getScale(), which is the minecraft:scale attribute through sanitizeScale, with no age in it, and state.ageScale = getAgeScale().
  • MobRenderer.getShadowRadius: super.getShadowRadius(state) * state.ageScale. AvatarRenderer and ArmorStandRenderer are LivingEntityRenderers but not MobRenderers.
  • LivingEntity.getAgeScale: isBaby() ? 0.5 : 1. Overridden by Armadillo, Camel (and CamelHusk), Dolphin, Goat, HappyGhast and Turtle with the values above.
  • VillagerRenderer, StriderRenderer: isBaby ? r * 0.5 : r. TurtleRenderer: isBaby ? r * 0.83 : r.
  • AbstractCubeMobRenderer: size * 0.25. PufferfishRenderer: 0.1 + 0.1 * puffState.

No harness covers entity shadows. New unit tests in shadows.rs:

  • babies_cast_their_age_scaled_shadow: a calf, a baby villager (0.125), a kid goat.
  • scaled_players_cast_a_scaled_shadow: a 2× player, a 0.25× mannequin, and no age scale for avatars.
  • sized_mobs_keep_their_own_radius: a size-4 slime ignores its scale, and a puffed pufferfish.
  • items_and_orbs_keep_their_radius: the non-living radii.
  • invisible_mobs_cast_no_shadow: now checks the cow's radius too.

Self-check

Run on Linux (WSL Ubuntu 22.04):

pr_ready (tools/pr_ready.py --quick --base upstream/main on GIGABAIT, against upstream/main at 5b1d64d4f, 4 min 28 s)

Check Result
Scope ✅ 2 files, +114 −10
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 474 passed (49 s)
rustfmt ✅ (11 s)
clippy ✅ (1 min 51 s)
tests: horizon-client ✅ 871 passed (1 min 34 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
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)

Screenshots

Windows 11, single player on the server thread, --offscreen --control-socket driven by horizon-ctl, in a fresh HORIZON_HOME. A mannequin's scale reaches its client only through #3922, so both builds are main (5b1d64d4f) with #3922 merged in. before is that build, after adds this branch's commit.

The scene, facing south, so +X is on the left:

  • x = 4.5: a mannequin.
  • x = 1.5: a mannequin with /attribute @e[type=mannequin,limit=1] minecraft:scale base set 2.
  • x = −1.5: a baby villager.
  • x = −3.5: an adult villager.

The baby villager comes from horizon-ctl summon minecraft:villager … baby, in the window's own entities. A server villager given Age:-24000 (by /summon or /data merge) still reaches the client as an adult on main. That is a separate bug, noted below.

before after
before after
The 2× mannequin and the baby villager have the same shadow as their 1× and adult neighbours. The 2× mannequin's shadow is twice as wide. The baby villager's shadow shrinks to a quarter of the adult's radius, under its feet.
before, looking down after, looking down
Closer, looking down at the feet. The 2× mannequin's shadow covers about two blocks.

Not in this PR:

  • The local player's own shadow: its model isn't a caster, so it has none even in third person, where vanilla draws one.
  • A server villager given Age:-24000 by /summon or /data merge entity stays an adult on its client. The server holds the age (/data get reads −24000), but the client's baby flag stays false, even after the entity is tracked again.

🤖 Generated with Claude Code


🔄 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/3965 **Author:** [@GIGABAIT93](https://github.com/GIGABAIT93) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/shadow-scale` --- ### 📝 Commits (1) - [`d7f9535`](https://github.com/horizon-rust/horizon/commit/d7f953540637d2e40d0aa5e50d3ee54bcfc329da) Entity shadows follow the entity's scale and age ### 📊 Changes **2 files changed** (+114 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+8 -5) 📝 `crates/horizon-client/src/shadows.rs` (+106 -5) </details> ### 📄 Description > 🤖 Opened by GIGABAIT93's AI agent (Claude Code, Claude Opus 5.5), not by GIGABAIT93 directly. ## What and why Entity shadows always had the type's radius from `shadow_params`. Vanilla sizes a living entity's shadow with the entity. So a 2× mannequin kept a 1× shadow, and a baby villager cast a full-sized one. - `mob_shadow_radius` (`shadows.rs`) follows vanilla's `getShadowRadius` chain for living entities: - `LivingEntityRenderer`: the type's radius × `minecraft:scale` (`extra.model_scale`). Players and mannequins (`AvatarRenderer`) stop here. - `MobRenderer`: × `LivingEntity.getAgeScale`. That is 0.5 for a baby, or the species' own value: armadillo and camel 0.6, dolphin 0.65, goat 0.55, happy ghast 0.2375, turtle 0.3. - `VillagerRenderer` and `StriderRenderer` halve a baby's shadow again, and `TurtleRenderer` takes 0.83 of it. A baby villager's shadow is 0.5 × 0.5 × 0.5 = 0.125. - `AbstractCubeMobRenderer` (slime, magma cube, sulfur cube) returns `size * 0.25`, and `PufferfishRenderer` returns `0.1 + 0.1 * puffState`. Neither applies scale or age. Until now they had a fixed 0.25 and 0.2. - `mob_casters` now yields each mob's radius. Items and experience orbs aren't living, so they keep their fixed radius. `extra.model_scale` is set for the local player's own model and, with #3922, for other players and mannequins from their attribute updates. No other mob carries a scale on the client yet, so for them only the age part changes. The local player casts no shadow in Horizon today: the casters are `self.mobs`, dropped items and orbs, and the player's own model isn't among them. So this change doesn't reach it. ## Kind - [x] 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 Checked with `javap -c` against the 26.3 client jar: - `LivingEntityRenderer.getShadowRadius(LivingEntityRenderState)`: `super.getShadowRadius(state) * state.scale`. `extractRenderState` sets `state.scale = LivingEntity.getScale()`, which is the `minecraft:scale` attribute through `sanitizeScale`, with no age in it, and `state.ageScale = getAgeScale()`. - `MobRenderer.getShadowRadius`: `super.getShadowRadius(state) * state.ageScale`. `AvatarRenderer` and `ArmorStandRenderer` are `LivingEntityRenderer`s but not `MobRenderer`s. - `LivingEntity.getAgeScale`: `isBaby() ? 0.5 : 1`. Overridden by `Armadillo`, `Camel` (and `CamelHusk`), `Dolphin`, `Goat`, `HappyGhast` and `Turtle` with the values above. - `VillagerRenderer`, `StriderRenderer`: `isBaby ? r * 0.5 : r`. `TurtleRenderer`: `isBaby ? r * 0.83 : r`. - `AbstractCubeMobRenderer`: `size * 0.25`. `PufferfishRenderer`: `0.1 + 0.1 * puffState`. No harness covers entity shadows. New unit tests in `shadows.rs`: - `babies_cast_their_age_scaled_shadow`: a calf, a baby villager (0.125), a kid goat. - `scaled_players_cast_a_scaled_shadow`: a 2× player, a 0.25× mannequin, and no age scale for avatars. - `sized_mobs_keep_their_own_radius`: a size-4 slime ignores its scale, and a puffed pufferfish. - `items_and_orbs_keep_their_radius`: the non-living radii. - `invisible_mobs_cast_no_shadow`: now checks the cow's radius too. ## Self-check Run on Linux (WSL Ubuntu 22.04): **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on GIGABAIT, against upstream/main at 5b1d64d4f, 4 min 28 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +114 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 474 passed (49 s) | | rustfmt | ✅ (11 s) | | clippy | ✅ (1 min 51 s) | | tests: horizon-client | ✅ 871 passed (1 min 34 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | 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) | ## Screenshots Windows 11, single player on the server thread, `--offscreen --control-socket` driven by `horizon-ctl`, in a fresh `HORIZON_HOME`. A mannequin's scale reaches its client only through #3922, so both builds are main (`5b1d64d4f`) with #3922 merged in. `before` is that build, `after` adds this branch's commit. The scene, facing south, so +X is on the left: - x = 4.5: a mannequin. - x = 1.5: a mannequin with `/attribute @e[type=mannequin,limit=1] minecraft:scale base set 2`. - x = −1.5: a baby villager. - x = −3.5: an adult villager. The baby villager comes from `horizon-ctl summon minecraft:villager … baby`, in the window's own entities. A server villager given `Age:-24000` (by `/summon` or `/data merge`) still reaches the client as an adult on main. That is a separate bug, noted below. | before | after | | --- | --- | | ![before](https://github.com/GIGABAIT93/horizon/releases/download/proof-shadow-scale/shadow-before.png) | ![after](https://github.com/GIGABAIT93/horizon/releases/download/proof-shadow-scale/shadow-after.png) | | The 2× mannequin and the baby villager have the same shadow as their 1× and adult neighbours. | The 2× mannequin's shadow is twice as wide. The baby villager's shadow shrinks to a quarter of the adult's radius, under its feet. | | ![before, looking down](https://github.com/GIGABAIT93/horizon/releases/download/proof-shadow-scale/shadow-before-down.png) | ![after, looking down](https://github.com/GIGABAIT93/horizon/releases/download/proof-shadow-scale/shadow-after-down.png) | | Closer, looking down at the feet. | The 2× mannequin's shadow covers about two blocks. | Not in this PR: - The local player's own shadow: its model isn't a caster, so it has none even in third person, where vanilla draws one. - A server villager given `Age:-24000` by `/summon` or `/data merge entity` stays an adult on its client. The server holds the age (`/data get` reads −24000), but the client's baby flag stays false, even after the entity is tracked again. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:49 +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#5325
No description provided.