The bug
The shield does not block attacks when the player faces straight up, even if the enemy is above the player.
How to reproduce
Ensure you are in Survival or Adventure mode
Hold a shield:
/item replace entity @s weapon with shield
Face directly upwards
Summon an arrow directly above you:
/summon arrow ~ ~20 ~
Attempt to block the arrow with the shield
→ ❌ The shield does not block the arrow
Code analysis and fix
Code analysis by @unknown can be found in this comment.
Linked issues
Attachments
Comments 20
Well Shields cant block something if your facing the wrong way, that's like trying to block an arrow that was fired from the right by shielding to the left. If its inside you then 1. Why would u be there 2. Shields block something coming towards it, it doesn't help if its already past the shield.
Now on the other hand say a skeleton was firing at you and a zombie comes up behind you and hits you right before an arrow does and then the arrow hits you, if then you take 100% damage from the zombie & the arrow then i can see a bug otherwise i don't see a problem here.
Edit: on another note it might be a hitbox issue.
Edit0: Or the Zombies have learned to put their arms around a shield.
P.S.
Why are you inside a creeper in the first place?
1. Going inside a creeper was for steps to reproduce
2. If you want to see an attack range issue, see MC-108937, this ticket is related as they both affect shield blocking, have to do with mobs and how they inflict damage, and have to do with poor attack mechanics, but MC-108937 is for mobs only, and this ticket has to do with poor blocking.
3. this ticket reports poor graphical shield alignment causing probably unintended backstabbing mechanics.
also relates to MC-100949
Never has happened to me that is all i'm saying. the only thing that has negated my shield is the /kill command.(And stuff from behind me)
by the way What do you mean by "poor graphical shield alignment"? that sounds like a rendering issue more than anything.
Edit: Just finished 128 Shields and nothing.
This bug occurs because LivingEntity::isDamageSourceBlocked uses the entity's viewpoint instead of its direction.
To fix this bug, just replace getViewVector(1) with new Vec3(getDirection().getStepX(), getDirection().getStepY(), getDirection().getStepZ());
Hi! I've just done some testing, and it appears that this issue isn't fixed so I'm reopening this report. I've attached a video that demonstrates that this is still a problem in 23w40a.
[media]@unknown
The way shields work:
They block damage from a 180 degree hemisphere. And the center of this hemisphere is disregarding the vertical view direction, it only takes horizontal into account.
So vertically the angle from directly below the player (-90 degrees) to directly above the player (+90 degrees) is covered, no matter where the player is looking vertically. And those checks are non-inclusive. -90 < x < 90, not -90 <= x <= 90. That's the reason why you can still hit yourself by spawning an arrow directly above you.
The bug which was fixed here:
Due to incorrect calculations if a player looked directly up or down blocking fully stopped working or became unpredictable independently from where the damage was coming from.
It means that now if you use this command:/summon arrow ~0.01 ~20 ~
while looking east and directly up you will be protected.
So I will close this bug as fixed again.
relates to MC-108937