[PR #7576] Fix /worldborder's size-limit message #7685

Open
opened 2026-11-03 07:21:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7576
Author: @MSedgeMC
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/worldborder-limit


📝 Commits (2)

  • 8cc8b8e fix: /worldborder set names the size limit as vanilla prints it
  • 2694dee test: the too-big message names the limit as Java prints it

📊 Changes

1 file changed (+24 additions, -1 deletions)

View changed files

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

📄 Description

/worldborder set (and /worldborder add) refuse a size above the limit with
commands.worldborder.set.failed.big, and vanilla names the limit in that
message with the same double it checks against.

Vanilla

javap -p -c -constants net.minecraft.server.commands.WorldBorderCommand:

  • setSize(source, distance, time) rejects distance > 5.9999968E7d
    (ldc2_w #37 // double 5.9999968E7d, then ERROR_TOO_BIG.create()), and
  • <clinit> builds ERROR_TOO_BIG as
    Component.translatable("commands.worldborder.set.failed.big", 5.9999968E7d)
    — the same constant, as a boxed Double argument.

A translatable substitutes a plain argument with String.valueOf, so the number
in that message is Double.toString(59999968.0), i.e. 5.9999968E7 — Java
switches to scientific notation from 1.0E7 up, and the shortest round-tripping
digits are kept.

Horizon

crates/horizon-client/src/game/commands/terrain_cmds.rs compares against
worldborder::MAX_SIZE (59_999_968.0, correct) but passed the hand-written
string "5.999997E7" as the message argument, a rounded form vanilla never
prints.

The message now renders the same constant through
java_text::double_to_string, so the number in the error and the number in
the check can no longer drift apart.

Proven: the error's argument before the change is 5.999997E7, after it
5.9999968E7 (Double.toString of 5.9999968E7d); vanilla's <clinit>
pushes exactly 5.9999968E7d. The new unit test
the_too_big_message_names_the_limit_as_vanilla_prints_it asserts the
rendered text, so it fails on the old literal and passes now
(cargo test -q -p horizon-client --lib the_too_big, 1 passed).

Not proven: no run of the command itself in a world (the message text is
built by the same err(...) call the command already used); the size
boundary itself is unchanged, so no /worldborder set behaviour other than
the message differs.


🔄 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/7576 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/worldborder-limit` --- ### 📝 Commits (2) - [`8cc8b8e`](https://github.com/horizon-rust/horizon/commit/8cc8b8e4384bedf8d4c57f59b8fa01c892768c77) fix: /worldborder set names the size limit as vanilla prints it - [`2694dee`](https://github.com/horizon-rust/horizon/commit/2694deeb70ef99be93dd0a31d2ff86e9c543980e) test: the too-big message names the limit as Java prints it ### 📊 Changes **1 file changed** (+24 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/terrain_cmds.rs` (+24 -1) </details> ### 📄 Description `/worldborder set` (and `/worldborder add`) refuse a size above the limit with `commands.worldborder.set.failed.big`, and vanilla names the limit in that message with the same double it checks against. ### Vanilla `javap -p -c -constants net.minecraft.server.commands.WorldBorderCommand`: * `setSize(source, distance, time)` rejects `distance > 5.9999968E7d` (`ldc2_w #37 // double 5.9999968E7d`, then `ERROR_TOO_BIG.create()`), and * `<clinit>` builds `ERROR_TOO_BIG` as `Component.translatable("commands.worldborder.set.failed.big", 5.9999968E7d)` — the same constant, as a boxed `Double` argument. A translatable substitutes a plain argument with `String.valueOf`, so the number in that message is `Double.toString(59999968.0)`, i.e. `5.9999968E7` — Java switches to scientific notation from 1.0E7 up, and the shortest round-tripping digits are kept. ### Horizon `crates/horizon-client/src/game/commands/terrain_cmds.rs` compares against `worldborder::MAX_SIZE` (`59_999_968.0`, correct) but passed the hand-written string `"5.999997E7"` as the message argument, a rounded form vanilla never prints. The message now renders the same constant through `java_text::double_to_string`, so the number in the error and the number in the check can no longer drift apart. **Proven:** the error's argument before the change is `5.999997E7`, after it `5.9999968E7` (`Double.toString` of `5.9999968E7d`); vanilla's `<clinit>` pushes exactly `5.9999968E7d`. The new unit test `the_too_big_message_names_the_limit_as_vanilla_prints_it` asserts the rendered text, so it fails on the old literal and passes now (`cargo test -q -p horizon-client --lib the_too_big`, 1 passed). **Not proven:** no run of the command itself in a world (the message text is built by the same `err(...)` call the command already used); the size boundary itself is unchanged, so no `/worldborder set` behaviour other than the message differs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7685
No description provided.