[PR #1211] [MERGED] Server commands run in their source's level (execute in, execute at) #3425

Closed
opened 2026-11-03 04:09:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1211
Author: @ludovic111
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @ludovic111

Base: main ← Head: fix/server-command-levels


📝 Commits (9)

  • bd36508 lan_e2e levels: players in their own levels on the server thread; design note
  • 84171cf lan_e2e portals: wait for the guest to be placed in its Nether portal
  • 9fe228c Server commands run in their source's level (execute in, execute at)
  • b6b6eb9 Merge origin/main into feat/lan-levels-check
  • 5a2d55c Merge the updated stack base (with origin/main) into fix/server-command-levels
  • 5e55ebd Merge origin/main into feat/lan-levels-check
  • 5472d4c Merge the updated stack base (with origin/main) into fix/server-command-levels
  • b6a018b Merge origin/main into feat/lan-levels-check
  • e4fb8f0 Merge the updated stack base (with origin/main) into fix/server-command-levels

📊 Changes

6 files changed (+376 additions, -22 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+18 -14)
📝 crates/horizon-client/src/game/commands/execute.rs (+11 -3)
📝 crates/horizon-client/src/game/levels.rs (+18 -0)
➕ docs/server-levels.md (+92 -0)
📝 docs/server.md (+1 -1)
📝 tools/lan_e2e.py (+236 -4)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Brief lan-levels-1, part 2 of 4. Stacked on #1210.

What

On a server (the dedicated one, or single player's server thread), each dimension is its own level. But a command ran in whichever level was in place, so:

  • a guest in the Nether running execute in minecraft:overworld run setblock … got "That position is not loaded";
  • execute at <a player in another level> used the wrong level's blocks.

Vanilla runs a command in its source's level (CommandSourceStack.getLevel).

  • with_source now puts the source's level in place for the command and puts the old one back afterwards (Game::enter_command_level). as_target already does this for a player in another level. The window's own game holds one level, so nothing changes there.
  • execute at takes the entity's level (withLevel(entity.level())).
  • A server player's level is its own (target_level), even while another level is in place. So execute in … run tp @s still moves the guest across levels.

Test

lan_e2e levels, step execute: from the Nether, the guest runs three commands.

  • execute in overworld run setblock
  • execute at <host> run setblock
  • execute in overworld if block … in the_nether run setblock

Each block must land in its level.

  • Before this PR, setblock in the Overworld failed: the block beside the host stayed air.
  • With this PR, all three pass.

How tested (Mac mini)

On the stack's tip (#1213), whose test code is a superset of this one, rebased on main b88218d0:

  • cargo fmt --check: OK. cargo clippy --workspace --all-targets -- -D warnings: OK, and on each branch of the stack. cargo test -p horizon-client: 995 + 91 + 22 passed.
  • lan_e2e --server-thread --check portals --check levels --check tab: 3/3, all 8 levels steps pass. In the frame, levels is skipped.

Earlier, on the same code built on #1114:

  • Full lan_e2e --server-thread: 46/50. swings is the known race (#1114). portals failed once: the check read the guest's Nether position before the guest had been placed in its portal. #1210 now waits for that (it happened again once after the first rebase, then passed 2/2 with the wait). flight and levels failed after it, because the guest was left in the Nether. All four pass on rerun.
  • Full in-frame lan_e2e: 45/50. The guest died before swings, and swings, cracks, plates, effects and flight failed after it, on the dead screen. All 5 pass on rerun. The in-frame suite's flakes on this busy machine are in #1114 too.
  • Parity: server_dimension_players, command_exec, nether_portal, anchor, end_gateway and end_podium pass. dedicated_server failed 3 times on play-pearl teleported 0 time(s), then passed 3/3. It fails the same way on the base (#1114's head): 1 of 2. It is the known pearl flake. Changed set (--changed, 83 harnesses, same Rust code before the rebase onto main): 82 pass. world_spawn was cut off twice (a restart of the agent's server, then a time limit on the rerun on the tip) after 60/60 origins and 58 spawn seeds, all matching vanilla.
  • No perf rerun. With nobody outside the Overworld, the server tick runs the same single pass. The new code runs only for commands whose source is in another level, players touching a gateway, and respawns. The Mac mini was 90% busy, which makes the bench unreliable (#1114).

Cost of an extra level (docs/server-levels.md): 1.0 ms a tick with both players in the Overworld, 2.2 ms with the guest in the Nether, about +45 MB.

Needs Ludovic

Nothing.

🤖 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/1211 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/server-command-levels` --- ### 📝 Commits (9) - [`bd36508`](https://github.com/horizon-rust/horizon/commit/bd36508c298cfee286986088a1b30ecdac68d34b) lan_e2e levels: players in their own levels on the server thread; design note - [`84171cf`](https://github.com/horizon-rust/horizon/commit/84171cfc94c048807520c426cf9a4af05aaf289f) lan_e2e portals: wait for the guest to be placed in its Nether portal - [`9fe228c`](https://github.com/horizon-rust/horizon/commit/9fe228cd1e2753e252f40a2f49150779316423cf) Server commands run in their source's level (execute in, execute at) - [`b6b6eb9`](https://github.com/horizon-rust/horizon/commit/b6b6eb9a87b97f75c03be38bd5edefa803d110cf) Merge origin/main into feat/lan-levels-check - [`5a2d55c`](https://github.com/horizon-rust/horizon/commit/5a2d55c8639f852294e90303c80ac00d748f442b) Merge the updated stack base (with origin/main) into fix/server-command-levels - [`5e55ebd`](https://github.com/horizon-rust/horizon/commit/5e55ebd2a76ebe8fb69e1a8c6a216b1c8ce8a1d6) Merge origin/main into feat/lan-levels-check - [`5472d4c`](https://github.com/horizon-rust/horizon/commit/5472d4c6685c81468f66321097620afca542f7b8) Merge the updated stack base (with origin/main) into fix/server-command-levels - [`b6a018b`](https://github.com/horizon-rust/horizon/commit/b6a018bf870463c841f12553d23b541fc8f39c1a) Merge origin/main into feat/lan-levels-check - [`e4fb8f0`](https://github.com/horizon-rust/horizon/commit/e4fb8f0f3fb42076b0fc297f7686e749261906e5) Merge the updated stack base (with origin/main) into fix/server-command-levels ### 📊 Changes **6 files changed** (+376 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+18 -14) 📝 `crates/horizon-client/src/game/commands/execute.rs` (+11 -3) 📝 `crates/horizon-client/src/game/levels.rs` (+18 -0) ➕ `docs/server-levels.md` (+92 -0) 📝 `docs/server.md` (+1 -1) 📝 `tools/lan_e2e.py` (+236 -4) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Brief lan-levels-1, part 2 of 4. **Stacked on #1210.** ## What On a server (the dedicated one, or single player's server thread), each dimension is its own level. But a command ran in whichever level was in place, so: - a guest in the Nether running `execute in minecraft:overworld run setblock …` got "That position is not loaded"; - `execute at <a player in another level>` used the wrong level's blocks. Vanilla runs a command in its source's level (`CommandSourceStack.getLevel`). - `with_source` now puts the source's level in place for the command and puts the old one back afterwards (`Game::enter_command_level`). `as_target` already does this for a player in another level. The window's own game holds one level, so nothing changes there. - `execute at` takes the entity's level (`withLevel(entity.level())`). - A server player's level is its own (`target_level`), even while another level is in place. So `execute in … run tp @s` still moves the guest across levels. ## Test `lan_e2e levels`, step `execute`: from the Nether, the guest runs three commands. - `execute in overworld run setblock` - `execute at <host> run setblock` - `execute in overworld if block … in the_nether run setblock` Each block must land in its level. - Before this PR, `setblock` in the Overworld failed: the block beside the host stayed air. - With this PR, all three pass. ## How tested (Mac mini) On the stack's tip (#1213), whose test code is a superset of this one, rebased on `main` b88218d0: - `cargo fmt --check`: OK. `cargo clippy --workspace --all-targets -- -D warnings`: OK, and on each branch of the stack. `cargo test -p horizon-client`: 995 + 91 + 22 passed. - `lan_e2e --server-thread --check portals --check levels --check tab`: 3/3, all 8 `levels` steps pass. In the frame, `levels` is skipped. Earlier, on the same code built on #1114: - Full `lan_e2e --server-thread`: 46/50. `swings` is the known race (#1114). `portals` failed once: the check read the guest's Nether position before the guest had been placed in its portal. #1210 now waits for that (it happened again once after the first rebase, then passed 2/2 with the wait). `flight` and `levels` failed after it, because the guest was left in the Nether. All four pass on rerun. - Full in-frame `lan_e2e`: 45/50. The guest died before `swings`, and `swings`, `cracks`, `plates`, `effects` and `flight` failed after it, on the dead screen. All 5 pass on rerun. The in-frame suite's flakes on this busy machine are in #1114 too. - Parity: `server_dimension_players`, `command_exec`, `nether_portal`, `anchor`, `end_gateway` and `end_podium` pass. `dedicated_server` failed 3 times on `play-pearl teleported 0 time(s)`, then passed 3/3. It fails the same way on the base (#1114's head): 1 of 2. It is the known pearl flake. Changed set (`--changed`, 83 harnesses, same Rust code before the rebase onto `main`): 82 pass. `world_spawn` was cut off twice (a restart of the agent's server, then a time limit on the rerun on the tip) after 60/60 origins and 58 spawn seeds, all matching vanilla. - No perf rerun. With nobody outside the Overworld, the server tick runs the same single pass. The new code runs only for commands whose source is in another level, players touching a gateway, and respawns. The Mac mini was 90% busy, which makes the bench unreliable (#1114). Cost of an extra level (docs/server-levels.md): 1.0 ms a tick with both players in the Overworld, 2.2 ms with the guest in the Nether, about +45 MB. ## Needs Ludovic Nothing. 🤖 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 04:09:27 +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#3425
No description provided.