[PR #2736] [MERGED] Add a regression test for the entity draw distance #4577

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2736
Author: @levzzz5154
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

Base: main ← Head: fix/2273-entity-view-scale


📝 Commits (1)

  • fa940d5 Add a regression test for the entity draw distance

📊 Changes

1 file changed (+47 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/entity_culling.rs (+47 -1)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself.

What and why

Issue #2273 reports that chickens vanish sooner than other mobs: a chicken disappears at about 32 blocks while the other mobs stay. The cause is the entity draw distance, not the despawn distance: vanilla multiplies the entity's bounding box by a "view scale" before it is compared with the camera distance, and Horizon dropped that factor, so every small mob was drawn a third of the way too near.

The behavioural fix for #2273 landed upstream in #2317 ("Apply vanilla's view scale to entity render distance"), which closed the issue: Game::view_scale() and default_range() now apply vanilla's factor. That pull request carried no test, so this one adds the missing regression test. The view scale formula moves into a free function (entity_view_scale) that the test can call, and the draw distance of a chicken, of a broken bounding box and of every render distance is pinned. Without the fix the chicken test fails with left: 32.0, right: 48.0 — the exact 32 blocks the reporter measured.

Fixes #2273

Vanilla reference

  • net.minecraft.world.entity.Entity#shouldRenderAtSqrDistance(double): the squared camera distance is compared with (size * 64 * viewScale)², where size is the bounding box's size and a NaN size falls back to 1.0.
  • net.minecraft.world.phys.AABB#getSize(): the mean of the three edge lengths. A chicken's 0.4 × 0.7 × 0.4 box gives 0.5, so 0.5 × 64 = 32 blocks, and with the view scale of 1.5 at twelve chunks, 48 blocks.
  • net.minecraft.world.entity.Entity#setViewScale(double) and net.minecraft.client.renderer.extract.LevelExtractor#extractVisibleEntities: before drawing the entities the client sets the view scale to Mth.clamp(options.getEffectiveRenderDistance() / 8.0, 1.0, 2.5) * options.entityDistanceScaling().get().
  • net.minecraft.client.Options#getEffectiveRenderDistance(): the client render distance, capped by the server's view distance when connected.
  • net.minecraft.client.player.RemotePlayer#shouldRenderAtSqrDistance(double): a remote player uses ten times the box size, so other players are drawn much further away.

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on cachyos-x8664, against upstream/main at 9c62aba38, 5 min 9 s)

Check Result
Scope ✅ 1 files, +47 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 331 passed (17 s)
rustfmt ✅ (4 s)
clippy ✅ (1 min 20 s)
tests: horizon-client ✅ 1326 passed (2 min 44 s)
doc tests ✅ 0 passed (35 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 ➖ 34 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 22 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • cargo test -p horizon-client --bin horizon-client -- game::entity_culling::tests → 3 passed; 0 failed.
  • The same command with the view scale dropped from entity_view_scale → 3 failed; 0 passed: the chicken with left: 32.0, right: 48.0 and the broken box with left: 64.0, right: 96.0.
  • cargo test -p horizon-client --bin horizon-client → 130 passed; 0 failed; 3 ignored.
  • cargo fmt -p horizon-client -- --check → clean.
  • cargo build -p horizon-client --bin horizon-client → finished.

🤖 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/2736 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/2273-entity-view-scale` --- ### 📝 Commits (1) - [`fa940d5`](https://github.com/horizon-rust/horizon/commit/fa940d5b6b6f5d0d88b431ab8496376ec3adf326) Add a regression test for the entity draw distance ### 📊 Changes **1 file changed** (+47 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/entity_culling.rs` (+47 -1) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself. ## What and why Issue #2273 reports that chickens vanish sooner than other mobs: a chicken disappears at about 32 blocks while the other mobs stay. The cause is the entity *draw* distance, not the despawn distance: vanilla multiplies the entity's bounding box by a "view scale" before it is compared with the camera distance, and Horizon dropped that factor, so every small mob was drawn a third of the way too near. The behavioural fix for #2273 landed upstream in #2317 ("Apply vanilla's view scale to entity render distance"), which closed the issue: `Game::view_scale()` and `default_range()` now apply vanilla's factor. That pull request carried no test, so this one adds the missing regression test. The view scale formula moves into a free function (`entity_view_scale`) that the test can call, and the draw distance of a chicken, of a broken bounding box and of every render distance is pinned. Without the fix the chicken test fails with `left: 32.0, right: 48.0` — the exact 32 blocks the reporter measured. Fixes #2273 ## Vanilla reference - `net.minecraft.world.entity.Entity#shouldRenderAtSqrDistance(double)`: the squared camera distance is compared with `(size * 64 * viewScale)²`, where `size` is the bounding box's size and a NaN size falls back to 1.0. - `net.minecraft.world.phys.AABB#getSize()`: the mean of the three edge lengths. A chicken's 0.4 × 0.7 × 0.4 box gives 0.5, so 0.5 × 64 = 32 blocks, and with the view scale of 1.5 at twelve chunks, 48 blocks. - `net.minecraft.world.entity.Entity#setViewScale(double)` and `net.minecraft.client.renderer.extract.LevelExtractor#extractVisibleEntities`: before drawing the entities the client sets the view scale to `Mth.clamp(options.getEffectiveRenderDistance() / 8.0, 1.0, 2.5) * options.entityDistanceScaling().get()`. - `net.minecraft.client.Options#getEffectiveRenderDistance()`: the client render distance, capped by the server's view distance when connected. - `net.minecraft.client.player.RemotePlayer#shouldRenderAtSqrDistance(double)`: a remote player uses ten times the box size, so other players are drawn much further away. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on cachyos-x8664, against upstream/main at 9c62aba38, 5 min 9 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +47 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 331 passed (17 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (1 min 20 s) | | tests: horizon-client | ✅ 1326 passed (2 min 44 s) | | doc tests | ✅ 0 passed (35 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 | ➖ 34 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 22 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - `cargo test -p horizon-client --bin horizon-client -- game::entity_culling::tests` → 3 passed; 0 failed. - The same command with the view scale dropped from `entity_view_scale` → 3 failed; 0 passed: the chicken with `left: 32.0, right: 48.0` and the broken box with `left: 64.0, right: 96.0`. - `cargo test -p horizon-client --bin horizon-client` → 130 passed; 0 failed; 3 ignored. - `cargo fmt -p horizon-client -- --check` → clean. - `cargo build -p horizon-client --bin horizon-client` → finished. 🤖 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 04:18:11 +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#4577
No description provided.