From df626cf2f381ff11ff72a2e7d3793e7078291cca Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:15:28 +0100 Subject: [PATCH] A tool that changes a block ends the click on a server's client On a server's client (single player on the server thread, LAN guests), a shovel making a path, an axe stripping, a hoe tilling or honeycomb waxing did not end the right click: the client went on to the other hand, so an off-hand torch was predicted as placed and its hand swung instead of the tool's (#1289). Vanilla's client runs `Item.useOn` itself: its SUCCESS swings that hand and `Minecraft.startUseItem` returns before the off hand. The client now does the same when its prediction of the tool's use succeeds. Fixes #1289 Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/remote.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index c1ef53122..8edfd77a2 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -4000,8 +4000,14 @@ impl Game<'_> { } if reacts { self.predict_use(&changes, seq); - } else if let Some(stack) = held.as_ref() { - self.predict_item_on_block(stack, &hit); + } else if let Some(stack) = held.as_ref() + && self.predict_item_on_block(stack, &hit) + { + // Item.useOn succeeded here (InteractionResult.SUCCESS): + // this hand swings and the click ends, so the other hand + // (a shield, a torch) is never tried. + self.with_hand(hand, Game::swing_arm); + return true; } if held_block { let placed = if reacts { @@ -4031,7 +4037,8 @@ impl Game<'_> { /// `playSound(player, ...)`: the server sends them to the others only): /// honeycomb waxing copper, and an axe, hoe or shovel transforming a /// block (stripping, scraping, removing wax, tilling, making a path). - fn predict_item_on_block(&mut self, stack: &ItemStack, hit: &super::Hit) { + /// Whether the item's use succeeded, which ends the click. + fn predict_item_on_block(&mut self, stack: &ItemStack, hit: &super::Hit) -> bool { let at = [ f64::from(hit.pos[0]) + 0.5, f64::from(hit.pos[1]) + 0.5, @@ -4050,11 +4057,15 @@ impl Game<'_> { self.audio .play("minecraft:item.honeycomb.wax_on", Some(at), 1.0, 1.0); } + waxes } else if let Some((_, sound, _, _, particle)) = self.block_transform(stack, hit.pos, hit.face) { self.transform_particle(&particle, hit.pos); self.audio.play(&sound, Some(at), 1.0, 1.0); + true + } else { + false } }