[PR #963] [MERGED] Structure processors: Lithostitched's apply_random, condition and set_block as data #2945

Closed
opened 2026-11-02 16:00:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/processor-random-and-condition


📝 Commits (1)

  • 2647ed7 Structure processors: Lithostitched's apply_random, condition and set_block as data

📊 Changes

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

View changed files

📝 crates/horizon-world/src/worldgen/structure/processor.rs (+83 -1)
➕ crates/horizon-world/src/worldgen/structure/processor/lithostitched.rs (+434 -0)

📄 Description

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

Carry writes these types in #964. This PR builds alone; vanilla data never has them.

What

Three processor types for Lithostitched's processors, which ChoiceTheorem's Overhauled Village (CTOV) uses throughout its villages:

  • horizon:apply_random (apply_random): one processor list, drawn by weight, runs on the block (WeightedList.getRandom: nextInt(total)).
  • horizon:condition (condition): then or else runs, by a test of the block. The tests are true, all_of (a bare list too), any_of, not, random_chance and matching_blocks (blocks or tags, plain property values, on the placed block or the one in the world).
  • horizon:set_block (set_block) with a simple or weighted state provider: the block becomes the state and keeps the properties it shares with the old one (withPropertiesOf) unless preserve_state is off.

Randoms are drawn as Lithostitched draws them: RandomSource.create(seed + name.hashCode()).forkPositional().at(pos), with pos the block, the piece's position or the structure's pivot (per_block, per_piece, per_structure). set_block draws from the unsalted seed. process_block now gets the piece's position for this.

Proof (a CTOV plains village, seed 1234, structure pieces only, with #964 and #960 against carry without them, same game build)

  • The farms grow carrots 15, potatoes 12, beetroot 16, melon and pumpkin stems where they held only wheat (-45 wheat).
  • 1,655 cobblestone blocks become 781 dirt paths, 680 grass blocks, 166 mossy cobblestone and 28 planks; 32 stone bricks become cracked and mossy.
  • The block total is unchanged, and the village's starts and pieces are the same.
  • Tests:
    • random_settings_salt_and_position: ResourceLocation's hash, and the positional fork against a hand-built Java one.
    • apply_random_draws_by_weight and set_block_draws_from_the_unsalted_seed: draws checked against Java's Random.
  • Vanilla is unchanged: the harnesses below.

Self-check

cargo fmt --all --check                                   ok
cargo clippy -p horizon-world --all-targets -- -D warnings   ok
cargo test -p horizon-world (lithostitched)               3 passed
tools/parity.py on an integration commit 311 passed, 0 failed (72 min, integration commit of #954-#964)

Nothing needs Ludovic.

🤖 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/963 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/processor-random-and-condition` --- ### 📝 Commits (1) - [`2647ed7`](https://github.com/horizon-rust/horizon/commit/2647ed7ed02c734d895882adb1d44ad8851cd793) Structure processors: Lithostitched's apply_random, condition and set_block as data ### 📊 Changes **2 files changed** (+517 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/worldgen/structure/processor.rs` (+83 -1) ➕ `crates/horizon-world/src/worldgen/structure/processor/lithostitched.rs` (+434 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Carry writes these types in #964. This PR builds alone; vanilla data never has them. ## What Three processor types for Lithostitched's processors, which ChoiceTheorem's Overhauled Village (CTOV) uses throughout its villages: - **`horizon:apply_random`** (`apply_random`): one processor list, drawn by weight, runs on the block (WeightedList.getRandom: `nextInt(total)`). - **`horizon:condition`** (`condition`): `then` or `else` runs, by a test of the block. The tests are `true`, `all_of` (a bare list too), `any_of`, `not`, `random_chance` and `matching_blocks` (blocks or tags, plain property values, on the placed block or the one in the world). - **`horizon:set_block`** (`set_block`) with a simple or weighted state provider: the block becomes the state and keeps the properties it shares with the old one (`withPropertiesOf`) unless `preserve_state` is off. Randoms are drawn as Lithostitched draws them: `RandomSource.create(seed + name.hashCode()).forkPositional().at(pos)`, with `pos` the block, the piece's position or the structure's pivot (`per_block`, `per_piece`, `per_structure`). `set_block` draws from the unsalted seed. `process_block` now gets the piece's position for this. ## Proof (a CTOV plains village, seed 1234, structure pieces only, with #964 and #960 against carry without them, same game build) - The farms grow carrots 15, potatoes 12, beetroot 16, melon and pumpkin stems where they held only wheat (-45 wheat). - 1,655 cobblestone blocks become 781 dirt paths, 680 grass blocks, 166 mossy cobblestone and 28 planks; 32 stone bricks become cracked and mossy. - The block total is unchanged, and the village's starts and pieces are the same. - Tests: - `random_settings_salt_and_position`: ResourceLocation's hash, and the positional fork against a hand-built Java one. - `apply_random_draws_by_weight` and `set_block_draws_from_the_unsalted_seed`: draws checked against Java's `Random`. - Vanilla is unchanged: the harnesses below. ## Self-check ``` cargo fmt --all --check ok cargo clippy -p horizon-world --all-targets -- -D warnings ok cargo test -p horizon-world (lithostitched) 3 passed tools/parity.py on an integration commit 311 passed, 0 failed (72 min, integration commit of #954-#964) ``` Nothing needs Ludovic. 🤖 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-02 16:00:18 +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#2945
No description provided.