Topic category: User side tutorials
This tutorial brings Dark Souls' parry shield into Minecraft,
.......but without durability setting option.
1.The food shield
Although it seemed pretty weird that a shield is a kind of food, trigger On player stopped using does not work on tools and items, and I don't know how to write java code to use that trigger, there is no other choice.
This global trigger prevents players from eating up their shield after holding it 9999 ticks.
set right-click to defend, and external custom key to parry.
ShieldValue recovers as shield time increases and absorbs equal value damage via global trigger setting.
When the player stops using the shield, the ShieldTick and ShieldValue reset.
2.Defence and Parry procedure
Axes can not cool down this shield as vanilla ones, to make up, they can deal 1.5 times damage to ShieldValue.
x1y1z1 is the directional vector for the attacked player, and x2y2z2 is the directional vector for attacker or arrows.
Ranged items are not always facing forward, so the velocity vector is better for judging the incoming direction of the attack.
cos 135°≈ -0.707106.
Angle of the vector determines whether a defence is successful.
Besides, this can be used not only for shields blocking attacks but also for weapons backstabbing, just reverse the >.
Ignoring the pitch simplifies the calculation relative to the Y-axis
Considering the case of yaw as only 2 kinds, face and back, more calculation can be simplified.
If the defence is successful, cancel the trigger, and if ShieldValue drops to 0 or below, punish the shield-bearer.
Parry procedure is similar to normal defence procedure.
As ShieldValue is invisible to the player, they need HUD to keep a handle on the situation.