[PR #2291] [MERGED] Saves: write points of interest (carries #2074) #4176

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

📋 Pull Request Information

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

Base: main ← Head: carry/2074-poi-files


📝 Commits (3)

  • 2143c26 Saves: write points of interest
  • 43ae7a0 Merge main (save.rs: LevelShape beside the POI encoder; both sets of tests kept)
  • 7e5fa6f Merge main (save.rs tests: the POI tests beside #2073's loot test)

📊 Changes

2 files changed (+388 additions, -64 deletions)

View changed files

📝 crates/horizon-client/src/game/commands.rs (+1 -32)
📝 crates/horizon-client/src/save.rs (+387 -32)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

This carries @FusselTV's #2074 unchanged, plus one merge of main. After #2070 merged, #2074 conflicted in save.rs: LevelShape and the POI encoder were added at the same place, and so were both PRs' tests. GitHub doesn't let maintainers push to a fork owned by an organization (RoyalPixelsDE), so the merge lives on this branch. FusselTV's commit keeps its author, and the merger lands it with a merge commit.

The merge keeps both sides. save::tests passes 28/28, including the three POI tests and nether_and_end_chunks_save_with_their_own_height.

Gate evidence: a vanilla save of a generated world round-trips through Horizon back to vanilla 26.3 on the server thread and in-frame, with the same number of POI chunks (21/21 in the overworld). Horizon still leaves out empty Valid sections, which is recorded as a leftover. save_roundtrip, world_reopen and chunk_generation pass on an integration tree with the whole save series.

Closes #2074 once merged.


FusselTV's original description:

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

What and why

Horizon finds villager points of interest from the blocks and never wrote a poi folder. A world it made has none. Vanilla rebuilds a missing POI section when it loads the chunk. Until then nothing knows that chunk's beds, job sites, bells, bee nests, nether portals or lodestones:

  • villagers do not find homes or jobs there,
  • /locate poi misses them.

On a pre-generated world those chunks may stay unloaded for a long time.

What changes:

  • Saving a chunk also writes its POI records, the way PoiManager saves its sections:
    • each section with POI blocks is written and marked Valid: 1,
    • one record per block of PoiTypes, with that type's max tickets,
    • free_tickets is left out at 0, as the codec does.
  • Claims survive a save. A record that is still at the same position with the same type keeps the free_tickets of the saved one, so a bed or job site a villager claimed stays claimed.
  • A chunk that lost its last POI and had a record gets an empty one. Vanilla trusts a valid section, so a stale record would keep pointing at a removed block.
  • The records are built on the region writer thread, which reads the saved record there. Unloading chunks reads no files on the tick thread.
  • poi_type is one table, used by the save and by /locate poi. A straw bed is not a home (PoiTypes.BEDS is the sixteen coloured beds). Only a bed's head is.

Vanilla reference

  • PoiManager, SectionStorage.writeChunk
  • PoiSection.Packed CODEC (Valid, Records)
  • PoiRecord.Packed CODEC (pos, type, free_tickets defaulting to 0)
  • PoiTypes.register and its block state sets, including BEDS and the lightning rods

Tests

  • New unit tests:
    • save::tests::points_of_interest_save_as_poi_sections: bed head, bed foot, bell, stone and a straw bed in one chunk give exactly the bed head (minecraft:home, 1 ticket) and the bell (minecraft:meeting, 32).
    • save::tests::saved_poi_records_keep_their_claims.
    • save::tests::a_chunk_that_loses_its_last_poi_saves_empty_sections: goes through SaveDir::save_later and the writer thread.
  • Negative controls: with the straw bed check removed, the first test fails. With the empty-record case removed, the last one fails.
  • 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. Overworld: 4 poi region files and 66 of vanilla's 68 POI records in the same area. The 2 missing ones sit where blocks differ from generation order; Paper's own world has 67 of 68.

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on a8d704b4b217, against upstream/main at 57c5f8129, 3 min 49 s)

Check Result
Scope ✅ 2 files, +388 −64
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (6 s)
clippy ✅ (31 s)
tests: horizon-client ✅ 1298 passed (3 min 9 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

🤖 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/2291 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `carry/2074-poi-files` --- ### 📝 Commits (3) - [`2143c26`](https://github.com/horizon-rust/horizon/commit/2143c26a2e6205af93ef55729f9db45866c2bc84) Saves: write points of interest - [`43ae7a0`](https://github.com/horizon-rust/horizon/commit/43ae7a0974ff18c6543be3a2b2ada0768d827f09) Merge main (save.rs: LevelShape beside the POI encoder; both sets of tests kept) - [`7e5fa6f`](https://github.com/horizon-rust/horizon/commit/7e5fa6f91b0cec5da9416fb72c1a2fd284830cab) Merge main (save.rs tests: the POI tests beside #2073's loot test) ### 📊 Changes **2 files changed** (+388 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands.rs` (+1 -32) 📝 `crates/horizon-client/src/save.rs` (+387 -32) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. **This carries @FusselTV's #2074 unchanged, plus one merge of main.** After #2070 merged, #2074 conflicted in `save.rs`: `LevelShape` and the POI encoder were added at the same place, and so were both PRs' tests. GitHub doesn't let maintainers push to a fork owned by an organization (RoyalPixelsDE), so the merge lives on this branch. FusselTV's commit keeps its author, and the merger lands it with a merge commit. The merge keeps both sides. `save::tests` passes 28/28, including the three POI tests and `nether_and_end_chunks_save_with_their_own_height`. Gate evidence: a vanilla save of a generated world round-trips through Horizon back to vanilla 26.3 on the server thread and in-frame, with the same number of POI chunks (21/21 in the overworld). Horizon still leaves out empty Valid sections, which is recorded as a leftover. `save_roundtrip`, `world_reopen` and `chunk_generation` pass on an integration tree with the whole save series. Closes #2074 once merged. --- FusselTV's original description: > (#2074) Opened by FusselTV's AI agent (Claude Code, Opus 5.5), not by FusselTV personally. ## What and why Horizon finds villager points of interest from the blocks and never wrote a `poi` folder. A world it made has none. Vanilla rebuilds a missing POI section when it loads the chunk. Until then nothing knows that chunk's beds, job sites, bells, bee nests, nether portals or lodestones: - villagers do not find homes or jobs there, - `/locate poi` misses them. On a pre-generated world those chunks may stay unloaded for a long time. What changes: - Saving a chunk also writes its POI records, the way `PoiManager` saves its sections: - each section with POI blocks is written and marked `Valid: 1`, - one record per block of `PoiTypes`, with that type's max tickets, - `free_tickets` is left out at 0, as the codec does. - Claims survive a save. A record that is still at the same position with the same type keeps the `free_tickets` of the saved one, so a bed or job site a villager claimed stays claimed. - A chunk that lost its last POI and had a record gets an empty one. Vanilla trusts a valid section, so a stale record would keep pointing at a removed block. - The records are built on the region writer thread, which reads the saved record there. Unloading chunks reads no files on the tick thread. - `poi_type` is one table, used by the save and by `/locate poi`. A straw bed is not a home (`PoiTypes.BEDS` is the sixteen coloured beds). Only a bed's head is. ## Vanilla reference - `PoiManager`, `SectionStorage.writeChunk` - `PoiSection.Packed` CODEC (`Valid`, `Records`) - `PoiRecord.Packed` CODEC (`pos`, `type`, `free_tickets` defaulting to 0) - `PoiTypes.register` and its block state sets, including `BEDS` and the lightning rods ## Tests - New unit tests: - `save::tests::points_of_interest_save_as_poi_sections`: bed head, bed foot, bell, stone and a straw bed in one chunk give exactly the bed head (`minecraft:home`, 1 ticket) and the bell (`minecraft:meeting`, 32). - `save::tests::saved_poi_records_keep_their_claims`. - `save::tests::a_chunk_that_loses_its_last_poi_saves_empty_sections`: goes through `SaveDir::save_later` and the writer thread. - Negative controls: with the straw bed check removed, the first test fails. With the empty-record case removed, the last one fails. - 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. Overworld: 4 `poi` region files and 66 of vanilla's 68 POI records in the same area. The 2 missing ones sit where blocks differ from generation order; Paper's own world has 67 of 68. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on a8d704b4b217, against upstream/main at 57c5f8129, 3 min 49 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +388 −64 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (6 s) | | clippy | ✅ (31 s) | | tests: horizon-client | ✅ 1298 passed (3 min 9 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) 🤖 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:15:15 +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#4176
No description provided.