[PR #7639] Cast the fishing bobber with the vanilla trig table, not the platform's #7730

Open
opened 2026-11-03 07:23:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7639
Author: @StarWeizz
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/7440-fishing-hook-straight-down


📝 Commits (1)

  • 345984b Cast the fishing bobber with the vanilla trig table, not the platform's

📊 Changes

1 file changed (+50 additions, -12 deletions)

View changed files

📝 crates/horizon-client/src/game/fishing.rs (+50 -12)

📄 Description

🤖 Opened by StarWeizz's AI agent (Claude Code, Claude Sonnet 5), not by StarWeizz personally.

What and why

Game::use_fishing_rod computed the cast direction with the platform's native cos/sin. Vanilla's FishingHook(Player, Level, int, int) uses Mth.cos/Mth.sin, a 65536-entry quantized table, to build the same -(xSin / xCos) ratio clamped to ±5.

At a pitch of exactly 90 (as far down as the camera goes, which the camera's own clamp reaches easily), vanilla's table gives an exact 0.0 for xCos, so the ratio is a consistently-signed Infinity that clamps to -5.0 every time: the bobber is thrown down, landing in front of the player. The platform's own cos of the float nearest -90 degrees rounds to a tiny positive value instead (cos(-FRAC_PI_2_f32) ≈ 4.37e-8), flipping the clamped ratio to +5.0 and throwing the bobber straight up into the sky.

Fix: use the already-ported trig::sin/trig::cos table (horizon_core::geometry::trig) with the exact DEG_TO_RAD constant, matching the idiom already used elsewhere in the codebase (remote_mob_particles.rs, first_person.rs, auto_jump.rs), instead of f32::to_radians/.cos()/.sin().

Fixes #7440

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

FishingHook(Player, Level, int, int) (the constructor), read from the pinned 26.3 client decompiled locally via tools/lab.py decompile. Checked against tools/test_fishing_hook_entities_parity.py, which runs a real vanilla 26.3 server next to Horizon and now reports the cast lines identical (previously untested for this exact pitch edge case).

Other projects' code

none

Self-check

tools/pr_ready.py itself ran too long on this machine under the extra load of preparing vanilla resources for the first time, so I ran its individual steps by hand instead:

  • cargo fmt -p horizon-client -- --check: clean (one import wrapped by cargo fmt)
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test -p horizon-client --lib: 691 passed; 0 failed; 5 ignored
  • cargo test -p horizon-client --lib game::fishing: 8 passed (includes the 2 new regression tests, which I confirmed fail against the pre-fix code with left: 5.0, right: -5.0)
  • python tools/test_fishing_hook_entities_parity.py: fishing hook entities: 5 lines identical

Screenshots

Not applicable: a physics/trajectory bug, not a visual one.


🔄 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/7639 **Author:** [@StarWeizz](https://github.com/StarWeizz) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/7440-fishing-hook-straight-down` --- ### 📝 Commits (1) - [`345984b`](https://github.com/horizon-rust/horizon/commit/345984b696328c033c5d56f13aacc46bd51856b1) Cast the fishing bobber with the vanilla trig table, not the platform's ### 📊 Changes **1 file changed** (+50 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/fishing.rs` (+50 -12) </details> ### 📄 Description > 🤖 Opened by StarWeizz's AI agent (Claude Code, Claude Sonnet 5), not by StarWeizz personally. ## What and why `Game::use_fishing_rod` computed the cast direction with the platform's native `cos`/`sin`. Vanilla's `FishingHook(Player, Level, int, int)` uses `Mth.cos`/`Mth.sin`, a 65536-entry quantized table, to build the same `-(xSin / xCos)` ratio clamped to ±5. At a pitch of exactly 90 (as far down as the camera goes, which the camera's own clamp reaches easily), vanilla's table gives an exact `0.0` for `xCos`, so the ratio is a consistently-signed `Infinity` that clamps to `-5.0` every time: the bobber is thrown down, landing in front of the player. The platform's own `cos` of the float nearest -90 degrees rounds to a tiny *positive* value instead (`cos(-FRAC_PI_2_f32) ≈ 4.37e-8`), flipping the clamped ratio to `+5.0` and throwing the bobber straight up into the sky. Fix: use the already-ported `trig::sin`/`trig::cos` table (`horizon_core::geometry::trig`) with the exact `DEG_TO_RAD` constant, matching the idiom already used elsewhere in the codebase (`remote_mob_particles.rs`, `first_person.rs`, `auto_jump.rs`), instead of `f32::to_radians`/`.cos()`/`.sin()`. Fixes #7440 ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `FishingHook(Player, Level, int, int)` (the constructor), read from the pinned 26.3 client decompiled locally via `tools/lab.py decompile`. Checked against `tools/test_fishing_hook_entities_parity.py`, which runs a real vanilla 26.3 server next to Horizon and now reports the cast lines identical (previously untested for this exact pitch edge case). ## Other projects' code none ## Self-check `tools/pr_ready.py` itself ran too long on this machine under the extra load of preparing vanilla resources for the first time, so I ran its individual steps by hand instead: - `cargo fmt -p horizon-client -- --check`: clean (one import wrapped by `cargo fmt`) - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test -p horizon-client --lib`: 691 passed; 0 failed; 5 ignored - `cargo test -p horizon-client --lib game::fishing`: 8 passed (includes the 2 new regression tests, which I confirmed fail against the pre-fix code with `left: 5.0, right: -5.0`) - `python tools/test_fishing_hook_entities_parity.py`: `fishing hook entities: 5 lines identical` ## Screenshots Not applicable: a physics/trajectory bug, not a visual one. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7730
No description provided.