[PR #6445] [MERGED] Blow up a TNT minecart that runs into a block #6877

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

📋 Pull Request Information

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

Base: main ← Head: fix/tnt-cart-collision


📝 Commits (2)

  • da31387 Blow up a TNT minecart that runs into a block
  • 34e0a12 Keep the off-track path from arming the collision detonation

📊 Changes

1 file changed (+34 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/game/minecarts.rs (+34 -6)

📄 Description

MinecartTNT.tick ends with the collision check:

// javap -p -c on MinecartTNT
75: getfield  horizontalCollision
79: ifeq      107
83: invokevirtual getVelocity/getDeltaMovement
86: invokevirtual Vec3.horizontalDistanceSqr
91: ldc2_w    0.009999999776482582
95: iflt      107
99-104: explode(ignitionSource, d)

That delta is still non-zero on a rail because AbstractMinecart.moveAlongTrack re-applies
the track's velocity after the move: a TNT cart pushed into a block at any speed over a tenth
of a block a tick detonates. Horizon resolves the collision by zeroing the cart's velocity
(move_cart), and the tick's check then read velocity - always zero at that point - so a
cart driven into a block simply stopped, which is the report's five carts in a row that never
went off.

The cart now remembers the horizontal speed it wanted when a block stopped it, and the check
uses that, with the same 0.01 threshold vanilla compares against.

Proven: on the build VM, cargo test -q -p horizon-client --lib a_tnt_cart_detonates_only_when_a_collision_stops_a_moving_one
→ 1 passed: 0.01 and 0.36 with a collision detonate, a stopped or nudged cart does not, and
a fast cart with nothing in the way does not.

Not proven: the trigger end to end is not under test (it needs rails, a cart and a blast);
the in-game check is the report's own setup - a powered rail driving TNT minecarts into a block.

One related case is unchanged on purpose: a cart that comes off the end of a track still
detonates through MinecartTNT.causeFallDamage (the fall >= 3.0 branch in come_off_track),
which already worked.


🔄 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/6445 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/tnt-cart-collision` --- ### 📝 Commits (2) - [`da31387`](https://github.com/horizon-rust/horizon/commit/da313872c5ffb699d8ec59e37908b8f50af0e9f8) Blow up a TNT minecart that runs into a block - [`34e0a12`](https://github.com/horizon-rust/horizon/commit/34e0a1295fccb6b3a8b5de353e0451ef06a6f1b2) Keep the off-track path from arming the collision detonation ### 📊 Changes **1 file changed** (+34 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/minecarts.rs` (+34 -6) </details> ### 📄 Description `MinecartTNT.tick` ends with the collision check: ```java // javap -p -c on MinecartTNT 75: getfield horizontalCollision 79: ifeq 107 83: invokevirtual getVelocity/getDeltaMovement 86: invokevirtual Vec3.horizontalDistanceSqr 91: ldc2_w 0.009999999776482582 95: iflt 107 99-104: explode(ignitionSource, d) ``` That delta is still non-zero on a rail because `AbstractMinecart.moveAlongTrack` re-applies the track's velocity after the move: a TNT cart pushed into a block at any speed over a tenth of a block a tick detonates. Horizon resolves the collision by zeroing the cart's velocity (`move_cart`), and the tick's check then read `velocity` - always zero at that point - so a cart driven into a block simply stopped, which is the report's five carts in a row that never went off. The cart now remembers the horizontal speed it wanted when a block stopped it, and the check uses that, with the same 0.01 threshold vanilla compares against. **Proven:** on the build VM, `cargo test -q -p horizon-client --lib a_tnt_cart_detonates_only_when_a_collision_stops_a_moving_one` → `1 passed`: 0.01 and 0.36 with a collision detonate, a stopped or nudged cart does not, and a fast cart with nothing in the way does not. **Not proven:** the trigger end to end is not under test (it needs rails, a cart and a blast); the in-game check is the report's own setup - a powered rail driving TNT minecarts into a block. One related case is unchanged on purpose: a cart that comes off the end of a track still detonates through `MinecartTNT.causeFallDamage` (the `fall >= 3.0` branch in `come_off_track`), which already worked. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:28:32 +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#6877
No description provided.