[PR #483] [MERGED] World Options: Edit Game Rules (InWorldGameRulesScreen) #2597

Closed
opened 2026-11-02 15:57:30 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/483
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: fix/world-options-game-rules


📝 Commits (2)

  • e27e556 World Options: the difficulty lock (with its question) and Restrictions
  • a950a04 World Options: Edit Game Rules (InWorldGameRulesScreen)

📊 Changes

8 files changed (+1123 additions, -33 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+5 -1)
📝 crates/horizon-client/src/game/control.rs (+4 -1)
➕ crates/horizon-client/src/game/game_rules_screen.rs (+593 -0)
📝 crates/horizon-client/src/game/lan.rs (+2 -2)
📝 crates/horizon-client/src/game/lan_screen.rs (+486 -25)
📝 crates/horizon-client/src/game/options.rs (+3 -1)
📝 crates/horizon-client/src/hud.rs (+20 -0)
📝 crates/horizon-client/src/save.rs (+10 -3)

📄 Description

Fixes #464 (the Game Rules part; Lock and Restrictions are #482, which this stacks on).

What vanilla 26.3 does

  • WorldOptionsScreen.createGameRulesButton opens InWorldGameRulesScreen, whose exit callback returns to World Options. updateButton enables the button when the level isn't hardcore and the player has gamemaster permission. The Allow Commands switch calls updatePermissionDependentButtons(.., false), which leaves the Game Rules button alone, so the button only follows commands once they are applied.
  • AbstractGameRulesScreen:
    • Header 12 + 9 + 15: the title over a 200×15 search box, which has initial focus and the gray italic gui.game_rule.search hint. Footer: Done and Cancel.
    • RuleList: one entry per category (gamerule.category.minecraft.*, bold, yellow, underlined), sorted by category id, then the rules sorted by description id. Entries are 24 px in 220 px rows.
    • Bool rules get a 44×20 ON/OFF CycleButton. Integer rules get a 44×20 EditBox validated by GameRule.deserialize (Brigadier readInt, then the rule's range). Invalid text turns red (-65536) and Done is disabled.
    • The filter matches the id, the name, the category name or the description.
    • Tooltip: the id in yellow, the description if it resolves, then editGamerule.default in gray.
  • InWorldGameRulesScreen.onDone sends ServerboundSetGameRulePacket with the changed rules. ServerGamePacketListenerImpl.handleSetGameRule sets them for a gamemaster and sends commands.gamerule.set to operators. onClose with pending changes opens a ConfirmScreen (editGamerule.inGame.discardChanges.*): Yes discards, No returns. Escape answers No.

Changes

  • New game/game_rules_screen.rs, which World Options opens as a sub-view. The wanted World Options state is kept across it, as repositionElements keeps it.
  • horizon-ctl type now reaches World Options' text boxes (the port, search and number boxes), so the screen can be scripted.

Verified

In game: offscreen, control socket, GUI scale 3 at 1280×720.

  • With commands off, Edit Game Rules is disabled, and toggling Allow Commands alone does not enable it. After Apply and reopening, it is enabled.
  • The list matches vanilla's geometry: controls at x = 276, scrollbar at 331, category headings at top + 8.
  • Searching "tick" shows the Player and World Updates rules (the portal-delay rules match on their descriptions).
  • Typing 3+ turns the text red and disables Done. 10 is valid again.
  • Done prints "Game rule random_tick_speed is now set to 10" and "… command_block_output … false", and /gamerule reads both back.
  • Escape with changes shows the ConfirmScreen (title at y 85, buttons at y 135, matching ConfirmScreen's layout). No returns to the rules; Cancel → Yes discards, and /gamerule log_admin_commands is still true.

Tests:

  • numbers_parse_like_brigadier_within_the_rule
  • rows_group_categories_and_rules_by_description_id
  • edits_change_rules_and_bad_numbers_hold_done
  • box_colours_are_vanillas
  • an extended buttons_follow_commands_hardcore_and_lan

cargo fmt and clippy -D warnings are clean.

🤖 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/483 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/world-options-game-rules` --- ### 📝 Commits (2) - [`e27e556`](https://github.com/horizon-rust/horizon/commit/e27e556ab27994d0d397cf8cbf0a03abd423ebc6) World Options: the difficulty lock (with its question) and Restrictions - [`a950a04`](https://github.com/horizon-rust/horizon/commit/a950a046aeabd47dc1afc9c3d06b08754ac314d1) World Options: Edit Game Rules (InWorldGameRulesScreen) ### 📊 Changes **8 files changed** (+1123 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+5 -1) 📝 `crates/horizon-client/src/game/control.rs` (+4 -1) ➕ `crates/horizon-client/src/game/game_rules_screen.rs` (+593 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+2 -2) 📝 `crates/horizon-client/src/game/lan_screen.rs` (+486 -25) 📝 `crates/horizon-client/src/game/options.rs` (+3 -1) 📝 `crates/horizon-client/src/hud.rs` (+20 -0) 📝 `crates/horizon-client/src/save.rs` (+10 -3) </details> ### 📄 Description Fixes #464 (the Game Rules part; Lock and Restrictions are #482, which this stacks on). ## What vanilla 26.3 does - `WorldOptionsScreen.createGameRulesButton` opens `InWorldGameRulesScreen`, whose exit callback returns to World Options. `updateButton` enables the button when the level isn't hardcore and the player has gamemaster permission. The Allow Commands switch calls `updatePermissionDependentButtons(.., false)`, which leaves the Game Rules button alone, so the button only follows commands once they are applied. - `AbstractGameRulesScreen`: - Header 12 + 9 + 15: the title over a 200×15 search box, which has initial focus and the gray italic `gui.game_rule.search` hint. Footer: Done and Cancel. - `RuleList`: one entry per category (`gamerule.category.minecraft.*`, bold, yellow, underlined), sorted by category id, then the rules sorted by description id. Entries are 24 px in 220 px rows. - Bool rules get a 44×20 ON/OFF CycleButton. Integer rules get a 44×20 EditBox validated by `GameRule.deserialize` (Brigadier `readInt`, then the rule's range). Invalid text turns red (`-65536`) and Done is disabled. - The filter matches the id, the name, the category name or the description. - Tooltip: the id in yellow, the description if it resolves, then `editGamerule.default` in gray. - `InWorldGameRulesScreen.onDone` sends `ServerboundSetGameRulePacket` with the changed rules. `ServerGamePacketListenerImpl.handleSetGameRule` sets them for a gamemaster and sends `commands.gamerule.set` to operators. `onClose` with pending changes opens a `ConfirmScreen` (`editGamerule.inGame.discardChanges.*`): Yes discards, No returns. Escape answers No. ## Changes - New `game/game_rules_screen.rs`, which World Options opens as a sub-view. The wanted World Options state is kept across it, as `repositionElements` keeps it. - `horizon-ctl type` now reaches World Options' text boxes (the port, search and number boxes), so the screen can be scripted. ## Verified In game: offscreen, control socket, GUI scale 3 at 1280×720. - With commands off, Edit Game Rules is disabled, and toggling Allow Commands alone does not enable it. After Apply and reopening, it is enabled. - The list matches vanilla's geometry: controls at x = 276, scrollbar at 331, category headings at top + 8. - Searching "tick" shows the Player and World Updates rules (the portal-delay rules match on their descriptions). - Typing `3+` turns the text red and disables Done. `10` is valid again. - Done prints "Game rule random_tick_speed is now set to 10" and "… command_block_output … false", and `/gamerule` reads both back. - Escape with changes shows the ConfirmScreen (title at y 85, buttons at y 135, matching ConfirmScreen's layout). No returns to the rules; Cancel → Yes discards, and `/gamerule log_admin_commands` is still true. Tests: - `numbers_parse_like_brigadier_within_the_rule` - `rows_group_categories_and_rules_by_description_id` - `edits_change_rules_and_bad_numbers_hold_done` - `box_colours_are_vanillas` - an extended `buttons_follow_commands_hardcore_and_lan` `cargo fmt` and `clippy -D warnings` are clean. 🤖 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-02 15:57:30 +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#2597
No description provided.