[PR #4247] [MERGED] F3+I copies the server's data on servers and LAN #5517

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

📋 Pull Request Information

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

Base: main ← Head: fix-3518-tag-query


📝 Commits (2)

  • ef024a0 F3+I copies the server's data on servers and LAN
  • 6be3dad lan_e2e: tag-query check for an operator guest's F3+I

📊 Changes

10 files changed (+391 additions, -40 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+21 -0)
📝 crates/horizon-client/src/game/debug_keys.rs (+196 -28)
📝 crates/horizon-client/src/game/lan_actions.rs (+52 -0)
📝 crates/horizon-client/src/game/remote.rs (+5 -0)
📝 crates/horizon-protocol/src/packets/play.rs (+66 -0)
📝 tools/lan_e2e.py (+41 -2)
📝 tools/port_map/client-002.tsv (+1 -1)
📝 tools/port_map/rest-003.tsv (+4 -4)
📝 tools/port_map/rest-012.tsv (+3 -3)
📝 tools/port_map/rest-018.tsv (+2 -2)

📄 Description

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

What and why

F3+I is meant to copy the server's data for the targeted block or mob, but it always copied the client's partial copy. This happened on a server, as a LAN guest, and in single player too, because the world there runs on its own server thread. The chat still said "Copied server-side block data", yet a chest's /setblock came out as {Items:[]} and a mob's /summon had no Tags, because neither ever reaches the client. The game had no tag query packets at all, only their ids in ids.rs, so nothing asked the server and nothing on the server answered.

Root cause: copy_recreate_command read self.world and self.mobs on every connection. Vanilla's KeyboardHandler.copyRecreateCommand asks the server through DebugQueryHandler instead, and copies the command when the answer comes back.

The fix:

  • horizon-protocol: adds ServerboundBlockEntityTagQueryPacket (VarInt transaction, BlockPos), ServerboundEntityTagQueryPacket (VarInt transaction, VarInt entity id) and ClientboundTagQueryPacket (VarInt transaction, then the nullable compound from writeNbt, where a bare End tag means null).
  • Client (debug_keys.rs, remote.rs):
    • When the game is connected, F3+I without Shift starts a DebugQuery transaction and sends the query.
    • Like startTransaction, the transaction starts at -1 and a new query replaces any query still waiting.
    • The TagQuery answer goes through handleResponse (only an answer to the newest transaction counts, and only once), then copyCreateBlockCommand or copyCreateEntityCommand, and the chat shows debug.inspect.server.*.
    • Shift+F3+I still copies the client's own data. The deprecated in-frame path, where the game's data is the server's, is unchanged.
  • Server side for guests (lan_actions.rs): handleBlockEntityTagQuery and handleEntityTagQuery, for game masters only (permission 2 or higher), in the level of the player who asked.
    • Blocks reply with BlockEntity.saveWithoutMetadata, or null when there is no block entity.
    • Entities reply with saveWithoutId of the entity with that network id, which can be a player in that level.
    • The block code is shared with the client path as block_entity_tag. A new level_entity helper implements Level.getEntity.
  • Ledger: the rows for these methods in tools/port_map change from missing/skip to port or inline.

Part of #3520 (its handleBlockEntityTagQuery and handleEntityTagQuery rows).

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

I read these with javap on the 26.3 client.jar:

  • net.minecraft.client.KeyboardHandler: copyRecreateCommand, copyCreateBlockCommand, copyCreateEntityCommand (removes UUID and Pos), and the lambda$copyRecreateCommand$0/$1 callbacks with debug.inspect.server.block/.entity.
  • net.minecraft.client.DebugQueryHandler: startTransaction (++transactionId from -1), handleResponse (the current transaction only, callback cleared), queryEntityTag, queryBlockEntityTag.
  • ClientboundTagQueryPacket (readVarInt/readNbt), ServerboundBlockEntityTagQueryPacket (readVarInt/readBlockPos), ServerboundEntityTagQueryPacket (readVarInt/readVarInt).
  • net.minecraft.server.network.ServerGamePacketListenerImpl.handleEntityTagQuery and handleBlockEntityTagQuery: a COMMANDS_GAMEMASTER check, ServerLevel.getEntity(id) then saveWithoutId, which sends nothing when the entity is missing, and getBlockEntity(pos) then saveWithoutMetadata, which sends null when there is none.

Checks:

  • New lan_e2e check tag-query (second commit): an operator guest presses F3+I on a chest that holds diamonds and on a pig with a tag, and the copied commands must carry Items and Tags.
  • Unit tests for the packet layouts and for the transaction rules.

Self-check

Windows 11; tools/pr_ready.py doesn't run on Windows, so I ran the steps by hand:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-protocol --all-targets -- -D warnings: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test -p horizon-protocol: 111 passed, including the new packets::play::tests::debug_tag_queries_decode_as_their_packets
  • cargo test -p horizon-client --bin horizon-client: 207 passed, 3 ignored, including the new game::debug_keys::tests::a_debug_query_is_answered_once_and_only_the_newest
  • Without the fix (main's play.rs with only the new test added), cargo test -p horizon-protocol --lib debug_tag_queries doesn't compile: E0422 cannot find struct ... TagQuery / BlockEntityTagQuery / EntityTagQuery, and Serverbound/Clientbound have no such variants.
  • python tools/lan_e2e.py --check tag-query --bin-dir <build>: I ran it through a Windows wrapper that turns symlinks into junctions. The host is on the server thread.
    • Before (main): FAIL AssertionError("the chest's items are missing: /setblock -7 64 12 minecraft:chest[facing=north,type=single,waterlogged=false]{Items:[],components:{}}")
    • After: PASS. The block copy is .../chest[...]{Items:[{Slot:0b,count:5,id:"minecraft:diamond"}],components:{}} and the entity copy holds Tags: ["tag_query"], with "Copied server-side block/entity data to clipboard".
  • python tools/port_ledger.py check didn't run here: it needs decompiled vanilla sources, which this machine doesn't have. The new ledger rows name functions that exist: Game::answer_tag_query, DebugQuery::answer, DebugQuery::start, Game::copy_recreate_command, Game::level_entity_tag, Game::lan_guest_packet.

In game, single player on the server thread:

  • Before, F3+I on a chest with 5 diamonds and 2 golden apples copied {Items:[],components:{}}. After, it copied both stacks.
  • On a pig summoned with Tags:["probe"], the copy had no Tags before and has Tags: ["probe"] after.
  • Shift+F3+I still copies client-side data.
  • As a LAN guest with commands (two games), F3+I copied the chest with its items, the pig with its tags, and the host player's full player data.

Screenshots

before: the setblock command F3+I copied from a filled chest recreates it empty

after: the copied command carries the chest's contents (the server answers the tag query)

Single player on the server thread, same world, place and time of day. I pressed F3+I on a chest holding 5 diamonds and 2 golden apples, removed the chest, ran the copied /setblock command, and opened the new chest.

  • Before: the recreated chest is empty, although the chat said "Copied server-side block data to clipboard".
  • After: the recreated chest holds the 5 diamonds and 2 golden apples.

🤖 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/4247 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3518-tag-query` --- ### 📝 Commits (2) - [`ef024a0`](https://github.com/horizon-rust/horizon/commit/ef024a082ca97b9beec7409e4a4e18a024592855) F3+I copies the server's data on servers and LAN - [`6be3dad`](https://github.com/horizon-rust/horizon/commit/6be3dad37bd36795434267db5089e10edd2f943b) lan_e2e: tag-query check for an operator guest's F3+I ### 📊 Changes **10 files changed** (+391 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+21 -0) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+196 -28) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+52 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+5 -0) 📝 `crates/horizon-protocol/src/packets/play.rs` (+66 -0) 📝 `tools/lan_e2e.py` (+41 -2) 📝 `tools/port_map/client-002.tsv` (+1 -1) 📝 `tools/port_map/rest-003.tsv` (+4 -4) 📝 `tools/port_map/rest-012.tsv` (+3 -3) 📝 `tools/port_map/rest-018.tsv` (+2 -2) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally. ## What and why F3+I is meant to copy the server's data for the targeted block or mob, but it always copied the client's partial copy. This happened on a server, as a LAN guest, and in single player too, because the world there runs on its own server thread. The chat still said "Copied server-side block data", yet a chest's `/setblock` came out as `{Items:[]}` and a mob's `/summon` had no `Tags`, because neither ever reaches the client. The game had no tag query packets at all, only their ids in `ids.rs`, so nothing asked the server and nothing on the server answered. Root cause: `copy_recreate_command` read `self.world` and `self.mobs` on every connection. Vanilla's `KeyboardHandler.copyRecreateCommand` asks the server through `DebugQueryHandler` instead, and copies the command when the answer comes back. The fix: - **horizon-protocol**: adds `ServerboundBlockEntityTagQueryPacket` (VarInt transaction, BlockPos), `ServerboundEntityTagQueryPacket` (VarInt transaction, VarInt entity id) and `ClientboundTagQueryPacket` (VarInt transaction, then the nullable compound from `writeNbt`, where a bare End tag means null). - **Client** (`debug_keys.rs`, `remote.rs`): - When the game is connected, F3+I without Shift starts a `DebugQuery` transaction and sends the query. - Like `startTransaction`, the transaction starts at -1 and a new query replaces any query still waiting. - The `TagQuery` answer goes through `handleResponse` (only an answer to the newest transaction counts, and only once), then `copyCreateBlockCommand` or `copyCreateEntityCommand`, and the chat shows `debug.inspect.server.*`. - Shift+F3+I still copies the client's own data. The deprecated in-frame path, where the game's data is the server's, is unchanged. - **Server side for guests** (`lan_actions.rs`): `handleBlockEntityTagQuery` and `handleEntityTagQuery`, for game masters only (permission 2 or higher), in the level of the player who asked. - Blocks reply with `BlockEntity.saveWithoutMetadata`, or null when there is no block entity. - Entities reply with `saveWithoutId` of the entity with that network id, which can be a player in that level. - The block code is shared with the client path as `block_entity_tag`. A new `level_entity` helper implements `Level.getEntity`. - **Ledger**: the rows for these methods in `tools/port_map` change from missing/skip to port or inline. Part of #3520 (its `handleBlockEntityTagQuery` and `handleEntityTagQuery` rows). ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference I read these with javap on the 26.3 client.jar: - `net.minecraft.client.KeyboardHandler`: `copyRecreateCommand`, `copyCreateBlockCommand`, `copyCreateEntityCommand` (removes `UUID` and `Pos`), and the `lambda$copyRecreateCommand$0`/`$1` callbacks with `debug.inspect.server.block`/`.entity`. - `net.minecraft.client.DebugQueryHandler`: `startTransaction` (`++transactionId` from -1), `handleResponse` (the current transaction only, callback cleared), `queryEntityTag`, `queryBlockEntityTag`. - `ClientboundTagQueryPacket` (`readVarInt`/`readNbt`), `ServerboundBlockEntityTagQueryPacket` (`readVarInt`/`readBlockPos`), `ServerboundEntityTagQueryPacket` (`readVarInt`/`readVarInt`). - `net.minecraft.server.network.ServerGamePacketListenerImpl.handleEntityTagQuery` and `handleBlockEntityTagQuery`: a `COMMANDS_GAMEMASTER` check, `ServerLevel.getEntity(id)` then `saveWithoutId`, which sends nothing when the entity is missing, and `getBlockEntity(pos)` then `saveWithoutMetadata`, which sends null when there is none. Checks: - New lan_e2e check `tag-query` (second commit): an operator guest presses F3+I on a chest that holds diamonds and on a pig with a tag, and the copied commands must carry `Items` and `Tags`. - Unit tests for the packet layouts and for the transaction rules. ## Self-check Windows 11; `tools/pr_ready.py` doesn't run on Windows, so I ran the steps by hand: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-protocol --all-targets -- -D warnings`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test -p horizon-protocol`: 111 passed, including the new `packets::play::tests::debug_tag_queries_decode_as_their_packets` - `cargo test -p horizon-client --bin horizon-client`: 207 passed, 3 ignored, including the new `game::debug_keys::tests::a_debug_query_is_answered_once_and_only_the_newest` - Without the fix (main's `play.rs` with only the new test added), `cargo test -p horizon-protocol --lib debug_tag_queries` doesn't compile: `E0422 cannot find struct ... TagQuery / BlockEntityTagQuery / EntityTagQuery`, and `Serverbound`/`Clientbound` have no such variants. - `python tools/lan_e2e.py --check tag-query --bin-dir <build>`: I ran it through a Windows wrapper that turns symlinks into junctions. The host is on the server thread. - **Before** (main): `FAIL AssertionError("the chest's items are missing: /setblock -7 64 12 minecraft:chest[facing=north,type=single,waterlogged=false]{Items:[],components:{}}")` - **After**: `PASS`. The block copy is `.../chest[...]{Items:[{Slot:0b,count:5,id:"minecraft:diamond"}],components:{}}` and the entity copy holds `Tags: ["tag_query"]`, with "Copied server-side block/entity data to clipboard". - `python tools/port_ledger.py check` didn't run here: it needs decompiled vanilla sources, which this machine doesn't have. The new ledger rows name functions that exist: `Game::answer_tag_query`, `DebugQuery::answer`, `DebugQuery::start`, `Game::copy_recreate_command`, `Game::level_entity_tag`, `Game::lan_guest_packet`. In game, single player on the server thread: - Before, F3+I on a chest with 5 diamonds and 2 golden apples copied `{Items:[],components:{}}`. After, it copied both stacks. - On a pig summoned with `Tags:["probe"]`, the copy had no `Tags` before and has `Tags: ["probe"]` after. - Shift+F3+I still copies client-side data. - As a LAN guest with commands (two games), F3+I copied the chest with its items, the pig with its tags, and the host player's full player data. ## Screenshots ![before: the setblock command F3+I copied from a filled chest recreates it empty](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3518-tag-query-1.png) ![after: the copied command carries the chest's contents (the server answers the tag query)](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/3518-tag-query-2.png) Single player on the server thread, same world, place and time of day. I pressed F3+I on a chest holding 5 diamonds and 2 golden apples, removed the chest, ran the copied `/setblock` command, and opened the new chest. - Before: the recreated chest is empty, although the chat said "Copied server-side block data to clipboard". - After: the recreated chest holds the 5 diamonds and 2 golden apples. 🤖 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:13:07 +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#5517
No description provided.