[PR #4328] [MERGED] TNT: stop client piston replay from creating a second primed entity #5566

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4328
Author: @repositorykreml1n
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: codex/fix-tnt-duper-3856


📝 Commits (2)

  • df1a26d TNT: prime powered blocks only on the server
  • b87f65b TNT: cover client replay and preserved server duplication

📊 Changes

2 files changed (+139 additions, -1 deletions)

View changed files

📝 crates/horizon-world/src/level/redstone.rs (+3 -1)
📝 crates/horizon-world/src/level/tests.rs (+136 -0)

📄 Description

🤖 Prepared by repositorykreml1n's AI agent (OpenAI Codex).

What and why

A TNT duper appeared to produce two primed TNT entities in one cycle. The server created the expected entity, but the client's replay of the piston movement could also reach Sim::tnt_check. That call emitted another PrimeTnt, removed the client's TNT block and consumed a random push angle. The normal server entity packet then added the authoritative TNT separately.

This adds the server-side check to tnt_check, shared by TNT's placement and neighbor-update hooks. The client now waits for the server's entity and block updates.

The server's piston movement, saved block state and update ordering are unchanged. Vanilla TNT duplication is preserved: the regression duper creates one server TNT and retains its original block. There is no per-tick limit or coordinate-based deduplication; separate powered TNT blocks can still prime in the same tick.

Fixes #3856.

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

Read with javap -c -p from the installed Java Edition 26.3 client jar:

  • net.minecraft.world.level.block.TntBlock.prime(Level, BlockPos, LivingEntity, ItemStack) returns false outside a ServerLevel, before creating the entity or drawing its random push.
  • TntBlock.onPlace and TntBlock.neighborChanged remove the block only when prime succeeds.

Four regression tests in horizon_world::level::tests exercise the real block simulator:

  • A client neighbor update preserves the powered TNT block, emits no priming effects and leaves the RNG unchanged.
  • Client placement beside a power source creates no primed TNT.
  • Two separate server-side TNT blocks both prime in the same tick.
  • A sticky-piston/slime/BUD-powered-TNT fixture breaks a wall torch during movement. The server creates exactly one primed TNT while the cached original block survives; client replay creates none. Counts are checked both immediately and after the moving blocks finish.

The last fixture isolates the duplication mechanism. It is not a manual reproduction of the exact coral/minecart build from the report's video. The full Java differential parity suite was not run.

Self-check

Verified on Windows against the report's baseline, 4baa571566 (nightly-2026-10-29-4baa571), with the prepared 26.3 resources supplied through HORIZON_RESOURCES:

  • cargo test -p horizon-world --locked --offline: 264 passed, 0 failed, 3 ignored, including unit, binary, integration and doc-test targets. The ignored cases are two microbenchmarks and one documentation example.
  • The library portion is 185 passed, 0 failed, 1 ignored.
  • rustfmt --edition 2024 --check on both changed files: clean.
  • git diff --check: clean.

Before / after: with the original tnt_check, three of the four new tests fail. In the piston fixture, the server-side checks pass, but client replay produces one extra TNT where zero is expected. With the server-side guard, all four pass; they were also rerun immediately before upload.

The final full test run used a project-local temporary directory and ran outside the filesystem sandbox. Earlier sandboxed runs hit PermissionDenied in the existing cache and region-file tests; both pass in the final run. No cache or save code is changed.

tools/pr_ready.py, Clippy, a full game-client build and manual in-game verification were not run. No in-game before/after screenshots are claimed.

🤖 Generated with OpenAI Codex.


🔄 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/4328 **Author:** [@repositorykreml1n](https://github.com/repositorykreml1n) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `codex/fix-tnt-duper-3856` --- ### 📝 Commits (2) - [`df1a26d`](https://github.com/horizon-rust/horizon/commit/df1a26d2bdb82714de18a9a517b9c36854ceed50) TNT: prime powered blocks only on the server - [`b87f65b`](https://github.com/horizon-rust/horizon/commit/b87f65b1b6b7d1d0982f580e4feb8e29def286bf) TNT: cover client replay and preserved server duplication ### 📊 Changes **2 files changed** (+139 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/level/redstone.rs` (+3 -1) 📝 `crates/horizon-world/src/level/tests.rs` (+136 -0) </details> ### 📄 Description > 🤖 Prepared by repositorykreml1n's AI agent (OpenAI Codex). ## What and why A TNT duper appeared to produce two primed TNT entities in one cycle. The server created the expected entity, but the client's replay of the piston movement could also reach `Sim::tnt_check`. That call emitted another `PrimeTnt`, removed the client's TNT block and consumed a random push angle. The normal server entity packet then added the authoritative TNT separately. This adds the server-side check to tnt_check, shared by TNT's placement and neighbor-update hooks. The client now waits for the server's entity and block updates. The server's piston movement, saved block state and update ordering are unchanged. Vanilla TNT duplication is preserved: the regression duper creates one server TNT and retains its original block. There is no per-tick limit or coordinate-based deduplication; separate powered TNT blocks can still prime in the same tick. Fixes #3856. ## 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 Read with javap -c -p from the installed Java Edition 26.3 client jar: - net.minecraft.world.level.block.TntBlock.prime(Level, BlockPos, LivingEntity, ItemStack) returns false outside a ServerLevel, before creating the entity or drawing its random push. - TntBlock.onPlace and TntBlock.neighborChanged remove the block only when prime succeeds. Four regression tests in horizon_world::level::tests exercise the real block simulator: - A client neighbor update preserves the powered TNT block, emits no priming effects and leaves the RNG unchanged. - Client placement beside a power source creates no primed TNT. - Two separate server-side TNT blocks both prime in the same tick. - A sticky-piston/slime/BUD-powered-TNT fixture breaks a wall torch during movement. The server creates exactly one primed TNT while the cached original block survives; client replay creates none. Counts are checked both immediately and after the moving blocks finish. The last fixture isolates the duplication mechanism. It is not a manual reproduction of the exact coral/minecart build from the report's video. The full Java differential parity suite was not run. ## Self-check Verified on Windows against the report's baseline, 4baa571566e39bfd6594988d3bb2bc85440c30e7 (nightly-2026-10-29-4baa571), with the prepared 26.3 resources supplied through HORIZON_RESOURCES: - cargo test -p horizon-world --locked --offline: **264 passed, 0 failed, 3 ignored**, including unit, binary, integration and doc-test targets. The ignored cases are two microbenchmarks and one documentation example. - The library portion is **185 passed, 0 failed, 1 ignored**. - rustfmt --edition 2024 --check on both changed files: clean. - git diff --check: clean. Before / after: with the original tnt_check, three of the four new tests fail. In the piston fixture, the server-side checks pass, but client replay produces one extra TNT where zero is expected. With the server-side guard, all four pass; they were also rerun immediately before upload. The final full test run used a project-local temporary directory and ran outside the filesystem sandbox. Earlier sandboxed runs hit PermissionDenied in the existing cache and region-file tests; both pass in the final run. No cache or save code is changed. tools/pr_ready.py, Clippy, a full game-client build and manual in-game verification were not run. No in-game before/after screenshots are claimed. 🤖 Generated with [OpenAI Codex](https://openai.com/codex/). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:27 +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#5566
No description provided.