Skip to content

Commit c441e25

Browse files
committed
Update DamageSource API fixes from api-8
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
2 parents 4f2036c + 0f68286 commit c441e25

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626

2727
import org.spongepowered.api.Sponge;
2828
import org.spongepowered.api.block.BlockState;
29+
import org.spongepowered.api.data.Keys;
2930
import org.spongepowered.api.data.value.Value;
3031
import org.spongepowered.api.entity.FallingBlock;
32+
import org.spongepowered.api.util.Ticks;
3133

3234
public interface FallingBlockDamageSource extends EntityDamageSource {
3335

@@ -50,60 +52,74 @@ static Builder builder() {
5052
*
5153
* @return The immutable value for the damage per block of falling
5254
*/
53-
Value.Immutable<Double> fallDamagePerBlock();
55+
default Value.Immutable<Double> fallDamagePerBlock() {
56+
return this.source().requireValue(Keys.DAMAGE_PER_BLOCK).asImmutable();
57+
}
5458

5559
/**
5660
* Gets the maximum damage the {@link FallingBlock} can deal to another
5761
* entity for falling on the entity.
5862
*
5963
* @return The maximum damage the block can deal
6064
*/
61-
Value.Immutable<Double> maxFallDamage();
65+
default Value.Immutable<Double> maxFallDamage() {
66+
return this.source().requireValue(Keys.MAX_FALL_DAMAGE).asImmutable();
67+
}
6268

6369
/**
6470
* Gets the {@link BlockState} the falling block is representing.
6571
*
6672
* @return The falling block's block state
6773
*/
68-
Value.Immutable<BlockState> blockState();
74+
default Value.Immutable<BlockState> blockState() {
75+
return this.source().requireValue(Keys.BLOCK_STATE).asImmutable();
76+
}
6977

7078
/**
7179
* Gets whether this falling block will try to place itself where
7280
* it lands.
7381
*
7482
* @return True if this block will attempt to place itself when it lands
7583
*/
76-
Value.Immutable<Boolean> canPlaceAsBlock();
84+
default Value.Immutable<Boolean> canPlaceAsBlock() {
85+
return this.source().requireValue(Keys.CAN_PLACE_AS_BLOCK).asImmutable();
86+
}
7787

7888
/**
7989
* Gets whether this falling block can drop as an item if it lands in a
8090
* way that it can not be placed.
8191
*
8292
* @return Whether this falling block can drop as an item
8393
*/
84-
Value.Immutable<Boolean> canDropAsItem();
94+
default Value.Immutable<Boolean> canDropAsItem() {
95+
return this.source().requireValue(Keys.CAN_DROP_AS_ITEM).asImmutable();
96+
}
8597

8698
/**
8799
* Gets the time the block has been falling if spawning a entity in air
88100
* this will need to be set to 1 or it will be instantly removed.
89101
*
90102
* @return The time the block has been falling
91103
*/
92-
Value.Immutable<Integer> fallTime();
104+
default Value.Immutable<Ticks> fallTime() {
105+
return this.source().fallTime().asImmutable();
106+
}
93107

94108
/**
95109
* Gets whether this falling block will damage entities where it lands.
96110
*
97111
* @return Whether this falling block will damage entities where it lands
98112
*/
99-
Value.Immutable<Boolean> canHurtEntities();
113+
default Value.Immutable<Boolean> canHurtEntities() {
114+
return this.source().requireValue(Keys.CAN_HURT_ENTITIES).asImmutable();
115+
}
100116

101117

102118
interface Builder extends EntityDamageSource.EntityDamageSourceBuilder<FallingBlockDamageSource, Builder> {
103119

104120
Builder places(boolean canPlace);
105121

106-
Builder fallTime(int time);
122+
Builder fallTime(Ticks time);
107123

108124
Builder hurtsEntities(boolean hurts);
109125

0 commit comments

Comments
 (0)