[PR #7606] Apply loot damage modifiers on the correct random stream #7711

Open
opened 2026-11-03 07:22:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7606
Author: @TheMrZZ
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/h040-loot-set-damage


📝 Commits (1)

  • 0a9a77d Apply loot damage modifiers on the correct random stream

📊 Changes

3 files changed (+73 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/terrain_cmds.rs (+8 -5)
📝 crates/horizon-items/src/items.rs (+31 -0)
📝 tools/command_exec_corpus.py (+34 -0)

📄 Description

🤖 Opened by TheMrZZ's AI agent (Codex, gpt-6.1-sol), not by TheMrZZ personally.

What and why

Fixes #7543.

/loot ignored set_damage, leaving generated swords pristine and skipping random providers. Apply the modifier in the items loot engine: check damageability before sampling, use the stack's maximum durability, and preserve the float/add/clamp/floor calculation. Inline command loot tables now select their random_sequence when present, so the generated damage and the next stream value both match vanilla.

Extend the command corpus with constant/clamped values, additive composition, uniform providers, non-damageable stone, and an explicit table without a random sequence. Nested table expansion and tracker counts remain in #7506; the shared-file scope was coordinated there.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Java 26.3 SetItemDamageFunction.run, LootTable.getRandomItemsRaw, and LootContext.Builder.create, inspected from the pinned bytecode. Ineligible stacks do not sample the damage provider. Loot tables pass their optional random sequence to context creation.

tools/test_command_exec_parity.py --only 'loot set damage' checks the actual command path using the 26.3 modifier field. The unchanged source at f030c124c matches 23/30 observations; the fix matches 30/30. The scripts and fresh Java records are byte-for-byte identical between runs. Checks include feedback, styles, results, chest contents, and next named-stream values, without adding ticks to the corpus.

Other projects' code

None.

Self-check

pr_ready (tools/pr_ready.py --quick locally, against origin/main at f030c124c, 19 min 56 s)

Check Result
Scope ✅ 3 files, +73 −5
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (2 min 50 s)
rustfmt ✅ (30 s)
clippy ✅ (4 min 37 s)
tests: horizon-client, horizon-items ✅ 752 passed (4 min 12 s)
doc tests ✅ 0 passed (4 s)
content root tests ✅ 24 passed (7 min 6 s)
mod API up to date ✅ (36 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

port_ledger.py check --base origin/main completed with no new gaps or stale citations; it reports the existing uncited-dispatch advisory for cmd_loot.

The Python suite ran 614 tests with one skipped.

The full affected parity suite has not been run locally (pr_ready --quick); the focused command group above was run separately.

🤖 Generated with Codex


🔄 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/7606 **Author:** [@TheMrZZ](https://github.com/TheMrZZ) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/h040-loot-set-damage` --- ### 📝 Commits (1) - [`0a9a77d`](https://github.com/horizon-rust/horizon/commit/0a9a77d387fc026dd129c80c6fa0404029bedd70) Apply loot damage modifiers on the correct random stream ### 📊 Changes **3 files changed** (+73 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/terrain_cmds.rs` (+8 -5) 📝 `crates/horizon-items/src/items.rs` (+31 -0) 📝 `tools/command_exec_corpus.py` (+34 -0) </details> ### 📄 Description > 🤖 Opened by TheMrZZ's AI agent (Codex, gpt-6.1-sol), not by TheMrZZ personally. ## What and why Fixes #7543. `/loot` ignored `set_damage`, leaving generated swords pristine and skipping random providers. Apply the modifier in the items loot engine: check damageability before sampling, use the stack's maximum durability, and preserve the float/add/clamp/floor calculation. Inline command loot tables now select their `random_sequence` when present, so the generated damage and the next stream value both match vanilla. Extend the command corpus with constant/clamped values, additive composition, uniform providers, non-damageable stone, and an explicit table without a random sequence. Nested table expansion and tracker counts remain in #7506; the shared-file scope was coordinated there. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Java 26.3 `SetItemDamageFunction.run`, `LootTable.getRandomItemsRaw`, and `LootContext.Builder.create`, inspected from the pinned bytecode. Ineligible stacks do not sample the damage provider. Loot tables pass their optional random sequence to context creation. `tools/test_command_exec_parity.py --only 'loot set damage'` checks the actual command path using the 26.3 `modifier` field. The unchanged source at `f030c124c` matches 23/30 observations; the fix matches 30/30. The scripts and fresh Java records are byte-for-byte identical between runs. Checks include feedback, styles, results, chest contents, and next named-stream values, without adding ticks to the corpus. ## Other projects' code None. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` locally, against origin/main at f030c124c, 19 min 56 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +73 −5 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (2 min 50 s) | | rustfmt | ✅ (30 s) | | clippy | ✅ (4 min 37 s) | | tests: horizon-client, horizon-items | ✅ 752 passed (4 min 12 s) | | doc tests | ✅ 0 passed (4 s) | | content root tests | ✅ 24 passed (7 min 6 s) | | mod API up to date | ✅ (36 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | `port_ledger.py check --base origin/main` completed with no new gaps or stale citations; it reports the existing uncited-dispatch advisory for `cmd_loot`. The Python suite ran 614 tests with one skipped. The full affected parity suite has not been run locally (`pr_ready --quick`); the focused command group above was run separately. 🤖 Generated with [Codex](https://openai.com/codex/) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7711
No description provided.