[PR #163] [MERGED] Respawn anchors charge, set the respawn point, explode outside the Nether #2365

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

📋 Pull Request Information

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

Base: main ← Head: fix/respawn-anchors-99


📝 Commits (1)

  • 1596210 Respawn anchors charge, set the respawn point, explode outside the Nether

📊 Changes

12 files changed (+974 additions, -52 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+68 -13)
📝 crates/horizon-client/src/game/commands.rs (+1 -0)
📝 crates/horizon-client/src/game/dispense_fixture.rs (+50 -2)
📝 crates/horizon-client/src/game/end.rs (+4 -2)
📝 crates/horizon-client/src/game/explosion.rs (+60 -19)
➕ crates/horizon-client/src/game/respawn_anchor.rs (+542 -0)
📝 crates/horizon-client/src/game/screens.rs (+10 -0)
📝 crates/horizon-client/src/items.rs (+40 -2)
📝 crates/horizon-client/src/save.rs (+28 -3)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockUpdateOracle.java (+22 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java (+45 -2)
📝 tools/test_use_item_on_parity.py (+104 -9)

📄 Description

What was wrong

Respawn anchors did nothing. Glowstone on an anchor wasn't handled at all, and a right click on a charged anchor (charged by a dispenser, say) reached the game as a RespawnAnchor player effect that was ignored: no respawn point in the Nether, no explosion elsewhere. Dying could never send you back to an anchor, and dying in the Nether without one respawned you in the Nether at the Overworld's spawn coordinates.

What vanilla does

  • RespawnAnchorBlock.useItemOn: glowstone on an anchor below 4 charges charges it (setBlockAndUpdate, BLOCK_CHANGE with the new state, block.respawn_anchor.charge) and consumes one; the main hand PASSes when the off hand holds glowstone, so the off hand charges it; otherwise TRY_WITH_EMPTY_HAND. ITEM_USED_ON_BLOCK gives nether/charge_respawn_anchor.
  • useWithoutItem on a charged anchor: canSetSpawn (the respawn_anchor_works environment attribute, true only in the Nether). There: setRespawnPosition(RespawnConfig(Nether, pos), true) with the block.minecraft.set_spawn message and block.respawn_anchor.set_spawn unless it's already the point. Elsewhere explode: removeBlock, then level.explode(null, badRespawnPointExplosion, calculator, centre, 5, fire=true, ExplosionInteraction.BLOCK) where the calculator gives the anchor's own position water's resistance when isWaterThatWouldFlow on a side or water above.
  • ServerPlayer.findRespawnAndUseSpawnBlock: an anchor with a charge in a dimension where it works → findStandUpPosition (RESPAWN_OFFSETS with DismountHelper.findSafeDismountLocation, the safe pass then the unsafe one), uses a charge, yaw from RespawnPosAngle.calculateLookAtYaw; PlayerList.respawn plays respawn_anchor.deplete (seeded from the level random); missing → world spawn and block.minecraft.spawn.not_valid.
  • ServerExplosion: explode game event, positions, entities, interactWithBlocks (shuffle, onExplosionHit; loot with EXPLOSION_RADIUS under DESTROY_WITH_DECAY, so survives_explosion/explosion_decay draw from the table's random sequence; TntBlock.wasExploded primes with a short fuse and no game event), then createFire over the shuffled list with BaseFireBlock.getState.

The fix

  • game/respawn_anchor.rs: charging (main and off hand), setting the point, the explosion, findStandUpPosition/DismountHelper, respawning at the anchor (travel to its dimension, wait for its chunks, use a charge, deplete sound) and the missing-anchor fallback. The point is saved in the player's respawn compound with its dimension; a bed or /spawnpoint replaces it. Dying in the Nether without one respawns in the Overworld.
  • game/explosion.rs: server_explode_as with a damage type and a resistance override; fire through BaseFireBlock.getState; the explosion radius in the block loot context (items.rs); wasExploded without the prime_fuse game event and with tnt_explodes.

How it was tested

  • tools/test_use_item_on_parity.py (real ServerPlayerGameMode.useItemOn) now also clicks anchors (0–4 charges, glowstone, other items, empty hand, sneaking, creative, the off hand) in the Nether and the Overworld, with blocks, TNT and water (source and flowing) around them, and the explosions run vanilla's real ServerExplosion on the stand-in level (oracle: Nether dimension type and attributes, ServerLevel.explode). New respawn cases call ServerPlayer.findRespawnAndUseSpawnBlock on anchors among stone, slabs, lava, fire, magma, cactus, berry bushes, powder snow, ladders, trapdoors, campfires… and compare the position, the yaw bits and the charge used. 4,000 / 4,000 cases match (133 explosions, 216 respawn spots found, every block change, drop, sound, game event, message and the final level random).
  • tools/test_dispenser_parity.py 6,000 / 6,000 (dispensers charging anchors, TNT).
  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace, tools/check_public_tree.py.

This PR and #146 both extend VanillaDispenserOracle/test_use_item_on_parity.py; whichever merges second gets a rebase.

Fixes #99

🤖 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/163 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/respawn-anchors-99` --- ### 📝 Commits (1) - [`1596210`](https://github.com/horizon-rust/horizon/commit/1596210bba2e71fc117aed34190a2ea0dcca83da) Respawn anchors charge, set the respawn point, explode outside the Nether ### 📊 Changes **12 files changed** (+974 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+68 -13) 📝 `crates/horizon-client/src/game/commands.rs` (+1 -0) 📝 `crates/horizon-client/src/game/dispense_fixture.rs` (+50 -2) 📝 `crates/horizon-client/src/game/end.rs` (+4 -2) 📝 `crates/horizon-client/src/game/explosion.rs` (+60 -19) ➕ `crates/horizon-client/src/game/respawn_anchor.rs` (+542 -0) 📝 `crates/horizon-client/src/game/screens.rs` (+10 -0) 📝 `crates/horizon-client/src/items.rs` (+40 -2) 📝 `crates/horizon-client/src/save.rs` (+28 -3) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockUpdateOracle.java` (+22 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java` (+45 -2) 📝 `tools/test_use_item_on_parity.py` (+104 -9) </details> ### 📄 Description ## What was wrong Respawn anchors did nothing. Glowstone on an anchor wasn't handled at all, and a right click on a charged anchor (charged by a dispenser, say) reached the game as a `RespawnAnchor` player effect that was ignored: no respawn point in the Nether, no explosion elsewhere. Dying could never send you back to an anchor, and dying in the Nether without one respawned you in the Nether at the Overworld's spawn coordinates. ## What vanilla does - `RespawnAnchorBlock.useItemOn`: glowstone on an anchor below 4 charges `charge`s it (`setBlockAndUpdate`, `BLOCK_CHANGE` with the new state, `block.respawn_anchor.charge`) and consumes one; the main hand `PASS`es when the off hand holds glowstone, so the off hand charges it; otherwise `TRY_WITH_EMPTY_HAND`. `ITEM_USED_ON_BLOCK` gives `nether/charge_respawn_anchor`. - `useWithoutItem` on a charged anchor: `canSetSpawn` (the `respawn_anchor_works` environment attribute, true only in the Nether). There: `setRespawnPosition(RespawnConfig(Nether, pos), true)` with the `block.minecraft.set_spawn` message and `block.respawn_anchor.set_spawn` unless it's already the point. Elsewhere `explode`: `removeBlock`, then `level.explode(null, badRespawnPointExplosion, calculator, centre, 5, fire=true, ExplosionInteraction.BLOCK)` where the calculator gives the anchor's own position water's resistance when `isWaterThatWouldFlow` on a side or water above. - `ServerPlayer.findRespawnAndUseSpawnBlock`: an anchor with a charge in a dimension where it works → `findStandUpPosition` (`RESPAWN_OFFSETS` with `DismountHelper.findSafeDismountLocation`, the safe pass then the unsafe one), uses a charge, yaw from `RespawnPosAngle.calculateLookAtYaw`; `PlayerList.respawn` plays `respawn_anchor.deplete` (seeded from the level random); missing → world spawn and `block.minecraft.spawn.not_valid`. - `ServerExplosion`: `explode` game event, positions, entities, `interactWithBlocks` (shuffle, `onExplosionHit`; loot with `EXPLOSION_RADIUS` under `DESTROY_WITH_DECAY`, so `survives_explosion`/`explosion_decay` draw from the table's random sequence; `TntBlock.wasExploded` primes with a short fuse and no game event), then `createFire` over the shuffled list with `BaseFireBlock.getState`. ## The fix - `game/respawn_anchor.rs`: charging (main and off hand), setting the point, the explosion, `findStandUpPosition`/`DismountHelper`, respawning at the anchor (travel to its dimension, wait for its chunks, use a charge, deplete sound) and the missing-anchor fallback. The point is saved in the player's `respawn` compound with its dimension; a bed or `/spawnpoint` replaces it. Dying in the Nether without one respawns in the Overworld. - `game/explosion.rs`: `server_explode_as` with a damage type and a resistance override; fire through `BaseFireBlock.getState`; the explosion radius in the block loot context (`items.rs`); `wasExploded` without the prime_fuse game event and with `tnt_explodes`. ## How it was tested - `tools/test_use_item_on_parity.py` (real `ServerPlayerGameMode.useItemOn`) now also clicks anchors (0–4 charges, glowstone, other items, empty hand, sneaking, creative, the off hand) in the Nether and the Overworld, with blocks, TNT and water (source and flowing) around them, and the explosions run vanilla's real `ServerExplosion` on the stand-in level (oracle: Nether dimension type and attributes, `ServerLevel.explode`). New respawn cases call `ServerPlayer.findRespawnAndUseSpawnBlock` on anchors among stone, slabs, lava, fire, magma, cactus, berry bushes, powder snow, ladders, trapdoors, campfires… and compare the position, the yaw bits and the charge used. **4,000 / 4,000** cases match (133 explosions, 216 respawn spots found, every block change, drop, sound, game event, message and the final level random). - `tools/test_dispenser_parity.py` 6,000 / 6,000 (dispensers charging anchors, TNT). - `cargo fmt --check`, `cargo clippy --workspace --all-targets -D warnings`, `cargo test --workspace`, `tools/check_public_tree.py`. This PR and #146 both extend `VanillaDispenserOracle`/`test_use_item_on_parity.py`; whichever merges second gets a rebase. Fixes #99 🤖 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:55:20 +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#2365
No description provided.