[GH-ISSUE #2630] husks give you the hunger effect even if using a shield #657

Closed
opened 2026-11-02 15:40:52 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @mangodotsh on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/2630

  • What I did:
    • Used a shield to protect me from a husk.
  • What happened:
    • The husk gave the hunger effect to the player anyway.
  • What should happen:
    • The shield should protect the player from that effect.
Originally created by @mangodotsh on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/2630 - **What I did:** - Used a shield to protect me from a husk. - **What happened:** - The husk gave the hunger effect to the player anyway. - **What should happen:** - The shield should protect the player from that effect.
Author
Owner

@kacpherek commented on GitHub (Oct 27, 2026):

Thanks mango for the report! A fix is up in #2646: the hunger (and the similar cave spider, wither skeleton, bee and pufferfish effects) only comes when the hit actually hurts, so a shield blocks it. It's waiting for review.

<!-- gh-comment-id:6434435295 --> @kacpherek commented on GitHub (Oct 27, 2026): Thanks mango for the report! A fix is up in #2646: the hunger (and the similar cave spider, wither skeleton, bee and pufferfish effects) only comes when the hit actually hurts, so a shield blocks it. It's waiting for review.
Author
Owner

@levzzz5154 commented on GitHub (Oct 27, 2026):

🤖 Agent: the shield part of this is covered by #2646 (open), and I checked the rest of vanilla's rule for the husk's hunger against the current main, because there is one more condition there that is still missing.

Vanilla 26.3, net.minecraft.world.entity.monster.zombie.Husk#doHurtTarget:

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;
}

So vanilla's husk applies the hunger when three things hold: the attack landed (doHurtTarget returned true, which a raised shield prevents), the husk's main hand is empty, and the effect lasts 140 * (int) the effective difficulty ticks.

Horizon today, crates/horizon-client/src/mobs/ai.rs, do_hurt_target:

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

The effect is pushed on every melee hit aimed at a player, with a flat 140 ticks, with no check of the husk's main hand and without the difficulty factor. #2646 makes it conditional on the hit landing (the shield) for the husk, the cave spider, the wither skeleton, the bee and the pufferfish; it does not add the empty main hand rule or the difficulty factor, so those two are still open.

Vanilla classes and methods: net.minecraft.world.entity.monster.zombie.Husk#doHurtTarget, net.minecraft.world.entity.Mob#doHurtTarget (the attack that a shield cancels), net.minecraft.world.DifficultyInstance#getEffectiveDifficulty and net.minecraft.world.level.Level#getCurrentDifficultyAt.

I cannot close this issue (no permission on the upstream repository), so I leave it open for a maintainer.

<!-- gh-comment-id:6434669975 --> @levzzz5154 commented on GitHub (Oct 27, 2026): 🤖 Agent: the shield part of this is covered by #2646 (open), and I checked the rest of vanilla's rule for the husk's hunger against the current `main`, because there is one more condition there that is still missing. **Vanilla 26.3, `net.minecraft.world.entity.monster.zombie.Husk#doHurtTarget`:** ```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; } ``` So vanilla's husk applies the hunger when three things hold: the attack landed (`doHurtTarget` returned true, which a raised shield prevents), the husk's **main hand is empty**, and the effect lasts `140 * (int)` the effective difficulty ticks. **Horizon today**, `crates/horizon-client/src/mobs/ai.rs`, `do_hurt_target`: ```rust Species::Husk if who == Who::Player => cx.events.push(MobEvent::EffectPlayer { effect: "minecraft:hunger", ticks: 140, amplifier: 0, }), ``` The effect is pushed on every melee hit aimed at a player, with a flat 140 ticks, with no check of the husk's main hand and without the difficulty factor. #2646 makes it conditional on the hit landing (the shield) for the husk, the cave spider, the wither skeleton, the bee and the pufferfish; it does not add the empty main hand rule or the difficulty factor, so those two are still open. Vanilla classes and methods: `net.minecraft.world.entity.monster.zombie.Husk#doHurtTarget`, `net.minecraft.world.entity.Mob#doHurtTarget` (the attack that a shield cancels), `net.minecraft.world.DifficultyInstance#getEffectiveDifficulty` and `net.minecraft.world.level.Level#getCurrentDifficultyAt`. I cannot close this issue (no permission on the upstream repository), so I leave it open for a maintainer.
Author
Owner

@levzzz5154 commented on GitHub (Oct 27, 2026):

🤖 Agent: the other half of vanilla's rule for the husk's hunger is now in #2692 (my pull request): vanilla's Husk#doHurtTarget also needs the husk's main hand to be empty, and the effect lasts 140 * (int) the effective difficulty ticks (280 ticks on a normal world, not the flat 140 Horizon used). Horizon gave the hunger on every melee hit aimed at a player, whatever the husk held and however long the effect was.

#2692 changes only that: the husk applies the hunger when its main hand is empty, and the length scales with the effective difficulty. The shield half of this report (the effect comes only when the hit lands) is kacpherek's open #2646, which covers 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, #2692 changes whether the husk applies it and how long it lasts.

Vanilla: net.minecraft.world.entity.monster.zombie.Husk#doHurtTarget (result && this.getMainHandItem().isEmpty() && ... and 140 * (int)difficulty), net.minecraft.world.DifficultyInstance#getEffectiveDifficulty.

I cannot close this issue (no permission on the upstream repository), so I leave it open for a maintainer.

<!-- gh-comment-id:6434832758 --> @levzzz5154 commented on GitHub (Oct 27, 2026): 🤖 Agent: the other half of vanilla's rule for the husk's hunger is now in #2692 (my pull request): vanilla's `Husk#doHurtTarget` also needs the husk's **main hand to be empty**, and the effect lasts `140 * (int)` the effective difficulty ticks (280 ticks on a normal world, not the flat 140 Horizon used). Horizon gave the hunger on every melee hit aimed at a player, whatever the husk held and however long the effect was. #2692 changes only that: the husk applies the hunger when its main hand is empty, and the length scales with the effective difficulty. The shield half of this report (the effect comes only when the hit lands) is kacpherek's open #2646, which covers 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, #2692 changes *whether* the husk applies it and *how long* it lasts. Vanilla: `net.minecraft.world.entity.monster.zombie.Husk#doHurtTarget` (`result && this.getMainHandItem().isEmpty() && ...` and `140 * (int)difficulty`), `net.minecraft.world.DifficultyInstance#getEffectiveDifficulty`. I cannot close this issue (no permission on the upstream repository), so I leave it open for a maintainer.
Author
Owner

@socksprox commented on GitHub (Oct 27, 2026):

🤖 Agent: Covered by open PRs #2692 and #2646 (husk hunger needs an empty main hand and hit effects only apply when the hit lands).

<!-- gh-comment-id:6443369573 --> @socksprox commented on GitHub (Oct 27, 2026): 🤖 Agent: Covered by open PRs #2692 and #2646 (husk hunger needs an empty main hand and hit effects only apply when the hit lands).
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#657
No description provided.