[PR #3861] [CLOSED] Place template: keep the block entity a replaced block already had #5254

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3861
Author: @JustKarkat
Created: 10/29/2026
Status: ❌ Closed

Base: main ← Head: fix/place-template-block-entity


📝 Commits (1)

  • f38f6e1 Place template: keep the block entity a replaced block already had

📊 Changes

1 file changed (+80 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/place.rs (+80 -2)

📄 Description

What

/place template wrote a template block's saved NBT straight into the world's block-entity map, blind to whatever stood there before:

  • A template block with saved data dropped the replaced entity with no removal handling (a jukebox wrote over another jukebox keeps playing; a chest's contents vanished without the block-entity removal path).
  • A template block placed over the same state also reloaded its saved data, which vanilla does not: setBlock reports no change there, so the entity already at that position must stay.

Fix

cmd_place now follows StructureTemplate.placeInWorld, and the ordering the repo already uses in worldgen/structure/processor.rs::place_in_world:

  1. A template block with saved data clears the entity it replaces before the block lands, without its side effects (jukebox_removed + map removal).
  2. The saved data is loaded only when the block actually changed; over an identical state the existing entity is kept.

The decision is a small replaced_entity(has_saved_data, unchanged) helper so it is testable without a live Game.

Tests

  • replaced_entity_follows_place_in_world: the decision table for the four cases.
  • template_chest_lands_with_its_own_contents: a template chest decodes to its own 27 slots with the template's stack, not a merge with what was there.

Both run under cargo test -p horizon-client --bins game::commands::place; the whole horizon-client bin suite (182 tests) passes, and rustfmt --check plus cargo clippy are clean.

Fixes #3708


🔄 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/3861 **Author:** [@JustKarkat](https://github.com/JustKarkat) **Created:** 10/29/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/place-template-block-entity` --- ### 📝 Commits (1) - [`f38f6e1`](https://github.com/horizon-rust/horizon/commit/f38f6e12450e4911618207d3ce33804dc217185f) Place template: keep the block entity a replaced block already had ### 📊 Changes **1 file changed** (+80 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/place.rs` (+80 -2) </details> ### 📄 Description ## What `/place template` wrote a template block's saved NBT straight into the world's block-entity map, blind to whatever stood there before: - A template block **with** saved data dropped the replaced entity with no removal handling (a jukebox wrote over another jukebox keeps playing; a chest's contents vanished without the block-entity removal path). - A template block placed over **the same state** also reloaded its saved data, which vanilla does not: `setBlock` reports no change there, so the entity already at that position must stay. ## Fix `cmd_place` now follows `StructureTemplate.placeInWorld`, and the ordering the repo already uses in `worldgen/structure/processor.rs::place_in_world`: 1. A template block with saved data clears the entity it replaces **before** the block lands, without its side effects (`jukebox_removed` + map removal). 2. The saved data is loaded only when the block actually changed; over an identical state the existing entity is kept. The decision is a small `replaced_entity(has_saved_data, unchanged)` helper so it is testable without a live `Game`. ## Tests - `replaced_entity_follows_place_in_world`: the decision table for the four cases. - `template_chest_lands_with_its_own_contents`: a template chest decodes to its own 27 slots with the template's stack, not a merge with what was there. Both run under `cargo test -p horizon-client --bins game::commands::place`; the whole `horizon-client` bin suite (182 tests) passes, and `rustfmt --check` plus `cargo clippy` are clean. Fixes #3708 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:17 +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#5254
No description provided.