[PR #1828] [MERGED] Close crafting tables that are removed or out of reach #3796

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

📋 Pull Request Information

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

Base: main ← Head: fix/1335-crafting-table-valid


📝 Commits (4)

  • ed7d88b Close container menus when the player moves out of reach
  • 18ec414 Close crafting tables that are removed or out of reach
  • 6d3cd33 One isWithinBlockInteractionRange for guests, the in-frame player, stations, lecterns and signs
  • ee74553 Merge #1827 (container reach) into #1828: share its reach helper

📊 Changes

10 files changed (+191 additions, -45 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+5 -0)
📝 crates/horizon-client/src/game/block_entity_ticks.rs (+2 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+38 -4)
📝 crates/horizon-client/src/game/lan_crafting.rs (+55 -14)
📝 crates/horizon-client/src/game/lan_stations.rs (+2 -26)
📝 crates/horizon-client/src/game/sign_edit.rs (+1 -1)
📝 crates/horizon-client/src/game/storage.rs (+46 -0)
📝 crates/horizon-client/src/lan/containers.rs (+6 -0)
📝 crates/horizon-client/src/lan/guest.rs (+23 -0)
📝 crates/horizon-client/src/lan/menu.rs (+13 -0)

📄 Description

What and why

Fixes #1335.

An open crafting table did not remember where it was, so nothing could check that it was still valid. After removing the table or teleporting 20 blocks away, the 3x3 grid stayed open and could still craft. Vanilla closes the menu when the block is no longer a crafting table or the player is out of reach, and gives the grid back.

  • The table's position is now stored with the open grid (in-frame) and with a guest's table menu (server thread and LAN).
  • In-frame single player: each tick the open table closes when its block is no longer a crafting table or the player's eyes are out of reach (block interaction range plus 4). Closing goes through the normal close, which returns the grid and the carried stack.
  • Server thread and LAN guests: the same check runs per tick for each guest's table; an invalid table closes with ContainerClose, the grid goes back to the inventory (dropped if full) and the carried stack is returned. Clicks on an invalid table do nothing.

Vanilla reference

  • CraftingMenu.stillValid -> AbstractContainerMenu.stillValid(access, player, Blocks.CRAFTING_TABLE): the block at the access position is a crafting table and Player.isWithinBlockInteractionRange(pos, 4.0).
  • ServerPlayer.tick: closeContainer when the menu is not stillValid; CraftingMenu.removed clears the grid back to the player (clearContainer).
  • ServerGamePacketListenerImpl.handleContainerClick: no click on a menu that is not stillValid.

No harness covers menu validity yet; I ran the existing harnesses for the touched crafting and LAN code: python3 tools/parity.py lan place_recipe ghost_recipe (3 passed). cargo check -p horizon-client is clean. parity.py --changed origin/main selects nearly every harness for a horizon-client change, so I did not run the full set.

Self-check

pr_ready (tools/pr_ready.py --quick on device-591, against origin/main at 220f05764, 3 min 57 s)

Check Result
Scope ✅ 4 files, +102 −18
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (14 s)
clippy ✅ (40 s)
tests: horizon-client ✅ 1236 passed (2 min 57 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 319 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, bamboo, basic_feature and 307 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🔄 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/1828 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/1335-crafting-table-valid` --- ### 📝 Commits (4) - [`ed7d88b`](https://github.com/horizon-rust/horizon/commit/ed7d88b2135e81b19238c3ffb39ede17b838aee6) Close container menus when the player moves out of reach - [`18ec414`](https://github.com/horizon-rust/horizon/commit/18ec4145c46400864f921987ed4d601fd1979f04) Close crafting tables that are removed or out of reach - [`6d3cd33`](https://github.com/horizon-rust/horizon/commit/6d3cd330d1f9b24b560c19c1701f39b1ed9b87cd) One isWithinBlockInteractionRange for guests, the in-frame player, stations, lecterns and signs - [`ee74553`](https://github.com/horizon-rust/horizon/commit/ee74553314a4a3bde139f199f394db5af29771a0) Merge #1827 (container reach) into #1828: share its reach helper ### 📊 Changes **10 files changed** (+191 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+5 -0) 📝 `crates/horizon-client/src/game/block_entity_ticks.rs` (+2 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+38 -4) 📝 `crates/horizon-client/src/game/lan_crafting.rs` (+55 -14) 📝 `crates/horizon-client/src/game/lan_stations.rs` (+2 -26) 📝 `crates/horizon-client/src/game/sign_edit.rs` (+1 -1) 📝 `crates/horizon-client/src/game/storage.rs` (+46 -0) 📝 `crates/horizon-client/src/lan/containers.rs` (+6 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+23 -0) 📝 `crates/horizon-client/src/lan/menu.rs` (+13 -0) </details> ### 📄 Description ## What and why Fixes #1335. An open crafting table did not remember where it was, so nothing could check that it was still valid. After removing the table or teleporting 20 blocks away, the 3x3 grid stayed open and could still craft. Vanilla closes the menu when the block is no longer a crafting table or the player is out of reach, and gives the grid back. - The table's position is now stored with the open grid (in-frame) and with a guest's table menu (server thread and LAN). - In-frame single player: each tick the open table closes when its block is no longer a crafting table or the player's eyes are out of reach (block interaction range plus 4). Closing goes through the normal close, which returns the grid and the carried stack. - Server thread and LAN guests: the same check runs per tick for each guest's table; an invalid table closes with ContainerClose, the grid goes back to the inventory (dropped if full) and the carried stack is returned. Clicks on an invalid table do nothing. ## Vanilla reference - `CraftingMenu.stillValid` -> `AbstractContainerMenu.stillValid(access, player, Blocks.CRAFTING_TABLE)`: the block at the access position is a crafting table and `Player.isWithinBlockInteractionRange(pos, 4.0)`. - `ServerPlayer.tick`: `closeContainer` when the menu is not `stillValid`; `CraftingMenu.removed` clears the grid back to the player (`clearContainer`). - `ServerGamePacketListenerImpl.handleContainerClick`: no click on a menu that is not `stillValid`. No harness covers menu validity yet; I ran the existing harnesses for the touched crafting and LAN code: `python3 tools/parity.py lan place_recipe ghost_recipe` (3 passed). `cargo check -p horizon-client` is clean. `parity.py --changed origin/main` selects nearly every harness for a horizon-client change, so I did not run the full set. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on device-591, against origin/main at 220f05764, 3 min 57 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +102 −18 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (14 s) | | clippy | ✅ (40 s) | | tests: horizon-client | ✅ 1236 passed (2 min 57 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 319 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, bamboo, basic_feature and 307 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:12:23 +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#3796
No description provided.