[PR #6899] [MERGED] Format command numbers like Java %.Nf (worldborder, spreadplayers, debug, tp) #7177

Closed
opened 2026-11-03 06:35:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6899
Author: @ClickingMaster
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/cmds-parity


📝 Commits (3)

  • aeaf04a Format command numbers like Java's %.Nf (half-up on shortest decimal)
  • 82fef33 Merge remote-tracking branch 'origin/main' into fix/cmds-parity
  • 98bbccc Merge main into #6899

📊 Changes

4 files changed (+31 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+24 -1)
📝 crates/horizon-client/src/game/commands/extra.rs (+1 -1)
📝 crates/horizon-client/src/game/commands/terrain_cmds.rs (+4 -4)
📝 crates/horizon-client/src/game/commands/world_cmds.rs (+2 -2)

📄 Description

🤖 Opened by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally.

Fixes #6890

Cause

/worldborder (get, set, damage, center), /spreadplayers, /debug stop and /tp formatted numbers with format!("{:.N}"). Vanilla uses String.format(Locale.ROOT, "%.Nf"), which rounds the shortest decimal text half-up. Rust rounds the exact binary value half-even, so 10.35 gave 10.3 (vanilla 10.4) and 10.5 with %.0f gave 10 (vanilla 11).

Fix

New percent_f in game/commands.rs calls the existing java_text::format_fixed; the call sites in terrain_cmds.rs, world_cmds.rs, extra.rs and format_double use it.

Test

game::commands::percent_f_tests (expected values from Java's %.Nf semantics: 10.35 -> 10.4, 5.125 -> 5.13, 10.5 -> 11, 0.1234565 -> 0.123457). Before the fix (helper still using {:.N}): FAILED, left 10.3, right 10.4. After: passes.

Self-check

  • cargo test -p horizon-client --no-default-features --lib --bins percent_f: 1 passed
  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client --no-default-features --lib --bins -- -D warnings: clean
  • Not run: tools/pr_ready.py, full test suite, port_ledger.py check, lan_e2e.

🤖 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/6899 **Author:** [@ClickingMaster](https://github.com/ClickingMaster) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/cmds-parity` --- ### 📝 Commits (3) - [`aeaf04a`](https://github.com/horizon-rust/horizon/commit/aeaf04a44eb7f96b4caa2d989025d5d564206d10) Format command numbers like Java's %.Nf (half-up on shortest decimal) - [`82fef33`](https://github.com/horizon-rust/horizon/commit/82fef33c48399f78106d4825a17ba03c3106ca54) Merge remote-tracking branch 'origin/main' into fix/cmds-parity - [`98bbccc`](https://github.com/horizon-rust/horizon/commit/98bbcccf99426ba68c988ebfd7f5d21234a98be5) Merge main into #6899 ### 📊 Changes **4 files changed** (+31 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+24 -1) 📝 `crates/horizon-client/src/game/commands/extra.rs` (+1 -1) 📝 `crates/horizon-client/src/game/commands/terrain_cmds.rs` (+4 -4) 📝 `crates/horizon-client/src/game/commands/world_cmds.rs` (+2 -2) </details> ### 📄 Description > 🤖 Opened by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally. Fixes #6890 ## Cause `/worldborder` (get, set, damage, center), `/spreadplayers`, `/debug stop` and `/tp` formatted numbers with `format!("{:.N}")`. Vanilla uses `String.format(Locale.ROOT, "%.Nf")`, which rounds the shortest decimal text half-up. Rust rounds the exact binary value half-even, so `10.35` gave `10.3` (vanilla `10.4`) and `10.5` with `%.0f` gave `10` (vanilla `11`). ## Fix New `percent_f` in `game/commands.rs` calls the existing `java_text::format_fixed`; the call sites in `terrain_cmds.rs`, `world_cmds.rs`, `extra.rs` and `format_double` use it. ## Test `game::commands::percent_f_tests` (expected values from Java's `%.Nf` semantics: 10.35 -> 10.4, 5.125 -> 5.13, 10.5 -> 11, 0.1234565 -> 0.123457). Before the fix (helper still using `{:.N}`): FAILED, left `10.3`, right `10.4`. After: passes. ## Self-check - `cargo test -p horizon-client --no-default-features --lib --bins percent_f`: 1 passed - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client --no-default-features --lib --bins -- -D warnings`: clean - Not run: `tools/pr_ready.py`, full test suite, `port_ledger.py check`, lan_e2e. 🤖 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 06:35:18 +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#7177
No description provided.