|
26 | 26 |
|
27 | 27 | import org.spongepowered.api.Sponge; |
28 | 28 | import org.spongepowered.api.event.cause.entity.damage.DamageType; |
| 29 | +import org.spongepowered.api.event.cause.entity.damage.source.DamageSource; |
29 | 30 | import org.spongepowered.api.tag.Tag; |
30 | 31 | import org.spongepowered.api.util.ResettableBuilder; |
31 | 32 |
|
32 | | -import java.util.Optional; |
33 | 33 | import java.util.Set; |
34 | 34 |
|
35 | 35 | /** |
|
38 | 38 | */ |
39 | 39 | public interface ShieldDamageReduction { |
40 | 40 |
|
41 | | - /** |
42 | | - * Returns the {@link DamageType damage types} this reduction applies to. |
43 | | - * {@link Optional#empty()} means this reduction is not restricted to any given damage type. |
44 | | - * |
45 | | - * @return the affected damage types |
46 | | - */ |
47 | | - Optional<Set<DamageType>> damageTypes(); |
48 | | - |
49 | | - /** |
50 | | - * Returns the maximum angle between the users facing direction and the direction of the incoming attack. |
51 | | - * |
52 | | - * @return the maximum angle |
53 | | - */ |
54 | | - double horizontalBlockingAngle(); |
55 | | - |
56 | | - /** |
57 | | - * Returns the constant amount of damage to be blocked. |
58 | | - * |
59 | | - * @return a constant amount of damage to block |
60 | | - */ |
61 | | - double constantReduction(); |
62 | | - |
63 | | - /** |
64 | | - * Returns fractional amount of damage to block, where a factor of 1 means that all damage is blocked, |
65 | | - * and a factor of 0 that no damage is blocked. |
66 | | - * |
67 | | - * @return fractional amount of damage to block |
68 | | - */ |
69 | | - double fractionalReduction(); |
| 41 | + double resolve(DamageSource source, double damage, double angle); |
70 | 42 |
|
71 | 43 | static Builder builder() { |
72 | 44 | return Sponge.game().builderProvider().provide(Builder.class); |
73 | 45 | } |
74 | 46 |
|
75 | 47 | interface Builder extends ResettableBuilder<ShieldDamageReduction, Builder> { |
76 | 48 |
|
| 49 | + /** |
| 50 | + * Limits the {@link DamageType damage types} this reduction applies to. |
| 51 | + * |
| 52 | + * @param damageTypes the affected damage types |
| 53 | + * @return This builder, for chaining |
| 54 | + */ |
77 | 55 | Builder damageTypes(Set<DamageType> damageTypes); |
78 | 56 |
|
| 57 | + /** |
| 58 | + * Limits the {@link DamageType damage types} this reduction applies to. |
| 59 | + * |
| 60 | + * @param tag the tag defining affected damage types |
| 61 | + * @return This builder, for chaining |
| 62 | + */ |
79 | 63 | Builder damageTypes(Tag<DamageType> tag); |
80 | 64 |
|
| 65 | + /** |
| 66 | + * Sets the maximum angle between the users facing direction and the direction of the incoming attack. |
| 67 | + * |
| 68 | + * @param angle the maximum angle |
| 69 | + * @return This builder, for chaining |
| 70 | + */ |
81 | 71 | Builder horizontalBlockingAngle(double angle); |
82 | 72 |
|
| 73 | + /** |
| 74 | + * Sets the constant amount of damage to be blocked. |
| 75 | + * |
| 76 | + * @param constant a constant amount of damage to block |
| 77 | + * @return This builder, for chaining |
| 78 | + */ |
83 | 79 | Builder constantReduction(double constant); |
84 | 80 |
|
| 81 | + /** |
| 82 | + * Sets fractional amount of damage to block, where a factor of 1 means that all damage is blocked, |
| 83 | + * and a factor of 0 that no damage is blocked. |
| 84 | + * |
| 85 | + * @param fraction fractional amount of damage to block |
| 86 | + * @return This builder, for chaining |
| 87 | + */ |
85 | 88 | Builder fractionalReduction(double fraction); |
86 | 89 |
|
87 | 90 | ShieldDamageReduction build(); |
|
0 commit comments