[PR #4804] [MERGED] Spectator camera on the server (handleSpectatorAction, SetCamera) #5862

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4804
Author: @levzzz5154
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: parity/G-spectate


📝 Commits (1)

  • 37aa729 Server side of the spectator camera: handleSpectatorAction, SetCamera, camera follow for guests

📊 Changes

6 files changed (+228 additions, -4 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/commands.rs (+1 -1)
📝 crates/horizon-client/src/game/commands/execute.rs (+1 -1)
📝 crates/horizon-client/src/game/commands/extra.rs (+19 -1)
📝 crates/horizon-client/src/game/lan_actions.rs (+3 -1)
➕ crates/horizon-client/src/game/lan_camera.rs (+203 -0)

📄 Description

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

Part of #3520

Rows

  • ServerGamePacketListenerImpl.handleSpectatorAction: a spectating guest's click (SPECTATOR_ACTION) is now handled on the server: client loaded and spectator, entity with that id, inside the world border, within the entity interaction range + 3.0 of its box, isPickable (players that are not spectators, living mobs, non-marker stands, frames, paintings, boats, minecarts, end crystals, interactions), then setCamera.
  • Also ServerPlayer.setCamera / the camera part of ServerPlayer.tick (new game/lan_camera.rs): the player moves to the camera and ClientboundSetCameraPacket is sent (it was never sent before, so /spectate did nothing for a guest or the window on its server thread); every tick the guest is snapped to the camera's position and rotation (so chunks stream around it), and the camera ends when the entity dies, the guest sneaks, leaves spectator mode or is teleported (resetCamera). /spectate for a guest goes through the same path.

Not covered: projectiles that are redirectable, ender dragon parts and falling blocks/TNT as cameras (not tracked as Targets), broadcastToPlayer hiding a camera-watching spectator from other spectators, resetLastActionTime.

Vanilla followed

ServerGamePacketListenerImpl.handleSpectatorAction, ServerPlayer.setCamera, ServerPlayer.tick (camera block), Entity.isPickable overrides, Player.isWithinEntityInteractionRange.

Tests

game::lan_camera::tests::camera_ends_like_server_player_tick; fmt, clippy -D warnings. Not run: harnesses (CI).

🤖 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/4804 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `parity/G-spectate` --- ### 📝 Commits (1) - [`37aa729`](https://github.com/horizon-rust/horizon/commit/37aa7295269b41b2aaebae9da8e16b67a12d2220) Server side of the spectator camera: handleSpectatorAction, SetCamera, camera follow for guests ### 📊 Changes **6 files changed** (+228 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+1 -1) 📝 `crates/horizon-client/src/game/commands/execute.rs` (+1 -1) 📝 `crates/horizon-client/src/game/commands/extra.rs` (+19 -1) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+3 -1) ➕ `crates/horizon-client/src/game/lan_camera.rs` (+203 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #3520 ## Rows - `ServerGamePacketListenerImpl.handleSpectatorAction`: a spectating guest's click (SPECTATOR_ACTION) is now handled on the server: client loaded and spectator, entity with that id, inside the world border, within the entity interaction range + 3.0 of its box, `isPickable` (players that are not spectators, living mobs, non-marker stands, frames, paintings, boats, minecarts, end crystals, interactions), then `setCamera`. - Also `ServerPlayer.setCamera` / the camera part of `ServerPlayer.tick` (new `game/lan_camera.rs`): the player moves to the camera and `ClientboundSetCameraPacket` is sent (it was never sent before, so `/spectate` did nothing for a guest or the window on its server thread); every tick the guest is snapped to the camera's position and rotation (so chunks stream around it), and the camera ends when the entity dies, the guest sneaks, leaves spectator mode or is teleported (`resetCamera`). `/spectate` for a guest goes through the same path. Not covered: projectiles that are redirectable, ender dragon parts and falling blocks/TNT as cameras (not tracked as `Target`s), `broadcastToPlayer` hiding a camera-watching spectator from other spectators, `resetLastActionTime`. ## Vanilla followed `ServerGamePacketListenerImpl.handleSpectatorAction`, `ServerPlayer.setCamera`, `ServerPlayer.tick` (camera block), `Entity.isPickable` overrides, `Player.isWithinEntityInteractionRange`. ## Tests `game::lan_camera::tests::camera_ends_like_server_player_tick`; fmt, clippy -D warnings. Not run: harnesses (CI). 🤖 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:15:30 +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#5862
No description provided.