[PR #2694] [CLOSED] commands: open the command block screen on a server's client #4548

Closed
opened 2026-11-03 04:17:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2694
Author: @levzzz5154
Created: 10/27/2026
Status: ❌ Closed

Base: main ← Head: fix/command-block-editor


📝 Commits (1)

  • 029deff commands: open the command block screen on a server's client

📊 Changes

5 files changed (+106 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/command_block.rs (+17 -0)
📝 crates/horizon-client/src/game/command_blocks.rs (+80 -3)
📝 crates/horizon-client/src/game/lan_actions.rs (+1 -0)
📝 crates/horizon-client/src/game/remote.rs (+1 -0)
📝 crates/horizon-protocol/src/packets/play.rs (+7 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself.

What and why

Right-clicking a command block did nothing for a client connected to a
server (and for a guest on a host): the command block's edit screen is
opened by the level event the window's own server sends
(PlayerEffect::OpenMenu), and a client never gets that event, so
open_command_block was never reached. Vanilla opens the screen on the
client that used the block (Player.openCommandBlock ->
LocalPlayer.openCommandBlock -> CommandBlockEditScreen) and the edit
travels to the server as ServerboundSetCommandBlockPacket, which
ServerGamePacketListenerImpl.handleSetCommandBlock applies when the
player may edit the block.

This pull request ports #2498 (open, based on an older main) onto the
current main: the client opens the screen itself when it uses a command
block it may edit, the edit is sent as ServerboundSetCommandBlock, and
the host applies it for a guest that may edit the block and tells the
clients about the new command. The single-player path (the window's own
server) keeps working as before.

Fixes #2494, Fixes #2600

Vanilla reference

  • net.minecraft.world.level.block.CommandBlock.useWithoutItem (26.3's
    name for what older versions call CommandBlockBlock) —
    if (level.getBlockEntity(pos) instanceof CommandBlockEntity commandBlockEntity && player.canUseGameMasterBlocks()) { player.openCommandBlock(commandBlockEntity); return InteractionResult.SUCCESS; }:
    the block opens its editor when the player may use game master blocks.
  • net.minecraft.world.entity.player.Player.canUseGameMasterBlocks —
    this.abilities.instabuild && this.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER):
    creative mode and the game master permission.
  • net.minecraft.client.gui.screens.inventory.CommandBlockEditScreen and
    AbstractCommandBlockEditScreen — the editor the client shows, with the
    command, the previous output, the mode and the conditional flag.
  • net.minecraft.server.network.ServerGamePacketListenerImpl.handleSetCommandBlock
    — the server's side of the edit: it writes the command, the mode and the
    flags into the block entity when the player may use game master blocks,
    and answers advMode.notAllowed when they may not.
  • net.minecraft.network.protocol.game.ServerboundSetCommandBlockPacket —
    the block position, the command, the mode (an Enum.ordinal) and the
    flags (the output, the conditional and the automatic bits).

Self-check

cargo build -p horizon-client --bin horizon-client (clean, no warnings)
and cargo fmt -p horizon-client (clean) on the branch
fix/command-block-editor (commit 029deff76, based on the current
main 37d31da54).

The port applies cleanly to the current main (git apply --3way of the
patch of #2498 touched five files with no conflict), and the whole
change is 106 added lines.

This is a port of the open pull request #2498; if that one is merged
first, this pull request becomes redundant.

🤖 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/2694 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/command-block-editor` --- ### 📝 Commits (1) - [`029deff`](https://github.com/horizon-rust/horizon/commit/029deff764ac5cc23fcea25e3cfa3fa46131c2bf) commands: open the command block screen on a server's client ### 📊 Changes **5 files changed** (+106 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/command_block.rs` (+17 -0) 📝 `crates/horizon-client/src/game/command_blocks.rs` (+80 -3) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+1 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -0) 📝 `crates/horizon-protocol/src/packets/play.rs` (+7 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself. ## What and why Right-clicking a command block did nothing for a client connected to a server (and for a guest on a host): the command block's edit screen is opened by the level event the *window's own* server sends (`PlayerEffect::OpenMenu`), and a client never gets that event, so `open_command_block` was never reached. Vanilla opens the screen on the client that used the block (`Player.openCommandBlock` -> `LocalPlayer.openCommandBlock` -> `CommandBlockEditScreen`) and the edit travels to the server as `ServerboundSetCommandBlockPacket`, which `ServerGamePacketListenerImpl.handleSetCommandBlock` applies when the player may edit the block. This pull request ports #2498 (open, based on an older main) onto the current `main`: the client opens the screen itself when it uses a command block it may edit, the edit is sent as `ServerboundSetCommandBlock`, and the host applies it for a guest that may edit the block and tells the clients about the new command. The single-player path (the window's own server) keeps working as before. Fixes #2494, Fixes #2600 ## Vanilla reference - `net.minecraft.world.level.block.CommandBlock.useWithoutItem` (26.3's name for what older versions call `CommandBlockBlock`) — `if (level.getBlockEntity(pos) instanceof CommandBlockEntity commandBlockEntity && player.canUseGameMasterBlocks()) { player.openCommandBlock(commandBlockEntity); return InteractionResult.SUCCESS; }`: the block opens its editor when the player may use game master blocks. - `net.minecraft.world.entity.player.Player.canUseGameMasterBlocks` — `this.abilities.instabuild && this.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER)`: creative mode and the game master permission. - `net.minecraft.client.gui.screens.inventory.CommandBlockEditScreen` and `AbstractCommandBlockEditScreen` — the editor the client shows, with the command, the previous output, the mode and the conditional flag. - `net.minecraft.server.network.ServerGamePacketListenerImpl.handleSetCommandBlock` — the server's side of the edit: it writes the command, the mode and the flags into the block entity when the player may use game master blocks, and answers `advMode.notAllowed` when they may not. - `net.minecraft.network.protocol.game.ServerboundSetCommandBlockPacket` — the block position, the command, the mode (an `Enum.ordinal`) and the flags (the output, the conditional and the automatic bits). ## Self-check `cargo build -p horizon-client --bin horizon-client` (clean, no warnings) and `cargo fmt -p horizon-client` (clean) on the branch `fix/command-block-editor` (commit `029deff76`, based on the current `main` `37d31da54`). The port applies cleanly to the current `main` (`git apply --3way` of the patch of #2498 touched five files with no conflict), and the whole change is 106 added lines. This is a port of the open pull request #2498; if that one is merged first, this pull request becomes redundant. 🤖 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 04:17:58 +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#4548
No description provided.