[PR #5084] [MERGED] fix(mobs): sulfur cubes follow the tnt_explodes rule #6051

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

📋 Pull Request Information

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

Base: main ← Head: fix/sulfur-cube-tnt-explodes


📝 Commits (3)

  • 1ec0d72 fix(mobs): sulfur cubes follow the tnt_explodes rule
  • 374171d Merge origin/main
  • 8c51ac2 Merge origin/main (picks up 72fabfede's Python test fix)

📊 Changes

3 files changed (+97 additions, -18 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/chat.rs (+1 -0)
📝 crates/horizon-client/src/mobs/sulfur_cube.rs (+95 -18)

📄 Description

What and why

Stacked on #5071, the Scope below counts both
With tnt_explodes off, a blast, a rocket, fire or lava still lit a TNT sulfur cube's fuse and made it invulnerable
Vanilla's SulfurCube.primeTime checks the rule, so with it off nothing is primed at all: no fuse, no invulnerability, no sound, no random draw for the short fuse
A cube that was already primed when the rule went off still dies when its fuse runs out, without a blast (tickFuse)
Horizon's flint and steel, dispenser and redstone paths already checked the rule before calling prime
The damage path couldn't, since Mob::damage has no MobWorld and so no game rules
The game shares the rule with the mob code through a thread-local, set at the start of each tick_world and by sync_rules when a rule changes, from ui.rules.bool("tnt_explodes")
I think the cleaner place would be MobWorld, but the damage path doesn't have it (about 59 damage calls), so I kept it to a thread-local
So a /gamerule tnt_explodes false from chat, a command block or a server's player holds for the very next hit, in the same tick
sulfur_cube::prime checks it in vanilla's order
With the rule off the fuse end sends neither the blast nor its source event, and still removes the cube
Unit tests check that a blast and a direct prime light nothing with the rule off and draw nothing from the cube's random, that the cube primes once it's back on, and that a fuse running out with the rule off removes the cube with no Explode or ExplosionSource event

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

SulfurCube.primeTime (SulfurCube.java:336-353): TNT_EXPLODES at :340, before setPermanentlyInvulnerable at :344
SulfurCube.tickFuse (SulfurCube.java:292-325): the blast only with TNT_EXPLODES at :302, discard either way at :322
SulfurCube.hurtServer primes through primeTime (SulfurCube.java:249, :251)

Other projects' code

none

Self-check

Check Result
Scope ✅ 6 files, +233 −44
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (58 s)
rustfmt ✅ (8 s)
clippy ✅ (2 min 15 s)
tests: horizon-client ✅ 1343 passed (6 min 1 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🔄 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/5084 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/sulfur-cube-tnt-explodes` --- ### 📝 Commits (3) - [`1ec0d72`](https://github.com/horizon-rust/horizon/commit/1ec0d72ba5395755f633a7b4d999974a80443ada) fix(mobs): sulfur cubes follow the tnt_explodes rule - [`374171d`](https://github.com/horizon-rust/horizon/commit/374171dac68cb270b783e44729927a0cfd24fd08) Merge origin/main - [`8c51ac2`](https://github.com/horizon-rust/horizon/commit/8c51ac22081a2e2dccee3fed55a9bb774f544696) Merge origin/main (picks up 72fabfede's Python test fix) ### 📊 Changes **3 files changed** (+97 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/chat.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/sulfur_cube.rs` (+95 -18) </details> ### 📄 Description ## What and why Stacked on #5071, the Scope below counts both With `tnt_explodes` off, a blast, a rocket, fire or lava still lit a TNT sulfur cube's fuse and made it invulnerable Vanilla's `SulfurCube.primeTime` checks the rule, so with it off nothing is primed at all: no fuse, no invulnerability, no sound, no random draw for the short fuse A cube that was already primed when the rule went off still dies when its fuse runs out, without a blast (`tickFuse`) Horizon's flint and steel, dispenser and redstone paths already checked the rule before calling `prime` The damage path couldn't, since `Mob::damage` has no `MobWorld` and so no game rules The game shares the rule with the mob code through a thread-local, set at the start of each `tick_world` and by `sync_rules` when a rule changes, from `ui.rules.bool("tnt_explodes")` I think the cleaner place would be `MobWorld`, but the damage path doesn't have it (about 59 damage calls), so I kept it to a thread-local So a `/gamerule tnt_explodes false` from chat, a command block or a server's player holds for the very next hit, in the same tick `sulfur_cube::prime` checks it in vanilla's order With the rule off the fuse end sends neither the blast nor its source event, and still removes the cube Unit tests check that a blast and a direct `prime` light nothing with the rule off and draw nothing from the cube's random, that the cube primes once it's back on, and that a fuse running out with the rule off removes the cube with no `Explode` or `ExplosionSource` event ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `SulfurCube.primeTime` (`SulfurCube.java:336-353`): `TNT_EXPLODES` at :340, before `setPermanentlyInvulnerable` at :344 `SulfurCube.tickFuse` (`SulfurCube.java:292-325`): the blast only with `TNT_EXPLODES` at :302, `discard` either way at :322 `SulfurCube.hurtServer` primes through `primeTime` (`SulfurCube.java:249`, :251) ## Other projects' code none ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 6 files, +233 −44 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (58 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (2 min 15 s) | | tests: horizon-client | ✅ 1343 passed (6 min 1 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:53 +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#6051
No description provided.