From 753b5654b18c7f33d260c8954853860210ee9ea6 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 11 Oct 2026 16:51:07 +0200 Subject: [PATCH] Keep errors inside forked execute chains silent, as vanilla Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/command_harness.rs | 8 ++++++++ crates/horizon-client/src/game/commands/execute.rs | 14 +++++++++++++- tools/command_exec_corpus.py | 8 +++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/command_harness.rs b/crates/horizon-client/src/game/command_harness.rs index ce18149f4..02bfb143b 100644 --- a/crates/horizon-client/src/game/command_harness.rs +++ b/crates/horizon-client/src/game/command_harness.rs @@ -98,9 +98,17 @@ impl Game<'_> { } "tick" => { self.chat_capture = Some(Vec::new()); + // The oracle's player has no client moving it: hold the + // player where commands put it while the game ticks. + let held = self.player.as_ref().map(|p| p.position); for _ in 0..op["n"].as_u64().unwrap_or(1) { self.update_world(); self.tick()?; + if let (Some(p), Some(at)) = (self.player.as_mut(), held) { + p.position = at; + p.velocity = horizon_core::geometry::Vec3::new(0.0, 0.0, 0.0); + p.fall_distance = 0.0; + } } let messages = self.chat_capture.take().unwrap_or_default(); if op["record"].as_bool() == Some(true) { diff --git a/crates/horizon-client/src/game/commands/execute.rs b/crates/horizon-client/src/game/commands/execute.rs index 2ed16b72f..a913b07c5 100644 --- a/crates/horizon-client/src/game/commands/execute.rs +++ b/crates/horizon-client/src/game/commands/execute.rs @@ -251,6 +251,10 @@ impl Game<'_> { pub(in crate::game) fn run_execute(&mut self, ctx: &Context) -> R { let mut sources = vec![self.command_source.unwrap_or_else(|| self.player_source())]; let mut c = ctx; + // A fork modifier (as, at, positioned as, rotated as, facing entity, + // on, a non-terminal if/unless) makes later errors silent + // (CommandSourceStack.handleError with `forked`). + let mut forked = false; loop { let word = c .literals @@ -273,7 +277,8 @@ impl Game<'_> { for s in sources { match self.with_source(s, |g| g.run_chain(command, last)) { Ok(n) => total += n, - // Forked executions report failures and carry on. + Err(_) if forked => {} + // Several sources: report each failure and carry on. Err(e) if many => self.command_failure(e.message), Err(e) => failure = Some(e), } @@ -291,6 +296,7 @@ impl Game<'_> { if c.child.is_none() { return self.run_conditional_terminal(c, sources, want); } + forked = true; let mut kept = Vec::new(); for s in sources { let (keep, _) = self.with_source(s, |g| g.condition(c, want))?; @@ -301,6 +307,12 @@ impl Game<'_> { sources = kept; } _ => { + forked |= match word { + "as" | "at" | "on" => true, + "positioned" | "rotated" => c.has("as"), + "facing" => c.has("entity"), + _ => false, + }; let mut next = Vec::new(); for s in sources { next.extend(self.with_source(s, |g| g.modify(word, c, s))?); diff --git a/tools/command_exec_corpus.py b/tools/command_exec_corpus.py index 2fb23967c..de1c33165 100644 --- a/tools/command_exec_corpus.py +++ b/tools/command_exec_corpus.py @@ -860,7 +860,13 @@ def test_command(): cmd('/test locate *'), cmd('/test run minecraft:nothing*'), cmd('/test locate nothing'), - cmd('/execute as @e[type=!minecraft:player,limit=1] run test pos'), + *setup('/summon minecraft:marker 8 230 8 {Tags:["tp"]}'), + cmd('/execute as @e[tag=tp] run test pos'), + cmd('/execute positioned 0 230 0 run test pos'), + cmd('/execute as @e[tag=tp] run kill @e[tag=nothing]'), + cmd('/execute as @e[tag=tp] at @s run kill @e[tag=nothing]'), + cmd('/execute positioned 1 2 3 run kill @e[tag=nothing]'), + *setup('/kill @e[tag=tp]'), ]