[PR #3566] [MERGED] Respawn anchor: glowstone charges it on a server instead of being placed #5057

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

📋 Pull Request Information

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

Base: main ← Head: fix-3034


📝 Commits (1)

  • ab640c7 Respawn anchor: glowstone charges it on a server instead of being placed

📊 Changes

4 files changed (+91 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+13 -1)
📝 crates/horizon-client/src/game/respawn_anchor.rs (+9 -0)
📝 crates/horizon-world/src/level/interact.rs (+20 -0)
📝 crates/horizon-world/src/level/tests.rs (+49 -0)

📄 Description

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

Fixes #3034
Fixes #3018 (the same bug, reported from Discord: glowstone shows as a block for a split second before it goes into the anchor)

What and why

The bug shows on a server, and in the default single player, where the window's player is a guest of the server thread. Right-clicking a respawn anchor with glowstone made the glowstone appear as a placed block for a moment, until the server took it back and charged the anchor.

The client decides whether a click ends at the block by running the block's useItemOn on a copy of its level (remote_block_reacts → horizon-world use_item_on). horizon-world had no RespawnAnchorBlock.useItemOn. Glowstone fell through to useWithoutItem, which PASSes on an empty anchor, so the client predicted a glowstone placement.

  • horizon-world use_item_on: glowstone on an anchor below 4 charges now charges it (RespawnAnchorBlock.charge: the block, the block_change game event, the sound) and returns SUCCESS. The in-frame game handles the anchor before this point (use_respawn_anchor), so its path is unchanged.
  • Off hand (remote_use_item_on): the client's off-hand turn now runs the anchor's useItemOn too. Glowstone in the off hand used to be predicted as a placement as well.
  • Main hand (remote_block_reacts): the main hand now PASSes when the off hand's glowstone is to charge the anchor. Before, with an empty main hand and off-hand glowstone, a charged anchor ran useWithoutItem (SUCCESS), so the client never sent the off-hand turn and the anchor didn't charge.

Vanilla reference

RespawnAnchorBlock.useItemOn (javap, 26.3 client.jar):

  • isRespawnFuel(stack) (glowstone) and canBeCharged(state) (CHARGE < 4) → charge(player, level, pos, state), stack.consume(1, player), SUCCESS;
  • otherwise, for the main hand, glowstone in the off hand and canBeCharged → PASS;
  • otherwise TRY_WITH_EMPTY_HAND.

RespawnAnchorBlock.charge: setBlockAndUpdate with CHARGE + 1, gameEvent(BLOCK_CHANGE, pos, Context.of(source, newState)), playSound(null, …, RESPAWN_ANCHOR_CHARGE, BLOCKS, 1, 1).

MultiPlayerGameMode.useItemOn runs the block's useItemOn on the client for either hand, and useWithoutItem only for the main hand on TRY_WITH_EMPTY_HAND. A sneaking player with something in either hand skips both, which is unchanged here.

No parity harness covers this block (test_anchor_parity.py is about vertical anchors in worldgen).

Test

cargo test -p horizon-world --lib glowstone_charges_a_respawn_anchor_up_to_four charges an anchor from 0 to 4 with glowstone, checks a full anchor isn't charged, and checks that stone on an empty anchor passes.

Without the fix (interact.rs reverted):

thread 'level::tests::glowstone_charges_a_respawn_anchor_up_to_four' panicked at crates\horizon-world\src\level\tests.rs:677:9:
assertion `left == right` failed
  left: Pass
 right: Success
test level::tests::glowstone_charges_a_respawn_anchor_up_to_four ... FAILED

With it:

test level::tests::glowstone_charges_a_respawn_anchor_up_to_four ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 179 filtered out

In game, LAN guest. Two games: the host opened to LAN, the guest connected through horizon-ctl connect. The host's server-hold on holds the server, so the guest's prediction stays on screen. The anchor is at 212 66 532, and the guest clicks its north face, so a predicted placement would land at 212 66 531.

Case Before (origin/main b19b4e92d) After (this branch)
Main-hand glowstone, empty anchor, server held 212 66 531 = minecraft:glowstone (the ghost; the guest also hears block.glass.place) 212 66 531 = air; then charges=1, only respawn_anchor.charge heard
Off-hand glowstone, empty main hand, empty anchor, server held 212 66 531 = glowstone (ghost) air; then charges=1
Off-hand glowstone, empty main hand, anchor at 2 charges stays at charges=2 (the off-hand turn was never sent) charges=3
Main-hand glowstone, full anchor (overworld) n/a the anchor explodes, as vanilla's useWithoutItem does
Sneaking, main-hand glowstone n/a glowstone is placed, as vanilla does

Self-check

tools/pr_ready.py doesn't run on Windows (parity.py uses signal.SIGHUP, and lan_e2e uses Unix sockets), so I ran these instead:

Rebased on origin/main 11494e17f, then:

  • cargo fmt --all -- --check: ok
  • cargo clippy -p horizon-world --all-targets -- -D warnings: ok
  • cargo clippy -p horizon-client --features mods --all-targets -- -D warnings: ok
  • cargo test -p horizon-world --lib level::tests: 42 passed
  • cargo build --profile fast -p horizon-client --features mods --bins, then the LAN runs above

In-game screenshots (described)

The guest's view while the server is held, right after a main-hand glowstone click on the empty anchor. Before, a full glowstone block stands in front of the anchor and hides most of it. After, the empty anchor is in plain view with no block in front of it, unchanged until the server's update arrives.

🤖 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/3566 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-3034` --- ### 📝 Commits (1) - [`ab640c7`](https://github.com/horizon-rust/horizon/commit/ab640c764680ec3a1a2bad9dffb032f327d1d37c) Respawn anchor: glowstone charges it on a server instead of being placed ### 📊 Changes **4 files changed** (+91 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+13 -1) 📝 `crates/horizon-client/src/game/respawn_anchor.rs` (+9 -0) 📝 `crates/horizon-world/src/level/interact.rs` (+20 -0) 📝 `crates/horizon-world/src/level/tests.rs` (+49 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. Fixes #3034 Fixes #3018 (the same bug, reported from Discord: glowstone shows as a block for a split second before it goes into the anchor) ## What and why The bug shows on a server, and in the default single player, where the window's player is a guest of the server thread. Right-clicking a respawn anchor with glowstone made the glowstone appear as a placed block for a moment, until the server took it back and charged the anchor. The client decides whether a click ends at the block by running the block's `useItemOn` on a copy of its level (`remote_block_reacts` → horizon-world `use_item_on`). horizon-world had no `RespawnAnchorBlock.useItemOn`. Glowstone fell through to `useWithoutItem`, which PASSes on an empty anchor, so the client predicted a glowstone placement. - **horizon-world `use_item_on`:** glowstone on an anchor below 4 charges now charges it (`RespawnAnchorBlock.charge`: the block, the `block_change` game event, the sound) and returns SUCCESS. The in-frame game handles the anchor before this point (`use_respawn_anchor`), so its path is unchanged. - **Off hand (`remote_use_item_on`):** the client's off-hand turn now runs the anchor's `useItemOn` too. Glowstone in the off hand used to be predicted as a placement as well. - **Main hand (`remote_block_reacts`):** the main hand now PASSes when the off hand's glowstone is to charge the anchor. Before, with an empty main hand and off-hand glowstone, a charged anchor ran `useWithoutItem` (SUCCESS), so the client never sent the off-hand turn and the anchor didn't charge. ## Vanilla reference `RespawnAnchorBlock.useItemOn` (javap, 26.3 client.jar): - `isRespawnFuel(stack)` (glowstone) and `canBeCharged(state)` (`CHARGE < 4`) → `charge(player, level, pos, state)`, `stack.consume(1, player)`, `SUCCESS`; - otherwise, for the main hand, glowstone in the off hand and `canBeCharged` → `PASS`; - otherwise `TRY_WITH_EMPTY_HAND`. `RespawnAnchorBlock.charge`: `setBlockAndUpdate` with `CHARGE + 1`, `gameEvent(BLOCK_CHANGE, pos, Context.of(source, newState))`, `playSound(null, …, RESPAWN_ANCHOR_CHARGE, BLOCKS, 1, 1)`. `MultiPlayerGameMode.useItemOn` runs the block's `useItemOn` on the client for either hand, and `useWithoutItem` only for the main hand on `TRY_WITH_EMPTY_HAND`. A sneaking player with something in either hand skips both, which is unchanged here. No parity harness covers this block (`test_anchor_parity.py` is about vertical anchors in worldgen). ## Test `cargo test -p horizon-world --lib glowstone_charges_a_respawn_anchor_up_to_four` charges an anchor from 0 to 4 with glowstone, checks a full anchor isn't charged, and checks that stone on an empty anchor passes. Without the fix (interact.rs reverted): ``` thread 'level::tests::glowstone_charges_a_respawn_anchor_up_to_four' panicked at crates\horizon-world\src\level\tests.rs:677:9: assertion `left == right` failed left: Pass right: Success test level::tests::glowstone_charges_a_respawn_anchor_up_to_four ... FAILED ``` With it: ``` test level::tests::glowstone_charges_a_respawn_anchor_up_to_four ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 179 filtered out ``` **In game, LAN guest.** Two games: the host opened to LAN, the guest connected through `horizon-ctl connect`. The host's `server-hold on` holds the server, so the guest's prediction stays on screen. The anchor is at 212 66 532, and the guest clicks its north face, so a predicted placement would land at 212 66 531. | Case | Before (origin/main b19b4e92d) | After (this branch) | | --- | --- | --- | | Main-hand glowstone, empty anchor, server held | `212 66 531` = `minecraft:glowstone` (the ghost; the guest also hears `block.glass.place`) | `212 66 531` = air; then `charges=1`, only `respawn_anchor.charge` heard | | Off-hand glowstone, empty main hand, empty anchor, server held | `212 66 531` = glowstone (ghost) | air; then `charges=1` | | Off-hand glowstone, empty main hand, anchor at 2 charges | stays at `charges=2` (the off-hand turn was never sent) | `charges=3` | | Main-hand glowstone, full anchor (overworld) | n/a | the anchor explodes, as vanilla's `useWithoutItem` does | | Sneaking, main-hand glowstone | n/a | glowstone is placed, as vanilla does | ## Self-check `tools/pr_ready.py` doesn't run on Windows (`parity.py` uses `signal.SIGHUP`, and lan_e2e uses Unix sockets), so I ran these instead: Rebased on origin/main 11494e17f, then: - `cargo fmt --all -- --check`: ok - `cargo clippy -p horizon-world --all-targets -- -D warnings`: ok - `cargo clippy -p horizon-client --features mods --all-targets -- -D warnings`: ok - `cargo test -p horizon-world --lib level::tests`: 42 passed - `cargo build --profile fast -p horizon-client --features mods --bins`, then the LAN runs above ## In-game screenshots (described) The guest's view while the server is held, right after a main-hand glowstone click on the empty anchor. Before, a full glowstone block stands in front of the anchor and hides most of it. After, the empty anchor is in plain view with no block in front of it, unchanged until the server's update arrives. 🤖 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:09:55 +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#5057
No description provided.