[PR #417] [MERGED] Vaults in the game: ticking, keys, rewards and the display item #2549

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

📋 Pull Request Information

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

Base: main ← Head: feat/vault-game


📝 Commits (3)

  • 2567a4a Add the vault's server logic with a parity harness
  • 2c07b5e Wire vaults into the game
  • 3ac3efe Save round-trip: a vault's next state update moves with the clock

📊 Changes

12 files changed (+1574 additions, -9 deletions)

View changed files

📝 crates/horizon-client/examples/natural_spawn_fixture.rs (+201 -2)
📝 crates/horizon-client/src/containers.rs (+9 -0)
📝 crates/horizon-client/src/game.rs (+10 -0)
📝 crates/horizon-client/src/game/trial_spawner.rs (+3 -3)
➕ crates/horizon-client/src/game/vault.rs (+242 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/save.rs (+2 -0)
📝 crates/horizon-client/src/structure_blocks.rs (+3 -0)
➕ crates/horizon-client/src/vault.rs (+771 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java (+105 -3)
📝 tools/test_save_roundtrip_parity.py (+2 -1)
➕ tools/test_vault_parity.py (+225 -0)

📄 Description

Part of #223. Stacked on #410 (base feat/vault-logic; retarget to main once it merges).

What

  • BlockEntity::Vault: vaults load from saves and from structure templates, so trial chambers keep their configs (ominous vaults: ominous_trial_key → chests/trial_chambers/reward_ominous), and save back.
  • game/vault.rs: every vault's Server.tick each game tick with the level random and the reward tables' random sequences. State changes go through setBlockAndUpdate; sounds, level events and ejected rewards (spawnItem from 1.2 above the floor) reach the world.
  • Keys: VaultBlock.useItemOn runs in use_hand before the item's own use. An active vault takes the click with anything in hand (wrong items get the fail sound), counts used, and consumes the key count unless the player is creative.
  • VaultRenderer: the display item, GROUND context, spinning 10°/tick (VaultClientData), at (0.5, 0.4, 0.5) with the item cluster poses.
  • trial_spawner_updated becomes mark_block_entity_updated, shared by both.

Particles, ambient sounds and the level events' client side (3015–3017) come in the next PR.

Verified in game (Mac mini, offscreen, release build)

Seed 12345, /locate structure minecraft:trial_chambers → [128, ~, −528]: 25 vaults and 14 trial spawners loaded.

  • The chamber's ominous vault at (137, −13, −517) loaded its ominous config from the template. It went inactive → active when I walked up (display item: an enchanted golden apple). It took 1 ominous_trial_key → unlocking → ejecting, and I picked up the ominous rewards (23 emeralds, an emerald block, a flow banner pattern). Then inactive: the rewarded player isn't connected any more.
  • A /setblock default vault in daylight: an emerald spins inside the cage (visible through the side bars; the front panel covers it, as in vanilla). 1 trial key consumed, timeline in game ticks unlocking 2717 → ejecting 2730 → inactive ≈2809. Rewards: arrows, an ominous bottle, emeralds, diamonds, a sapling.

Self-check

  • cargo fmt, cargo clippy -p horizon-client --all-targets -- -D warnings clean
  • cargo test -p horizon-client: all pass (692 lib, 44 + 15 + 2 + 2 + 2 bin/integration)
  • tools/test_vault_parity.py (from #410): 3,000 cases match. The full parity.py --changed run is on the combined branch, in the last PR.

Needs Ludovic

Nothing. Vaults only see the local player, like trial spawners since #320: LAN guests don't open vaults yet.

🤖 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/417 **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-game` --- ### 📝 Commits (3) - [`2567a4a`](https://github.com/horizon-rust/horizon/commit/2567a4a41aaeb13318756d2deba5331d81f61d63) Add the vault's server logic with a parity harness - [`2c07b5e`](https://github.com/horizon-rust/horizon/commit/2c07b5e621805ec33cdc198615be7a25c0a7742f) Wire vaults into the game - [`3ac3efe`](https://github.com/horizon-rust/horizon/commit/3ac3efe749c8d7cba9a1b768d070290a81d33606) Save round-trip: a vault's next state update moves with the clock ### 📊 Changes **12 files changed** (+1574 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/natural_spawn_fixture.rs` (+201 -2) 📝 `crates/horizon-client/src/containers.rs` (+9 -0) 📝 `crates/horizon-client/src/game.rs` (+10 -0) 📝 `crates/horizon-client/src/game/trial_spawner.rs` (+3 -3) ➕ `crates/horizon-client/src/game/vault.rs` (+242 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/save.rs` (+2 -0) 📝 `crates/horizon-client/src/structure_blocks.rs` (+3 -0) ➕ `crates/horizon-client/src/vault.rs` (+771 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java` (+105 -3) 📝 `tools/test_save_roundtrip_parity.py` (+2 -1) ➕ `tools/test_vault_parity.py` (+225 -0) </details> ### 📄 Description Part of #223. Stacked on #410 (base `feat/vault-logic`; retarget to `main` once it merges). ## What - `BlockEntity::Vault`: vaults load from saves **and from structure templates**, so trial chambers keep their configs (ominous vaults: `ominous_trial_key` → `chests/trial_chambers/reward_ominous`), and save back. - `game/vault.rs`: every vault's `Server.tick` each game tick with the level random and the reward tables' random sequences. State changes go through `setBlockAndUpdate`; sounds, level events and ejected rewards (`spawnItem` from 1.2 above the floor) reach the world. - Keys: `VaultBlock.useItemOn` runs in `use_hand` before the item's own use. An active vault takes the click with anything in hand (wrong items get the fail sound), counts `used`, and consumes the key count unless the player is creative. - `VaultRenderer`: the display item, GROUND context, spinning 10°/tick (`VaultClientData`), at (0.5, 0.4, 0.5) with the item cluster poses. - `trial_spawner_updated` becomes `mark_block_entity_updated`, shared by both. Particles, ambient sounds and the level events' client side (3015–3017) come in the next PR. ## Verified in game (Mac mini, offscreen, release build) Seed 12345, `/locate structure minecraft:trial_chambers` → [128, ~, −528]: 25 vaults and 14 trial spawners loaded. - The chamber's ominous vault at (137, −13, −517) loaded its ominous config from the template. It went `inactive → active` when I walked up (display item: an enchanted golden apple). It took 1 `ominous_trial_key` → `unlocking` → `ejecting`, and I picked up the ominous rewards (23 emeralds, an emerald block, a flow banner pattern). Then `inactive`: the rewarded player isn't connected any more. - A `/setblock` default vault in daylight: an emerald spins inside the cage (visible through the side bars; the front panel covers it, as in vanilla). 1 trial key consumed, timeline in game ticks `unlocking` 2717 → `ejecting` 2730 → `inactive` ≈2809. Rewards: arrows, an ominous bottle, emeralds, diamonds, a sapling. ## Self-check - `cargo fmt`, `cargo clippy -p horizon-client --all-targets -- -D warnings` clean - `cargo test -p horizon-client`: all pass (692 lib, 44 + 15 + 2 + 2 + 2 bin/integration) - `tools/test_vault_parity.py` (from #410): 3,000 cases match. The full `parity.py --changed` run is on the combined branch, in the last PR. ## Needs Ludovic Nothing. Vaults only see the local player, like trial spawners since #320: LAN guests don't open vaults yet. 🤖 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:06 +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#2549
No description provided.