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
Part1
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.
Part2
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.
3.Shield overlay
As ShieldValue is invisible to the player, they need HUD to keep a handle on the situation.
not sure if affects, also is old the post so not sure if there are new methods, the Y position of the mobs can be affected by its height, normal bipeds like player should be +1 since the player camera or arrow is +1 blocks higher.
aparently you can use raytrace and distance 0 to get the coords of the camera, it only helps with coord y since x and z camera coords and entity coords are the same, but my idea is a bit overkill.
also i know its almost impossible but technically can be achieve, dont put a divider without a security measure, i mean if its 0 everything explodes. just if divider = 0 -> divider =.1 idunno
welp yeah you got the divider = 0 already there srry about that