[PR #4016] [MERGED] Thrown eggs and snowballs turn with the camera, no flip looking straight up #5358

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

📋 Pull Request Information

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

Base: main ← Head: fix-3393-eggs


📝 Commits (2)

  • 4b09c9d Thrown eggs and snowballs turn with the camera, no flip looking straight up
  • 71527fa Merge remote-tracking branch 'origin/main' into upd-4016

📊 Changes

2 files changed (+62 additions, -20 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+16 -12)
📝 crates/horizon-client/src/game/creatures.rs (+46 -8)

📄 Description

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

What and why

Part of #3393 ("When throwing eggs or snowballs straight upward (at a 90° angle), their texture flips upside down").

Item projectiles (eggs, snowballs, ender pearls, fireballs, llama spit) are drawn as a billboard. entity_geometry in game/creatures.rs built its axes as right = forward × Y and up = right × forward. At pitch exactly ±90, where look and the mouse clamp, forward is vertical. In f32, cos(90°) comes out slightly negative (-4.37e-8), so the horizontal part of forward points backwards. right then flips sign compared with pitch ±89.9, up flips with it, and the sprite turns 180°. The same basis ignored third-person front view, which showed the sprite mirrored.

Vanilla doesn't build a basis from the look vector at all: it rotates the item by the camera's orientation. The fix does the same:

  • camera_orientation's maths moves into a free camera_rotation(camera_type, yaw, pitch) in game.rs, and the method calls it (same result for its existing callers: potions, fireworks, the splash potion projectile).
  • thrown_item_axes takes the billboard's right and up axes from that quaternion (q * X, q * Y). This is the turned-round camera in front view and stays continuous through ±90.

Not changed here: the client still lets a summoned {NoGravity:1b} egg fall between server updates. I saw it while testing, but it's a separate bug.

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

  • net.minecraft.client.renderer.entity.ThrownItemRenderer.submit: PoseStack.scale(scale), then PoseStack.rotate(CameraRenderState.orientation), then ItemStackRenderState.submit. There is no look-vector cross product.
  • net.minecraft.client.Camera.setRotation(float, float): rotation.rotationYXZ(π - yRot·π/180, -xRot·π/180, 0). Camera.setup calls it with (yRot + 180, -xRot) when CameraType.isMirrored() (third-person front).
  • Read with javap -c -p on the 26.3 client jar. No parity harness covers entity billboards. The new unit tests check the axes against Camera.setRotation's orientation.

Self-check

tools/pr_ready.py doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test -p horizon-client --bin horizon-client -- thrown_item_billboard game::perspective: 7 passed, 1 ignored (it needs prepared model data)
  • New tests in game/creatures.rs:
    • thrown_item_billboard_does_not_flip_at_straight_up_or_down: at yaws 0, 37.5, 90, 180 and -135, the axes at pitch ±90 match the ones at ±89.9.
    • thrown_item_billboard_faces_the_front_camera: the axes in first person, third-person back and third-person front at yaw 0, pitch 0.
  • Before the fix (old cross-product body put back into thrown_item_axes): both tests FAIL.
    yaw 0, pitch -90: [1, -0, 0]/[0, 0.00000004371139, 1] vs [-1, 0, -0]/[0, 0.0017452989, -0.99999857] at -89.9
    
    At pitch -90, right is +X; at pitch -89.9, it is -X. The front-camera test failed with right [-1, 0, 0] where [1, 0, 0] was expected.
  • After the fix: both pass.
  • In game (cargo build --profile fast -p horizon-client --bins, single player on the server thread, creative): I threw eggs at pitch -89 and -90 with horizon-ctl look and use-item, then took a screenshot.
    • Before: at -90 the egg was upside down (wide end up, highlight bottom right).
    • After: it was upright at both pitches (narrow end up, highlight top left), the same as at -89.
    • Looking down at pitch 89 the egg was also upright.

Screenshots

before: an egg thrown at pitch -89 (left) and -90 (right); at -90 it is drawn upside down

after: both upright

Before, throwing an egg straight up (pitch -90) shows it upside down: wide end up, highlight at the bottom right. At pitch -89 the same egg is upright. After the fix, the egg is upright at both -89 and -90, with the narrow end up and the highlight at the top left.

🤖 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/4016 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3393-eggs` --- ### 📝 Commits (2) - [`4b09c9d`](https://github.com/horizon-rust/horizon/commit/4b09c9d7d11a8807006ddc6b04b1a0b4b20e9a40) Thrown eggs and snowballs turn with the camera, no flip looking straight up - [`71527fa`](https://github.com/horizon-rust/horizon/commit/71527fa938481e853d7b392cd9dd597d350013d5) Merge remote-tracking branch 'origin/main' into upd-4016 ### 📊 Changes **2 files changed** (+62 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+16 -12) 📝 `crates/horizon-client/src/game/creatures.rs` (+46 -8) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally. ## What and why Part of #3393 ("When throwing eggs or snowballs straight upward (at a 90° angle), their texture flips upside down"). Item projectiles (eggs, snowballs, ender pearls, fireballs, llama spit) are drawn as a billboard. `entity_geometry` in `game/creatures.rs` built its axes as `right = forward × Y` and `up = right × forward`. At pitch exactly ±90, where `look` and the mouse clamp, `forward` is vertical. In f32, `cos(90°)` comes out slightly negative (-4.37e-8), so the horizontal part of `forward` points backwards. `right` then flips sign compared with pitch ±89.9, `up` flips with it, and the sprite turns 180°. The same basis ignored third-person front view, which showed the sprite mirrored. Vanilla doesn't build a basis from the look vector at all: it rotates the item by the camera's orientation. The fix does the same: - `camera_orientation`'s maths moves into a free `camera_rotation(camera_type, yaw, pitch)` in `game.rs`, and the method calls it (same result for its existing callers: potions, fireworks, the splash potion projectile). - `thrown_item_axes` takes the billboard's right and up axes from that quaternion (`q * X`, `q * Y`). This is the turned-round camera in front view and stays continuous through ±90. Not changed here: the client still lets a summoned `{NoGravity:1b}` egg fall between server updates. I saw it while testing, but it's a separate bug. ## 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 - `net.minecraft.client.renderer.entity.ThrownItemRenderer.submit`: `PoseStack.scale(scale)`, then `PoseStack.rotate(CameraRenderState.orientation)`, then `ItemStackRenderState.submit`. There is no look-vector cross product. - `net.minecraft.client.Camera.setRotation(float, float)`: `rotation.rotationYXZ(π - yRot·π/180, -xRot·π/180, 0)`. `Camera.setup` calls it with `(yRot + 180, -xRot)` when `CameraType.isMirrored()` (third-person front). - Read with `javap -c -p` on the 26.3 client jar. No parity harness covers entity billboards. The new unit tests check the axes against `Camera.setRotation`'s orientation. ## Self-check `tools/pr_ready.py` doesn't run on Windows (it needs SIGHUP), so I ran its steps by hand: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test -p horizon-client --bin horizon-client -- thrown_item_billboard game::perspective`: 7 passed, 1 ignored (it needs prepared model data) - New tests in `game/creatures.rs`: - `thrown_item_billboard_does_not_flip_at_straight_up_or_down`: at yaws 0, 37.5, 90, 180 and -135, the axes at pitch ±90 match the ones at ±89.9. - `thrown_item_billboard_faces_the_front_camera`: the axes in first person, third-person back and third-person front at yaw 0, pitch 0. - Before the fix (old cross-product body put back into `thrown_item_axes`): both tests FAIL. ``` yaw 0, pitch -90: [1, -0, 0]/[0, 0.00000004371139, 1] vs [-1, 0, -0]/[0, 0.0017452989, -0.99999857] at -89.9 ``` At pitch -90, right is +X; at pitch -89.9, it is -X. The front-camera test failed with right `[-1, 0, 0]` where `[1, 0, 0]` was expected. - After the fix: both pass. - In game (`cargo build --profile fast -p horizon-client --bins`, single player on the server thread, creative): I threw eggs at pitch -89 and -90 with `horizon-ctl look` and `use-item`, then took a screenshot. - Before: at -90 the egg was upside down (wide end up, highlight bottom right). - After: it was upright at both pitches (narrow end up, highlight top left), the same as at -89. - Looking down at pitch 89 the egg was also upright. ## Screenshots ![before: an egg thrown at pitch -89 (left) and -90 (right); at -90 it is drawn upside down](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3393-eggs-1.png) ![after: both upright](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3393-eggs-2.png) Before, throwing an egg straight up (pitch -90) shows it upside down: wide end up, highlight at the bottom right. At pitch -89 the same egg is upright. After the fix, the egg is upright at both -89 and -90, with the narrow end up and the highlight at the top left. 🤖 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:12:02 +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#5358
No description provided.