[PR #7418] [MERGED] Preserve mob health and clamp effective max-health command values #7591

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7418
Author: @TheMrZZ
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/mob-max-health-clamp


📝 Commits (3)

  • 69bee30 Clamp mob max-health values without altering raw bases or health
  • 27d3d3f Saved max_health bases stay attribute bases
  • 604256c Merge main into #7418

📊 Changes

3 files changed (+60 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+14 -0)
📝 crates/horizon-client/src/game/commands/world_cmds.rs (+18 -7)
📝 tools/command_exec_corpus.py (+28 -0)

📄 Description

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

What and why

Setting a pig's max_health base to -1.75 now keeps its health at 10, returns -1.75 from the raw-base getter, and returns 1 from the effective getter. Previously the command wrote the negative value directly into the gameplay field and reduced current health, causing the pig to disappear after ticking.

The max-health command uses the existing mob attribute base storage and effective-value calculation. Reset updates the same storage, so it also clears a previously overridden base. The command no longer changes Health.

Fixes #7413.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

Official Java 26.3 AttributeCommand.setAttributeBase calls AttributeInstance.setBaseValue and does not call setHealth. getAttributeBase returns the raw base; getAttribute returns the calculated value. AttributeInstance.calculateValue applies modifiers before calling RangedAttribute.sanitizeValue. The max-health attribute has bounds [1,1024].

The command-execution corpus adds negative, zero, positive, and above-range bases; raw/effective getters with and without scales; unchanged health; survival after 25 ticks; and reset controls. These extend the existing positive mob and player-modifier cases without adding modifier-command behavior.

Other projects' code

None.

Self-check

The full command-execution parity harness requires prepared game data and remains for CI. Standard checks below use the repository's missing-resource skips.

pr_ready (tools/pr_ready.py --quick on a local runner, against origin/main at 7504abf07, 3 min 43 s)

Check Result
Scope ✅ 2 files, +46 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (58 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 19 s)
tests: horizon-client ✅ 692 passed (1 min 10 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
mod API up to date ✅ (10 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)

🤖 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/7418 **Author:** [@TheMrZZ](https://github.com/TheMrZZ) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mob-max-health-clamp` --- ### 📝 Commits (3) - [`69bee30`](https://github.com/horizon-rust/horizon/commit/69bee308c248a721b116b63991904901c864423a) Clamp mob max-health values without altering raw bases or health - [`27d3d3f`](https://github.com/horizon-rust/horizon/commit/27d3d3ffdb654817ebdf732b081d7f2ec7f55d83) Saved max_health bases stay attribute bases - [`604256c`](https://github.com/horizon-rust/horizon/commit/604256c62309618037962f8df9eb4e502c00d04e) Merge main into #7418 ### 📊 Changes **3 files changed** (+60 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+14 -0) 📝 `crates/horizon-client/src/game/commands/world_cmds.rs` (+18 -7) 📝 `tools/command_exec_corpus.py` (+28 -0) </details> ### 📄 Description > 🤖 Opened by TheMrZZ's AI agent (Codex, gpt-6.1-sol), not by TheMrZZ personally. ## What and why Setting a pig's `max_health` base to `-1.75` now keeps its health at `10`, returns `-1.75` from the raw-base getter, and returns `1` from the effective getter. Previously the command wrote the negative value directly into the gameplay field and reduced current health, causing the pig to disappear after ticking. The max-health command uses the existing mob attribute base storage and effective-value calculation. Reset updates the same storage, so it also clears a previously overridden base. The command no longer changes `Health`. Fixes #7413. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference Official Java 26.3 `AttributeCommand.setAttributeBase` calls `AttributeInstance.setBaseValue` and does not call `setHealth`. `getAttributeBase` returns the raw base; `getAttribute` returns the calculated value. `AttributeInstance.calculateValue` applies modifiers before calling `RangedAttribute.sanitizeValue`. The max-health attribute has bounds `[1,1024]`. The command-execution corpus adds negative, zero, positive, and above-range bases; raw/effective getters with and without scales; unchanged health; survival after 25 ticks; and reset controls. These extend the existing positive mob and player-modifier cases without adding modifier-command behavior. ## Other projects' code None. ## Self-check The full command-execution parity harness requires prepared game data and remains for CI. Standard checks below use the repository's missing-resource skips. **pr_ready** (`tools/pr_ready.py --quick` on a local runner, against origin/main at 7504abf07, 3 min 43 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +46 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (58 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 19 s) | | tests: horizon-client | ✅ 692 passed (1 min 10 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (10 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) | 🤖 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>
bsakaguchi 2026-11-03 07:20:24 +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#7591
No description provided.