[PR #5992] [MERGED] feat(mods): detached camera distance hook #6597

Closed
opened 2026-11-03 06:23:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5992
Author: @Xmilon
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: native/detached-camera-distance


📝 Commits (1)

  • 8dc3e7f feat(mods): adjust detached camera distance before collision clipping

📊 Changes

4 files changed (+161 additions, -16 deletions)

View changed files

📝 crates/horizon-client-render/src/camera.rs (+115 -4)
📝 crates/horizon-client/src/game/native_hooks.rs (+12 -0)
📝 crates/horizon-client/src/game/perspective.rs (+22 -12)
➕ tools/native-hook-fragments/camera_distance.json (+12 -0)

📄 Description

🤖 Opened by Xmilon's AI agent (Codex), not by Xmilon personally.

What and why

Fixes #5978; part of #4953's camera additions. native_camera_distance(partial, mirrored, entity, distance) lets native mods adjust the final scaled third-person camera distance before the existing eight collision rays shorten it. This supports both front/back views, player and spectator-mob cameras, and the existing entity/mount scale and distance values.

The hook accepts finite distances in 0..=1024 blocks, including zero; invalid values retain the original distance. The bound keeps requests within the game's collision-ray budget. First-person views and title panoramas do not fire the hook. The existing Camera::align_with_entity entry point retains its behavior for existing callers.

Kind

  • feature: something new for players

Vanilla reference

Read the player's own pinned 26.3 Camera.alignWithEntity/getMaxZoom bytecode with javap: the scaled entity/mount maximum is computed before collision clipping. Public counterpart: CalculateDetachedCameraDistanceEvent. No vanilla game files are included.

Other projects' code

None. Public javadoc for the event contract only.

Self-check

  • Client and renderer Clippy --lib --bins --tests -D warnings passed.
  • Compiled the actual camera module in an isolated test crate: all ten unit tests passed, including the two added tests covering scaled/mounted input, front/back placement, collision clipping, invalid values, zero distance, and first-person exclusion.
  • All four fragment-tool tests, touched-file rustfmt, diff and public-tree checks passed.
  • API fragment only, no catalog/API number edits.
  • No in-game/screenshot check. Client-only camera calculation; no server simulation changes. CI pending.

🤖 Generated with Codex


🔄 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/5992 **Author:** [@Xmilon](https://github.com/Xmilon) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/detached-camera-distance` --- ### 📝 Commits (1) - [`8dc3e7f`](https://github.com/horizon-rust/horizon/commit/8dc3e7fbc5c5592a71adf3607f782bb77018f670) feat(mods): adjust detached camera distance before collision clipping ### 📊 Changes **4 files changed** (+161 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/camera.rs` (+115 -4) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+12 -0) 📝 `crates/horizon-client/src/game/perspective.rs` (+22 -12) ➕ `tools/native-hook-fragments/camera_distance.json` (+12 -0) </details> ### 📄 Description > 🤖 Opened by Xmilon's AI agent (Codex), not by Xmilon personally. ## What and why Fixes #5978; part of #4953's camera additions. `native_camera_distance(partial, mirrored, entity, distance)` lets native mods adjust the final scaled third-person camera distance before the existing eight collision rays shorten it. This supports both front/back views, player and spectator-mob cameras, and the existing entity/mount scale and distance values. The hook accepts finite distances in 0..=1024 blocks, including zero; invalid values retain the original distance. The bound keeps requests within the game's collision-ray budget. First-person views and title panoramas do not fire the hook. The existing `Camera::align_with_entity` entry point retains its behavior for existing callers. ## Kind - [x] feature: something new for players ## Vanilla reference Read the player's own pinned 26.3 Camera.alignWithEntity/getMaxZoom bytecode with javap: the scaled entity/mount maximum is computed before collision clipping. Public counterpart: [CalculateDetachedCameraDistanceEvent](https://aldak.netlify.app/javadoc/26.3.x/net/neoforged/neoforge/client/event/calculatedetachedcameradistanceevent). No vanilla game files are included. ## Other projects' code None. Public javadoc for the event contract only. ## Self-check - Client and renderer Clippy --lib --bins --tests -D warnings passed. - Compiled the actual camera module in an isolated test crate: all ten unit tests passed, including the two added tests covering scaled/mounted input, front/back placement, collision clipping, invalid values, zero distance, and first-person exclusion. - All four fragment-tool tests, touched-file rustfmt, diff and public-tree checks passed. - API fragment only, no catalog/API number edits. - No in-game/screenshot check. Client-only camera calculation; no server simulation changes. CI pending. 🤖 Generated with [Codex](https://openai.com/codex/) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:23:37 +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#6597
No description provided.