[PR #5078] [MERGED] Let the spectators_generate_chunks rule decide who loads terrain #6047

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5078
Author: @MSedgeMC
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/spectator-chunks-rule


📝 Commits (1)

  • fe0c9d5 Let the spectators_generate_chunks rule decide who loads terrain

📊 Changes

5 files changed (+63 additions, -21 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+29 -18)
📝 crates/horizon-client/src/game/dedicated.rs (+2 -1)
📝 crates/horizon-client/src/game/game_mode.rs (+29 -0)
📝 crates/horizon-client/src/game/lan.rs (+2 -1)
📝 tools/port_map/game-001.tsv (+1 -1)

📄 Description

Fixes the ChunkMap.skipPlayer row in the port ledger. (No issue.)

Vanilla's ChunkMap.skipPlayer(ServerPlayer) is player.isSpectator() && !level.getGameRules().getBoolean(SPECTATORS_GENERATE_CHUNKS), and updatePlayerStatus uses it to skip distanceManager.addPlayer — the ticket — while still running the chunk-tracking path. So with the rule off a spectator loads and generates nothing around themselves, but keeps receiving the chunks other players load.

Horizon declared the rule (gamerules.rs), saved and loaded it with the rest of game_rules.dat, and never read it: a spectator's chunk was an unconditional ticket source in update_chunk_tickets, a full streaming area in the LAN path, and could even become the centre a standalone dedicated server streams around.

The rule now reaches all three through one helper. Two details worth a reviewer's eye: the "no players ⇒ tick everywhere" guard for headless fixtures is now computed from the unfiltered player list, so a game whose only player is a skipped spectator does not start ticking the whole world; and a lone skipped spectator counts as nobody online for the dedicated server's centre, matching vanilla's no-ticket state. Chunk sending is untouched — a spectator still receives what others load.

Proven: cargo test -p horizon-client --bin horizon-client a_skipped_spectator → 1 passed on a build box (spectator with the rule off loads nothing, with it on loads, and a non-spectator always loads).

Not proven: the end-to-end behaviour on a server thread, LAN and dedicated server. The honest check is a lan_e2e case: with /gamerule spectators_generate_chunks false, put the guest in spectator mode, teleport them 1200 blocks out, wait, and /execute if loaded at that spot — it should fail, while the same with the rule on should pass, and the spectator should still receive the host's chunks nearby. execute if loaded already exists, so that check is feasible without new command work; I could not write or run it here.


🔄 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/5078 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/spectator-chunks-rule` --- ### 📝 Commits (1) - [`fe0c9d5`](https://github.com/horizon-rust/horizon/commit/fe0c9d55889391feab1cdcc05f3b10c82b01cb12) Let the spectators_generate_chunks rule decide who loads terrain ### 📊 Changes **5 files changed** (+63 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+29 -18) 📝 `crates/horizon-client/src/game/dedicated.rs` (+2 -1) 📝 `crates/horizon-client/src/game/game_mode.rs` (+29 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+2 -1) 📝 `tools/port_map/game-001.tsv` (+1 -1) </details> ### 📄 Description Fixes the `ChunkMap.skipPlayer` row in the port ledger. (No issue.) Vanilla's `ChunkMap.skipPlayer(ServerPlayer)` is `player.isSpectator() && !level.getGameRules().getBoolean(SPECTATORS_GENERATE_CHUNKS)`, and `updatePlayerStatus` uses it to skip `distanceManager.addPlayer` — the ticket — while still running the chunk-tracking path. So with the rule off a spectator loads and generates nothing around themselves, but keeps receiving the chunks other players load. Horizon declared the rule (`gamerules.rs`), saved and loaded it with the rest of `game_rules.dat`, and never read it: a spectator's chunk was an unconditional ticket source in `update_chunk_tickets`, a full streaming area in the LAN path, and could even become the centre a standalone dedicated server streams around. The rule now reaches all three through one helper. Two details worth a reviewer's eye: the "no players ⇒ tick everywhere" guard for headless fixtures is now computed from the **unfiltered** player list, so a game whose only player is a skipped spectator does not start ticking the whole world; and a lone skipped spectator counts as nobody online for the dedicated server's centre, matching vanilla's no-ticket state. Chunk *sending* is untouched — a spectator still receives what others load. **Proven:** `cargo test -p horizon-client --bin horizon-client a_skipped_spectator` → 1 passed on a build box (spectator with the rule off loads nothing, with it on loads, and a non-spectator always loads). **Not proven:** the end-to-end behaviour on a server thread, LAN and dedicated server. The honest check is a `lan_e2e` case: with `/gamerule spectators_generate_chunks false`, put the guest in spectator mode, teleport them 1200 blocks out, wait, and `/execute if loaded` at that spot — it should fail, while the same with the rule on should pass, and the spectator should still receive the host's chunks nearby. `execute if loaded` already exists, so that check is feasible without new command work; I could not write or run it here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:51 +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#6047
No description provided.