[PR #410] [MERGED] Vaults: server logic and a parity harness #2544

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

📋 Pull Request Information

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

Base: main ← Head: feat/vault-logic


📝 Commits (1)

  • 2567a4a Add the vault's server logic with a parity harness

📊 Changes

5 files changed (+1277 additions, -5 deletions)

View changed files

📝 crates/horizon-client/examples/natural_spawn_fixture.rs (+201 -2)
📝 crates/horizon-client/src/lib.rs (+1 -0)
➕ crates/horizon-client/src/vault.rs (+745 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java (+105 -3)
➕ tools/test_vault_parity.py (+225 -0)

📄 Description

Part of #223.

What

vault::Vault is vanilla's VaultBlockEntity (with VaultConfig, VaultServerData and VaultSharedData), not wired into the game yet (next PR):

  • load/save with the codecs' leniency: a missing config is VaultConfig.DEFAULT (trial key, chests/trial_chambers/reward); one with activation past deactivation falls back to the default; one without a key never opens. Like vanilla, loading leaves total_ejections_needed out.
  • Server.tick: the display item cycling from the loot table every 20 ticks while active, VaultState.tickAndGetNext for every state (connected players within the activation/deactivation range, not yet rewarded, creative included, spectators not), ejection one item per 20 ticks with spawnItem's draws and the pitch from ejectionProgress, onTransition sounds and level events 3015/3016/3017, shared data updates.
  • VaultBlock.useItemOn + Server.tryInsertKey: only while active, key item and count, the rewarded-player check, fail sounds at most every 15 ticks, the reward roll with the table's random sequence, unlocking (14 ticks), the 128 rewarded players cap.

This builds on the WIP from feat/vaults (bugs-trial-2), finished against vanilla 26.3.

Proof

tools/test_vault_parity.py (new, auto-discovered by tools/parity.py): a new mode=vault of VanillaNaturalSpawnOracle / natural_spawn_fixture loads a VaultBlockEntity from each case's NBT and ticks it with the game time advancing; players move and use trial keys, ominous keys, too few keys and other items through VaultBlock.useItemOn. Both sides log every state change, level event, sound (with pitch), ejected item (position and velocity bits), shared data update (display item, connected players), each use (accepted, stack left), and at the end the saved data and the next draw of the level random.

3,000 vault cases match vanilla (1,992 uses_on_active, 22 refused, 854 wrong_keys, 653 items, 2,716 states, 7,851 updates, 901 reached_inactive, 762 reached_active, 470 reached_unlocking, 494 reached_ejecting)

Mutation check: a fail-sound buffer of 14 instead of 15 → 15 cases differ; <= instead of < in the range check → 17 cases differ.

Self-check

  • cargo fmt clean, cargo clippy -p horizon-client --all-targets -- -D warnings clean
  • cargo test -p horizon-client --lib vault:: 3 passed
  • workspace clippy, the client tests and parity.py on the combined branch of the #223 PRs: in the last PR of the series

Needs Ludovic

Nothing.

🤖 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/410 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/vault-logic` --- ### 📝 Commits (1) - [`2567a4a`](https://github.com/horizon-rust/horizon/commit/2567a4a41aaeb13318756d2deba5331d81f61d63) Add the vault's server logic with a parity harness ### 📊 Changes **5 files changed** (+1277 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/natural_spawn_fixture.rs` (+201 -2) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) ➕ `crates/horizon-client/src/vault.rs` (+745 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java` (+105 -3) ➕ `tools/test_vault_parity.py` (+225 -0) </details> ### 📄 Description Part of #223. ## What `vault::Vault` is vanilla's `VaultBlockEntity` (with `VaultConfig`, `VaultServerData` and `VaultSharedData`), not wired into the game yet (next PR): - load/save with the codecs' leniency: a missing config is `VaultConfig.DEFAULT` (trial key, `chests/trial_chambers/reward`); one with activation past deactivation falls back to the default; one without a key never opens. Like vanilla, loading leaves `total_ejections_needed` out. - `Server.tick`: the display item cycling from the loot table every 20 ticks while active, `VaultState.tickAndGetNext` for every state (connected players within the activation/deactivation range, not yet rewarded, creative included, spectators not), ejection one item per 20 ticks with `spawnItem`'s draws and the pitch from `ejectionProgress`, `onTransition` sounds and level events 3015/3016/3017, shared data updates. - `VaultBlock.useItemOn` + `Server.tryInsertKey`: only while active, key item and count, the rewarded-player check, fail sounds at most every 15 ticks, the reward roll with the table's random sequence, unlocking (14 ticks), the 128 rewarded players cap. This builds on the WIP from `feat/vaults` (bugs-trial-2), finished against vanilla 26.3. ## Proof `tools/test_vault_parity.py` (new, auto-discovered by `tools/parity.py`): a new `mode=vault` of `VanillaNaturalSpawnOracle` / `natural_spawn_fixture` loads a `VaultBlockEntity` from each case's NBT and ticks it with the game time advancing; players move and use trial keys, ominous keys, too few keys and other items through `VaultBlock.useItemOn`. Both sides log every state change, level event, sound (with pitch), ejected item (position and velocity bits), shared data update (display item, connected players), each use (accepted, stack left), and at the end the saved data and the next draw of the level random. ``` 3,000 vault cases match vanilla (1,992 uses_on_active, 22 refused, 854 wrong_keys, 653 items, 2,716 states, 7,851 updates, 901 reached_inactive, 762 reached_active, 470 reached_unlocking, 494 reached_ejecting) ``` Mutation check: a fail-sound buffer of 14 instead of 15 → 15 cases differ; `<=` instead of `<` in the range check → 17 cases differ. ## Self-check - `cargo fmt` clean, `cargo clippy -p horizon-client --all-targets -- -D warnings` clean - `cargo test -p horizon-client --lib vault::` 3 passed - workspace clippy, the client tests and `parity.py` on the combined branch of the #223 PRs: in the last PR of the series ## Needs Ludovic Nothing. 🤖 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 15:57:04 +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#2544
No description provided.