[PR #2071] [MERGED] Trial spawners: no empty spawn_data on save #3981

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2071
Author: @FusselTV
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/trial-spawner-spawn-data


📝 Commits (1)

  • df3ac51 Trial spawners: no empty spawn_data on save

📊 Changes

1 file changed (+18 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/block_entity_nbt.rs (+18 -7)

📄 Description

🤖 Opened by FusselTV's AI agent (Claude Code, Opus 5.5), not by FusselTV personally.

What and why

The block entity canonicaliser (block_entity_nbt::canonical) added spawn_data: {entity: {}} to every trial spawner that had none. Vanilla writes spawn_data only after the spawner has picked its next mob. TrialSpawnerStateData.Packed reads a missing one as Optional.empty.

The added empty entity stays for good:

  • getOrCreateNextSpawnData returns the stored SpawnData instead of picking one.
  • That entity names no mob, so the spawner never spawns anything.
  • This happens in Horizon and also after the world is opened in vanilla or Paper.

Trial spawners save without a picked mob whenever mob spawning is off. That includes worlds pre-generated in peaceful, and worlds with spawner_blocks_work false, which is how seed generators and server networks pre-generate maps. So trial chambers in those worlds were dead.

What changes:

  • canonical keeps spawn_data when the spawner has one and adds nothing when it has none.

Vanilla reference

  • TrialSpawnerStateData.Packed CODEC: spawn_data is lenientOptionalFieldOf, and only a present value is written.
  • TrialSpawnerStateData.getOrCreateNextSpawnData.
  • TrialSpawner.load / save.

Tests

  • New unit test block_entity_nbt::tests::a_trial_spawner_without_spawn_data_saves_none. A fresh spawner saves no spawn_data. One that picked a skeleton keeps it.
  • tools/test_trial_spawner_parity.py passed on this branch: 2,500 cases match vanilla.
  • tools/test_block_entity_storage_parity.py passed on this branch: 78,251 lines match on client and server.
  • End to end: All fixes of this series (the five save PRs and the four structure-start PRs) merged onto main and run as a dedicated server, which pre-generated seed 12345, 4,096 chunks per dimension (radius 500 blocks), and the result was compared chunk by chunk with the same area from the pinned vanilla 26.3 server (compare.py, our own world-diff tool). Then the world was opened in Paper 26.3. Paper's log shows no exception and no skipped block entity. The Overworld has 63 trial spawners saved without spawn_data and none with an empty one. In Paper, data get block -258 -34 36 spawn_data finds none. Before rebasing onto current main, I also checked this in game on Paper with a real client: the spawner picks a mob and spawns it.

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on eadd575d4140, against upstream/main at 57c5f8129, 4 min 21 s)

Check Result
Scope ✅ 1 files, +18 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (6 s)
clippy ✅ (37 s)
tests: horizon-client ✅ 1296 passed (3 min 31 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 324 affected, to run in CI (--quick): arrow, attribute_map_queries, auto_jump, biome_source_codec, biome_temperature, biome_weather, biome_zoom, block_blob, block_collision_scan, block_column, block_entity_anim, block_entity_render and 312 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 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/2071 **Author:** [@FusselTV](https://github.com/FusselTV) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/trial-spawner-spawn-data` --- ### 📝 Commits (1) - [`df3ac51`](https://github.com/horizon-rust/horizon/commit/df3ac51447cfd9aaad6fd565ae32f81de3699cd7) Trial spawners: no empty spawn_data on save ### 📊 Changes **1 file changed** (+18 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/block_entity_nbt.rs` (+18 -7) </details> ### 📄 Description > 🤖 Opened by FusselTV's AI agent (Claude Code, Opus 5.5), not by FusselTV personally. ## What and why The block entity canonicaliser (`block_entity_nbt::canonical`) added `spawn_data: {entity: {}}` to every trial spawner that had none. Vanilla writes `spawn_data` only after the spawner has picked its next mob. `TrialSpawnerStateData.Packed` reads a missing one as `Optional.empty`. The added empty entity stays for good: - `getOrCreateNextSpawnData` returns the stored `SpawnData` instead of picking one. - That entity names no mob, so the spawner never spawns anything. - This happens in Horizon and also after the world is opened in vanilla or Paper. Trial spawners save without a picked mob whenever mob spawning is off. That includes worlds pre-generated in peaceful, and worlds with `spawner_blocks_work` false, which is how seed generators and server networks pre-generate maps. So trial chambers in those worlds were dead. What changes: - `canonical` keeps `spawn_data` when the spawner has one and adds nothing when it has none. ## Vanilla reference - `TrialSpawnerStateData.Packed` CODEC: `spawn_data` is `lenientOptionalFieldOf`, and only a present value is written. - `TrialSpawnerStateData.getOrCreateNextSpawnData`. - `TrialSpawner.load` / `save`. ## Tests - New unit test `block_entity_nbt::tests::a_trial_spawner_without_spawn_data_saves_none`. A fresh spawner saves no `spawn_data`. One that picked a skeleton keeps it. - `tools/test_trial_spawner_parity.py` passed on this branch: 2,500 cases match vanilla. - `tools/test_block_entity_storage_parity.py` passed on this branch: 78,251 lines match on client and server. - End to end: All fixes of this series (the five save PRs and the four structure-start PRs) merged onto `main` and run as a dedicated server, which pre-generated seed 12345, 4,096 chunks per dimension (radius 500 blocks), and the result was compared chunk by chunk with the same area from the pinned vanilla 26.3 server (`compare.py`, our own world-diff tool). Then the world was opened in Paper 26.3. Paper's log shows no exception and no skipped block entity. The Overworld has 63 trial spawners saved without `spawn_data` and none with an empty one. In Paper, `data get block -258 -34 36 spawn_data` finds none. Before rebasing onto current `main`, I also checked this in game on Paper with a real client: the spawner picks a mob and spawns it. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on eadd575d4140, against upstream/main at 57c5f8129, 4 min 21 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +18 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (6 s) | | clippy | ✅ (37 s) | | tests: horizon-client | ✅ 1296 passed (3 min 31 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 324 affected, to run in CI (--quick): arrow, attribute_map_queries, auto_jump, biome_source_codec, biome_temperature, biome_weather, biome_zoom, block_blob, block_collision_scan, block_column, block_entity_anim, block_entity_render and 312 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:13:46 +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#3981
No description provided.