[PR #6913] [MERGED] Explode a primed TNT with its own explosion_power #7189

Closed
opened 2026-11-03 06:35:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6913
Author: @MSedgeMC
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/tnt-explosion-power


📝 Commits (3)

  • 806d593 Explode a primed TNT with its own explosion_power
  • 934e363 Give the TNT test fixtures the new power field
  • 3bf2089 Merge main into #6913

📊 Changes

6 files changed (+62 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+44 -1)
📝 crates/horizon-client/src/game/commands/data.rs (+1 -0)
📝 crates/horizon-client/src/game/nether_portal.rs (+1 -0)
📝 crates/horizon-client/src/game/persist.rs (+4 -0)
📝 crates/horizon-client/src/game/remote_projectiles.rs (+1 -0)
📝 crates/horizon-client/src/game/tnt.rs (+11 -2)

📄 Description

PrimedTnt carries its blast power in the entity, and Horizon ignored it:

// javap -p -c on PrimedTnt.readAdditionalSaveData
40-59: getFloatOr("explosion_power", 4.0F) -> Mth.clamp(0, 128) -> explosionPower

and tick explodes with this.explosionPower. Horizon's tick_tnt passed a literal 4.0 to
server_explode, so /summon tnt ~ ~ ~ {fuse:20,explosion_power:10f} exploded like plain TNT -
the tag was kept in the raw save data and never read.

The power is now a field on the primed TNT, read from the tag through
entity_nbt::tnt_power (default 4, clamped both ways), written back by tnt_to_nbt when it is
not the default, carried through a portal, and used for the blast.

Proven: cargo test -q -p horizon-client-lib --lib explosion_power_is_read -> 1 passed:
absent reads 4, 10 reads 10, 200 clamps to 128, -3 clamps to 0, and the save round-trips 10
while a default one writes nothing. cargo clippy -q -p horizon-client-lib --lib and
cargo clippy -q -p horizon-client --lib are silent; rustfmt --edition 2024 --check clean.

Not proven: not exploded in game; the check is the report's own - summon TNT with
explosion_power:10 and see a much larger crater than plain TNT, and explosion_power:200
sized like 128.


🔄 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/6913 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/tnt-explosion-power` --- ### 📝 Commits (3) - [`806d593`](https://github.com/horizon-rust/horizon/commit/806d5935e53294f83d659c1948f289da0155ee1f) Explode a primed TNT with its own explosion_power - [`934e363`](https://github.com/horizon-rust/horizon/commit/934e3638d241f41a8256042ff452ac00240ce73d) Give the TNT test fixtures the new power field - [`3bf2089`](https://github.com/horizon-rust/horizon/commit/3bf2089385ccd6bbd6e634d6b281b0ab73a00a34) Merge main into #6913 ### 📊 Changes **6 files changed** (+62 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+44 -1) 📝 `crates/horizon-client/src/game/commands/data.rs` (+1 -0) 📝 `crates/horizon-client/src/game/nether_portal.rs` (+1 -0) 📝 `crates/horizon-client/src/game/persist.rs` (+4 -0) 📝 `crates/horizon-client/src/game/remote_projectiles.rs` (+1 -0) 📝 `crates/horizon-client/src/game/tnt.rs` (+11 -2) </details> ### 📄 Description `PrimedTnt` carries its blast power in the entity, and Horizon ignored it: ```java // javap -p -c on PrimedTnt.readAdditionalSaveData 40-59: getFloatOr("explosion_power", 4.0F) -> Mth.clamp(0, 128) -> explosionPower ``` and `tick` explodes with `this.explosionPower`. Horizon's `tick_tnt` passed a literal `4.0` to `server_explode`, so `/summon tnt ~ ~ ~ {fuse:20,explosion_power:10f}` exploded like plain TNT - the tag was kept in the raw save data and never read. The power is now a field on the primed TNT, read from the tag through `entity_nbt::tnt_power` (default 4, clamped both ways), written back by `tnt_to_nbt` when it is not the default, carried through a portal, and used for the blast. **Proven:** `cargo test -q -p horizon-client-lib --lib explosion_power_is_read` -> `1 passed`: absent reads 4, `10` reads 10, `200` clamps to 128, `-3` clamps to 0, and the save round-trips 10 while a default one writes nothing. `cargo clippy -q -p horizon-client-lib --lib` and `cargo clippy -q -p horizon-client --lib` are silent; `rustfmt --edition 2024 --check` clean. **Not proven:** not exploded in game; the check is the report's own - summon TNT with `explosion_power:10` and see a much larger crater than plain TNT, and `explosion_power:200` sized like 128. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:35:26 +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#7189
No description provided.