Skip to content

Commit aed2610

Browse files
committed
Damage step frames
1 parent 6e829fe commit aed2610

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

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

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
package org.spongepowered.api.event.cause.entity.damage;
2626

2727
import org.spongepowered.api.Sponge;
28-
import org.spongepowered.api.event.Cause;
28+
import org.spongepowered.api.event.CauseStackManager;
2929

3030
import java.util.Optional;
31+
import java.util.function.Consumer;
3132

3233
/**
33-
* A damage modifier that is or may become a {@link DamageStep}.
34+
* A damage modifier that will create a {@link DamageStep}.
3435
*/
3536
public interface DamageModifier {
3637

@@ -42,20 +43,19 @@ public interface DamageModifier {
4243
DamageStepType type();
4344

4445
/**
45-
* Gets the {@link Cause} of this modifier.
46+
* Gets the consumer that will modify the cause frame.
4647
*
47-
* @return The cause
48+
* @return The cause frame modifier
4849
*/
49-
Cause cause();
50+
Optional<Consumer<CauseStackManager.StackFrame>> frame();
5051

5152
/**
52-
* Gets the function that modify the damage.
53-
* The function may be absent if the sole purpose of this modifier is to apply children steps,
54-
* or if the step was made by the platform, usually the root step.
53+
* Gets the function that will modify the damage.
54+
* The function may be absent if the sole purpose of this modifier is to apply children steps.
5555
*
56-
* @return the modifier function
56+
* @return the damage modifier
5757
*/
58-
Optional<Function> function();
58+
Optional<Function> damage();
5959

6060
@FunctionalInterface
6161
interface Function {
@@ -78,18 +78,6 @@ static Builder builder() {
7878
return Sponge.game().builderProvider().provide(Builder.class);
7979
}
8080

81-
/**
82-
* Creates a new {@link DamageModifier}.
83-
*
84-
* @param type The damage step type
85-
* @param cause The modifier cause
86-
* @param function The modifier function
87-
* @return The new damage modifier
88-
*/
89-
static DamageModifier of(DamageStepType type, Cause cause, Function function) {
90-
return DamageModifier.builder().type(type).cause(cause).function(function).build();
91-
}
92-
9381
/**
9482
* A builder to create {@link DamageModifier}s.
9583
*/
@@ -104,19 +92,19 @@ interface Builder extends org.spongepowered.api.util.Builder<DamageModifier, Bui
10492
Builder type(DamageStepType type);
10593

10694
/**
107-
* Sets the {@link Cause} for this modifier.
95+
* Sets the cause frame modifier.
10896
*
109-
* @param cause The modifier cause
97+
* @param frameModifier The frame modifier
11098
* @return this builder for chaining
11199
*/
112-
Builder cause(Cause cause);
100+
Builder frame(Consumer<CauseStackManager.StackFrame> frameModifier);
113101

114102
/**
115103
* Sets the {@link Function} for this modifier.
116104
*
117-
* @param function The modifier function
105+
* @param function The damage function
118106
* @return this builder for chaining
119107
*/
120-
Builder function(Function function);
108+
Builder damage(Function function);
121109
}
122110
}

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
package org.spongepowered.api.event.cause.entity.damage;
2626

27+
import org.spongepowered.api.event.Cause;
28+
2729
import java.util.List;
2830
import java.util.Optional;
2931
import java.util.OptionalDouble;
@@ -33,7 +35,21 @@
3335
* Steps are structured as trees where children modify the input or output of the parent step.
3436
* A damage calculation is made of multiple trees of steps.
3537
*/
36-
public interface DamageStep extends DamageModifier {
38+
public interface DamageStep {
39+
40+
/**
41+
* Gets the {@link DamageStepType} of this step.
42+
*
43+
* @return the step type
44+
*/
45+
DamageStepType type();
46+
47+
/**
48+
* Gets the {@link Cause} of this step.
49+
*
50+
* @return The cause of this step
51+
*/
52+
Cause cause();
3753

3854
/**
3955
* Gets whether this step is skipped.

0 commit comments

Comments
 (0)