MinecraftForge icon indicating copy to clipboard operation
MinecraftForge copied to clipboard

[1.21.4] ShieldBlockEvent new damage is not applied to shield taking damage

Open Jonathing opened this issue 8 months ago • 0 comments

LivingEntity#hurtServer contains the logic for shield blocking. While updating Forge to 1.21.5, I noticed some suspicious logic when hurting the shield where it does not use the changed value of the event.

Here is the current code:

var ev = net.minecraftforge.event.ForgeEventFactory.onShieldBlock(this, p_361865_, p_365677_);
if (!ev.isCanceled()) {
    if (ev.shieldTakesDamage())
this.hurtCurrentlyUsedShield(p_365677_);
f1 = ev.getBlockedDamage();
p_365677_ -= ev.getBlockedDamage();
// ...

I believe it should be something more along the lines of this:

var ev = net.minecraftforge.event.ForgeEventFactory.onShieldBlock(this, p_361865_, p_365677_);
if (!ev.isCanceled()) {
f1 = ev.getBlockedDamage();
p_365677_ -= f1;
if (ev.shieldTakesDamage())
this.hurtCurrentlyUsedShield(f1);
// ...

This does not apply to 1.21.5 as the logic for shields taking damage has changed.

Jonathing avatar Mar 19 '25 16:03 Jonathing