Skip to content

Commit 6fc2a58

Browse files
committed
Replace setBaseDamage and setFinalDamage with damage steps
1 parent e6ea6db commit 6fc2a58

File tree

2 files changed

+18
-33
lines changed

2 files changed

+18
-33
lines changed

src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageStepTypes.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ public final class DamageStepTypes {
108108
*/
109109
public static final DefaultedRegistryReference<DamageStepType> ENCHANTMENT_COOLDOWN = DamageStepTypes.key(ResourceKey.sponge("enchantment_cooldown"));
110110

111+
/**
112+
* Represents the last {@link DamageStep} applied during a damage calculation.
113+
* This step happens just before the {@link org.spongepowered.api.event.entity.DamageCalculationEvent.Post}.
114+
* This step does nothing but can be used to add modifiers to the final damage.
115+
*/
116+
public static final DefaultedRegistryReference<DamageStepType> END = DamageStepTypes.key(ResourceKey.sponge("end"));
117+
111118
/**
112119
* Represents a {@link DamageStep} that will modify freezing damage.
113120
* E.g. {@link org.spongepowered.api.entity.living.monster.Blaze} take more damage from freezing sources.
@@ -152,6 +159,13 @@ public final class DamageStepTypes {
152159
*/
153160
public static final DefaultedRegistryReference<DamageStepType> SHIELD = DamageStepTypes.key(ResourceKey.sponge("shield"));
154161

162+
/**
163+
* Represents the first {@link DamageStep} applied during a damage calculation.
164+
* This step happens just after the {@link org.spongepowered.api.event.entity.DamageCalculationEvent.Pre}.
165+
* This step does nothing but can be used to add modifiers to the base damage.
166+
*/
167+
public static final DefaultedRegistryReference<DamageStepType> START = DamageStepTypes.key(ResourceKey.sponge("start"));
168+
155169
/**
156170
* Represents a {@link DamageStep} that is applied for a sweeping attack.
157171
*/

src/main/java/org/spongepowered/api/event/entity/DamageCalculationEvent.java

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.spongepowered.api.event.cause.entity.damage.DamageModifier;
3232
import org.spongepowered.api.event.cause.entity.damage.DamageStep;
3333
import org.spongepowered.api.event.cause.entity.damage.DamageStepType;
34+
import org.spongepowered.api.event.cause.entity.damage.DamageStepTypes;
3435
import org.spongepowered.api.event.impl.entity.AbstractDamageCalculationEventPre;
3536
import org.spongepowered.api.item.inventory.ItemStack;
3637
import org.spongepowered.api.world.difficulty.Difficulty;
@@ -48,7 +49,7 @@
4849
*
4950
* <p>Optimally, these steps can be traced to a
5051
* particular object, be it an {@link ItemStack}, {@link Difficulty}, or
51-
* simply an an attribute. Given that {@link Cause} has a unique capability of
52+
* simply an attribute. Given that {@link Cause} has a unique capability of
5253
* storing any and every {@link Object} willing to be passed into it, we
5354
* can easily represent these "sources" of "steps" in a {@link Cause}.
5455
* Now, knowing the "source" will not provide enough information, so a
@@ -65,17 +66,10 @@ public interface DamageCalculationEvent extends Event, Cancellable {
6566
*/
6667
Entity entity();
6768

68-
/**
69-
* Gets the original base damage to deal to the targeted {@link Entity}.
70-
*
71-
* @see #baseDamage()
72-
* @return The original base damage
73-
*/
74-
double originalBaseDamage();
75-
7669
/**
7770
* Gets the base damage to deal to the targeted {@link Entity}.
7871
* The base damage is the value before the calculation and its {@link DamageStep}s.
72+
* To modify the base damage, add a modifier to the step associated to {@link DamageStepTypes#START}.
7973
*
8074
* @return The base damage
8175
*/
@@ -88,14 +82,6 @@ public interface DamageCalculationEvent extends Event, Cancellable {
8882
@ImplementedBy(AbstractDamageCalculationEventPre.class)
8983
interface Pre extends DamageCalculationEvent {
9084

91-
/**
92-
* Sets the base damage to deal to the targeted {@link Entity}.
93-
*
94-
* @see #baseDamage()
95-
* @param baseDamage The base damage
96-
*/
97-
void setBaseDamage(double baseDamage);
98-
9985
/**
10086
* Gets a mutable list of all modifiers that applies just before the step.
10187
*
@@ -120,31 +106,16 @@ interface Pre extends DamageCalculationEvent {
120106
*/
121107
interface Post extends DamageCalculationEvent {
122108

123-
/**
124-
* Gets the original final damage to deal to the targeted {@link Entity}.
125-
*
126-
* @see #finalDamage()
127-
* @return The final amount of damage to originally deal
128-
*/
129-
double originalFinalDamage();
130-
131109
/**
132110
* Gets the final damage to deal to the targeted {@link Entity}.
133111
* The final damage is the value after the calculation and its {@link DamageStep}s.
134112
* The final damage is the amount of health being lost by the {@link Entity}, if health is tracked.
113+
* To modify the final damage, add a modifier to the step associated to {@link DamageStepTypes#END}.
135114
*
136115
* @return The final damage
137116
*/
138117
double finalDamage();
139118

140-
/**
141-
* Sets the final damage to deal to the targeted {@link Entity}.
142-
*
143-
* @see #finalDamage()
144-
* @param finalDamage The base damage
145-
*/
146-
void setFinalDamage(double finalDamage);
147-
148119
/**
149120
* Gets the list of the captured steps during the damage calculation in the order they have been applied.
150121
* Note that this list is not an exhaustive representation of all the operations applied,

0 commit comments

Comments
 (0)