[PR #2692] [CLOSED] The husk's hunger needs an empty main hand and the difficulty's length #4546

Closed
opened 2026-11-03 04:17:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2692
Author: @levzzz5154
Created: 10/27/2026
Status: ❌ Closed

Base: main ← Head: fix/husk-hunger-empty-hand


📝 Commits (3)

  • 498de72 Frog: walk at vanilla's speed
  • 7ad4926 The husk's hunger needs an empty main hand and the difficulty's length
  • da8805a Merge #2579 (frog tests beside the husk tests)

📊 Changes

1 file changed (+90 additions, -5 deletions)

View changed files

📝 crates/horizon-client/src/mobs/ai.rs (+90 -5)

📄 Description

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

What and why

In vanilla 26.3, Husk#doHurtTarget gives the player the hunger effect under three conditions: the attack landed, the husk's main hand is empty, and the effect lasts 140 * (int) the effective difficulty ticks.

public boolean doHurtTarget(final ServerLevel level, final Entity target) {
   boolean result = super.doHurtTarget(level, target);
   if (result && this.getMainHandItem().isEmpty() && target instanceof LivingEntity livingEntity) {
      float difficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
      livingEntity.addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)difficulty), this);
   }
   return result;
}

Horizon gave the hunger on every melee hit aimed at a player, with a flat 140 ticks:

Species::Husk if who == Who::Player => cx.events.push(MobEvent::EffectPlayer {
    effect: "minecraft:hunger",
    ticks: 140,
    amplifier: 0,
}),

So a husk holding a weapon still starved the player, and the effect was half as long as vanilla's on a normal world (vanilla: 140 * 2 = 280 ticks, Horizon: 140).

This pull request makes those two rules match vanilla: the rule now lives in husk_hunger_ticks, which do_hurt_target asks for the effect's length. A husk with something in its main hand gives no hunger at all, and the length is 140 * (int) the effective difficulty ticks.

The shield half of the report is not in this pull request. That is the "the effect comes only when the hit lands" rule, and it is covered by kacpherek's open pull request #2646, which does the same for the husk, the cave spider, the wither skeleton, the bee and the pufferfish. The two do not overlap: #2646 changes when the effect is applied, this one changes whether the husk applies it and how long it lasts.

Fixes #2630

Vanilla reference

  • net.minecraft.world.entity.monster.zombie.Husk#doHurtTarget: the hunger needs result (the attack landed), this.getMainHandItem().isEmpty(), and lasts 140 * (int)difficulty where the difficulty is level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty().
  • net.minecraft.world.DifficultyInstance#getEffectiveDifficulty and net.minecraft.world.level.Level#getCurrentDifficultyAt: the effective difficulty Horizon's LocalDifficulty::effective already carries.
  • net.minecraft.world.entity.Mob#doHurtTarget: the attack a raised shield cancels (that half is #2646).

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on cachyos-x8664, against upstream/main at d74d39cb0, 4 min 58 s)

Check Result
Scope ✅ 1 files, +38 −5
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 325 passed (16 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 9 s)
tests: horizon-client ✅ 1288 passed (2 min 48 s)
doc tests ✅ 0 passed (31 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 74 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, command_exec, composter, crafter and 62 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
$ cargo test -p horizon-client --lib -- the_husks_hunger_needs_an_empty_main_hand_and_the_difficulty
running 1 test
test mobs::ai::husk_tests::the_husks_hunger_needs_an_empty_main_hand_and_the_difficulty ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1164 filtered out; finished in 0.00s

The test pins the rule: no main hand item, no hunger, and 140 * (int) the effective difficulty ticks. Before this change the rule did not exist at all (the hunger was applied on every hit with a flat 140 ticks), and the helper the test calls is only reachable from do_hurt_target, so the build fails (an unused function, which the CI's cargo clippy --workspace --all-targets -- -D warnings rejects) if the call is taken out.

cargo fmt -p horizon-client is clean.

🤖 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/2692 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/husk-hunger-empty-hand` --- ### 📝 Commits (3) - [`498de72`](https://github.com/horizon-rust/horizon/commit/498de72da2ffa7a6726f32104540f3d4a16e6312) Frog: walk at vanilla's speed - [`7ad4926`](https://github.com/horizon-rust/horizon/commit/7ad49263516e1bc1beee207a795e98b6f9a461f4) The husk's hunger needs an empty main hand and the difficulty's length - [`da8805a`](https://github.com/horizon-rust/horizon/commit/da8805ad12f6cedcb2323208e6e3b96f3a5da321) Merge #2579 (frog tests beside the husk tests) ### 📊 Changes **1 file changed** (+90 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/ai.rs` (+90 -5) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code), not by levzzz5154 himself. ## What and why In vanilla 26.3, `Husk#doHurtTarget` gives the player the hunger effect under three conditions: the attack landed, the husk's **main hand is empty**, and the effect lasts `140 * (int)` the effective difficulty ticks. ```java public boolean doHurtTarget(final ServerLevel level, final Entity target) { boolean result = super.doHurtTarget(level, target); if (result && this.getMainHandItem().isEmpty() && target instanceof LivingEntity livingEntity) { float difficulty = level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); livingEntity.addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)difficulty), this); } return result; } ``` Horizon gave the hunger on **every** melee hit aimed at a player, with a flat 140 ticks: ```rust Species::Husk if who == Who::Player => cx.events.push(MobEvent::EffectPlayer { effect: "minecraft:hunger", ticks: 140, amplifier: 0, }), ``` So a husk holding a weapon still starved the player, and the effect was half as long as vanilla's on a normal world (vanilla: 140 * 2 = 280 ticks, Horizon: 140). This pull request makes those two rules match vanilla: the rule now lives in `husk_hunger_ticks`, which `do_hurt_target` asks for the effect's length. A husk with something in its main hand gives no hunger at all, and the length is `140 * (int)` the effective difficulty ticks. **The shield half of the report is not in this pull request.** That is the "the effect comes only when the hit lands" rule, and it is covered by kacpherek's open pull request #2646, which does the same for the husk, the cave spider, the wither skeleton, the bee and the pufferfish. The two do not overlap: #2646 changes *when* the effect is applied, this one changes *whether* the husk applies it and *how long* it lasts. Fixes #2630 ## Vanilla reference - `net.minecraft.world.entity.monster.zombie.Husk#doHurtTarget`: the hunger needs `result` (the attack landed), `this.getMainHandItem().isEmpty()`, and lasts `140 * (int)difficulty` where the difficulty is `level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty()`. - `net.minecraft.world.DifficultyInstance#getEffectiveDifficulty` and `net.minecraft.world.level.Level#getCurrentDifficultyAt`: the effective difficulty Horizon's `LocalDifficulty::effective` already carries. - `net.minecraft.world.entity.Mob#doHurtTarget`: the attack a raised shield cancels (that half is #2646). ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on cachyos-x8664, against upstream/main at d74d39cb0, 4 min 58 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +38 −5 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 325 passed (16 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 9 s) | | tests: horizon-client | ✅ 1288 passed (2 min 48 s) | | doc tests | ✅ 0 passed (31 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 74 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, command_exec, composter, crafter and 62 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | ``` $ cargo test -p horizon-client --lib -- the_husks_hunger_needs_an_empty_main_hand_and_the_difficulty running 1 test test mobs::ai::husk_tests::the_husks_hunger_needs_an_empty_main_hand_and_the_difficulty ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1164 filtered out; finished in 0.00s ``` The test pins the rule: no main hand item, no hunger, and `140 * (int)` the effective difficulty ticks. Before this change the rule did not exist at all (the hunger was applied on every hit with a flat 140 ticks), and the helper the test calls is only reachable from `do_hurt_target`, so the build fails (an unused function, which the CI's `cargo clippy --workspace --all-targets -- -D warnings` rejects) if the call is taken out. `cargo fmt -p horizon-client` is clean. 🤖 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-03 04:17:58 +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#4546
No description provided.