[PR #3589] [MERGED] Commands: coordinate suggestions skip entities and offer the hit point #5078

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3589
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3427


📝 Commits (1)

  • 4bd3210 Commands: coordinate suggestions skip entities and offer the hit point

📊 Changes

4 files changed (+58 additions, -2 deletions)

View changed files

📝 crates/horizon-client-core/src/registries.rs (+3 -0)
📝 crates/horizon-client/src/game/chat.rs (+11 -1)
📝 crates/horizon-command/src/args.rs (+5 -1)
📝 crates/horizon-command/src/tests.rs (+39 -0)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Fixes #3427

Two differences from vanilla in the coordinate suggestions of the chat:

  1. Entity under the crosshair. With a mob in front of a block, /setblock suggested the block behind the mob. Vanilla uses Minecraft.hitResult, which is the entity there, so it suggests ~, ~ ~, ~ ~ ~. refresh_dynamic_registries (game/chat.rs) now leaves the target empty when pick_entity_hit finds an entity before the block.
  2. Vec3 / Vec2 arguments (/summon, /tp, /worldborder center...) only ever suggested ~. Vanilla suggests the exact hit point with two decimals. Registries gets target_point (the hit point, each coordinate formatted as Java's %.2f with java_text::format_fixed2), and suggest_coordinates uses it for the non-relevant arguments.

Vanilla reference

  • ClientSuggestionProvider.getRelevantCoordinates: hitResult of type BLOCK → its BlockPos (prettyPrint(int)), else SharedSuggestionProvider.getRelevantCoordinates (~ ~ ~).
  • ClientSuggestionProvider.getAbsoluteCoordinates: hitResult of type BLOCK → getLocation() with prettyPrint(double) = String.format(Locale.ROOT, "%.2f", v), else ~ ~ ~.
  • BlockPosArgument/ColumnPosArgument.listSuggestions use the relevant coordinates, Vec3Argument/Vec2Argument.listSuggestions the absolute ones (SharedSuggestionProvider.suggestCoordinates / suggest2DCoordinates).
  • tools/test_chat_screen_parity.py still passes (3021/3021 chat screens match); its oracle uses a server CommandSourceStack, so it has no hit result to compare.

Self-check

tools/pr_ready.py / tools/parity.py stop on Windows (signal.SIGHUP), so these ran by hand (Windows 11), on top of main 11494e17f:

cargo fmt --all -- --check                                                # ok
cargo clippy -p horizon-client-core --all-targets -- -D warnings          # ok
cargo clippy -p horizon-command --all-targets -- -D warnings              # ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings   # ok
cargo test -p horizon-command                                             # 20 passed
python tools/test_chat_screen_parity.py                                   # 3021/3021 chat screens match

New test tests::coordinates_suggest_the_crosshair_block_or_hit_point (horizon-command), with args.rs back to main:

test tests::coordinates_suggest_the_crosshair_block_or_hit_point ... FAILED
assertion `left == right` failed
  left: ["~", "~ ~", "~ ~ ~"]
 right: ["-28.77", "-28.77 73.28", "-28.77 73.28 8.00"]

With the fix: ok. The entity check is in the game binary (refresh_dynamic_registries), shown in game below.

Screenshots

Checked in game (screenshots taken locally; the suggestions they show are listed here). Server-thread single player, creative: a stone wall, a NoAI pig in front of it.

Before (main) After
Crosshair on the pig, /setblock 205, 205 99, 205 99 539 (the block behind the pig) ~, ~ ~, ~ ~ ~
Crosshair on the wall (hit 204.044, 102.371, 540.0), /summon minecraft:pig ~, ~ ~, ~ ~ ~ 204.04, 204.04 102.37, 204.04 102.37 540.00
Same, /setblock the wall block (not captured) 204, 204 102, 204 102 540 (same as main)

🤖 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/3589 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3427` --- ### 📝 Commits (1) - [`4bd3210`](https://github.com/horizon-rust/horizon/commit/4bd3210f78cad65277147e1a03ef41339560fb7b) Commands: coordinate suggestions skip entities and offer the hit point ### 📊 Changes **4 files changed** (+58 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-core/src/registries.rs` (+3 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+11 -1) 📝 `crates/horizon-command/src/args.rs` (+5 -1) 📝 `crates/horizon-command/src/tests.rs` (+39 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3427 Two differences from vanilla in the coordinate suggestions of the chat: 1. **Entity under the crosshair.** With a mob in front of a block, `/setblock ` suggested the block *behind* the mob. Vanilla uses `Minecraft.hitResult`, which is the entity there, so it suggests `~`, `~ ~`, `~ ~ ~`. `refresh_dynamic_registries` (`game/chat.rs`) now leaves the target empty when `pick_entity_hit` finds an entity before the block. 2. **Vec3 / Vec2 arguments** (`/summon`, `/tp`, `/worldborder center`...) only ever suggested `~`. Vanilla suggests the exact hit point with two decimals. `Registries` gets `target_point` (the hit point, each coordinate formatted as Java's `%.2f` with `java_text::format_fixed2`), and `suggest_coordinates` uses it for the non-relevant arguments. ## Vanilla reference - `ClientSuggestionProvider.getRelevantCoordinates`: `hitResult` of type `BLOCK` → its `BlockPos` (`prettyPrint(int)`), else `SharedSuggestionProvider.getRelevantCoordinates` (`~ ~ ~`). - `ClientSuggestionProvider.getAbsoluteCoordinates`: `hitResult` of type `BLOCK` → `getLocation()` with `prettyPrint(double)` = `String.format(Locale.ROOT, "%.2f", v)`, else `~ ~ ~`. - `BlockPosArgument`/`ColumnPosArgument.listSuggestions` use the relevant coordinates, `Vec3Argument`/`Vec2Argument.listSuggestions` the absolute ones (`SharedSuggestionProvider.suggestCoordinates` / `suggest2DCoordinates`). - `tools/test_chat_screen_parity.py` still passes (`3021/3021 chat screens match`); its oracle uses a server `CommandSourceStack`, so it has no hit result to compare. ## Self-check `tools/pr_ready.py` / `tools/parity.py` stop on Windows (`signal.SIGHUP`), so these ran by hand (Windows 11), on top of main 11494e17f: ``` cargo fmt --all -- --check # ok cargo clippy -p horizon-client-core --all-targets -- -D warnings # ok cargo clippy -p horizon-command --all-targets -- -D warnings # ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings # ok cargo test -p horizon-command # 20 passed python tools/test_chat_screen_parity.py # 3021/3021 chat screens match ``` New test `tests::coordinates_suggest_the_crosshair_block_or_hit_point` (horizon-command), with `args.rs` back to main: ``` test tests::coordinates_suggest_the_crosshair_block_or_hit_point ... FAILED assertion `left == right` failed left: ["~", "~ ~", "~ ~ ~"] right: ["-28.77", "-28.77 73.28", "-28.77 73.28 8.00"] ``` With the fix: `ok`. The entity check is in the game binary (`refresh_dynamic_registries`), shown in game below. ## Screenshots Checked in game (screenshots taken locally; the suggestions they show are listed here). Server-thread single player, creative: a stone wall, a `NoAI` pig in front of it. | | Before (main) | After | |---|---|---| | Crosshair on the pig, `/setblock ` | `205`, `205 99`, `205 99 539` (the block behind the pig) | `~`, `~ ~`, `~ ~ ~` | | Crosshair on the wall (hit 204.044, 102.371, 540.0), `/summon minecraft:pig ` | `~`, `~ ~`, `~ ~ ~` | `204.04`, `204.04 102.37`, `204.04 102.37 540.00` | | Same, `/setblock ` | the wall block (not captured) | `204`, `204 102`, `204 102 540` (same as main) | 🤖 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:10:05 +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#5078
No description provided.