Skip to content

Commit 8a144ce

Browse files
committed
DamageSource/Type Changes
dropped all AbstractDamageSources dropped all DamageSource subtypes DamageTypes are now datapack registry types
1 parent 03ac602 commit 8a144ce

14 files changed

+161
-931
lines changed

src/main/java/org/spongepowered/api/event/cause/entity/damage/source/common/package-info.java renamed to src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageEffect.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,13 @@
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
2424
*/
25-
@org.checkerframework.framework.qual.DefaultQualifier(org.checkerframework.checker.nullness.qual.NonNull.class)
26-
package org.spongepowered.api.event.cause.entity.damage.source.common;
25+
package org.spongepowered.api.event.cause.entity.damage;
26+
27+
import org.spongepowered.api.registry.DefaultedRegistryValue;
28+
import org.spongepowered.api.util.annotation.CatalogedBy;
29+
30+
31+
@CatalogedBy(DamageEffects.class)
32+
public interface DamageEffect extends DefaultedRegistryValue {
33+
34+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.spongepowered.api.effect.potion.PotionEffectTypes;
3232
import org.spongepowered.api.entity.Entity;
3333
import org.spongepowered.api.entity.living.player.Player;
34-
import org.spongepowered.api.event.cause.entity.damage.source.FallingBlockDamageSource;
34+
import org.spongepowered.api.event.cause.entity.damage.source.DamageSource;
3535
import org.spongepowered.api.item.enchantment.Enchantment;
3636
import org.spongepowered.api.item.enchantment.EnchantmentType;
3737
import org.spongepowered.api.item.inventory.ItemStack;
@@ -112,7 +112,7 @@ public final class DamageModifierTypes {
112112

113113
/**
114114
* Represents the {@link DamageModifier} that will modify damage from
115-
* a {@link FallingBlockDamageSource}.
115+
* a {@link DamageSource#source()} that is a {@link org.spongepowered.api.entity.FallingBlock}.
116116
*
117117
* <p>Usually, within the {@link DamageModifier#cause ()} will reside
118118
* an {@link ItemStackSnapshot} and an {@link Enchantment} signifying

src/main/java/org/spongepowered/api/event/cause/entity/damage/source/EntityDamageSource.java renamed to src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageScaling.java

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,13 @@
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
* THE SOFTWARE.
2424
*/
25-
package org.spongepowered.api.event.cause.entity.damage.source;
25+
package org.spongepowered.api.event.cause.entity.damage;
2626

27-
import org.spongepowered.api.Sponge;
28-
import org.spongepowered.api.entity.Entity;
27+
import org.spongepowered.api.registry.DefaultedRegistryValue;
28+
import org.spongepowered.api.util.annotation.CatalogedBy;
2929

30-
public interface EntityDamageSource extends DamageSource {
3130

32-
/**
33-
* Creates a new {@link Builder} for building an {@link EntityDamageSource}.
34-
*
35-
* @return A new builder
36-
*/
37-
static Builder builder() {
38-
return Sponge.game().builderProvider().provide(Builder.class);
39-
}
31+
@CatalogedBy(DamageScalings.class)
32+
public interface DamageScaling extends DefaultedRegistryValue {
4033

41-
/**
42-
* Gets the {@link Entity} that is the source.
43-
*
44-
* @return The entity source
45-
*/
46-
Entity source();
47-
48-
interface Builder extends EntityDamageSourceBuilder<EntityDamageSource, Builder> {
49-
50-
}
51-
52-
interface EntityDamageSourceBuilder<T extends EntityDamageSource, B extends EntityDamageSourceBuilder<T, B>> extends DamageSourceBuilder<T, B> {
53-
54-
/**
55-
* Sets the {@link Entity} as the damage "source".
56-
*
57-
* @param entity The entity
58-
* @return This builder, for chaining
59-
*/
60-
B entity(Entity entity);
61-
62-
}
6334
}

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

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,18 @@
2424
*/
2525
package org.spongepowered.api.event.cause.entity.damage;
2626

27-
import org.spongepowered.api.Sponge;
2827
import org.spongepowered.api.entity.Entity;
2928
import org.spongepowered.api.event.cause.entity.damage.source.DamageSource;
3029
import org.spongepowered.api.registry.DefaultedRegistryValue;
30+
import org.spongepowered.api.tag.Tag;
3131
import org.spongepowered.api.util.Nameable;
3232
import org.spongepowered.api.util.annotation.CatalogedBy;
3333

3434
/**
35-
* A {@link DamageType} is a type of "grouping" for {@link DamageSource}s since
36-
* a {@link DamageSource} instance can be inherently different from another
37-
* {@link DamageSource} by virtue of the {@link Object} backing the source.
38-
* Furthermore, it is impossible to refer to {@link DamageSource}s statically
39-
* due to the nature of constructing them. It is possible however, that the
40-
* parent {@link Object} being referred to as the "damage source" can damage
41-
* an {@link Entity} with varying {@link DamageType}s depending on the
42-
* circumstances.
35+
* A {@link DamageType} is a type of "grouping" for {@link DamageSource}s since a {@link DamageSource} instance can be inherently different from
36+
* another {@link DamageSource} by virtue of the {@link Object} backing the source. Furthermore, it is impossible to refer to {@link DamageSource}s
37+
* statically due to the nature of constructing them. It is possible however, that the parent {@link Object} being referred to as the "damage source"
38+
* can damage an {@link Entity} with varying {@link DamageType}s depending on the circumstances.
4339
*/
4440
@CatalogedBy(DamageTypes.class)
4541
public interface DamageType extends DefaultedRegistryValue, Nameable {
@@ -54,16 +50,37 @@ static Builder builder() {
5450
}
5551

5652
/**
57-
* A builder to create {@link DamageType}s.
53+
* Gets the amount of exhaustion this {@link DamageType} will add to the entity, generally only to players.
54+
* <p>
55+
* TODO check this facts:
56+
* <p>In vanilla gameplay this is set to 0.1 by default and
57+
* overridden to 0 if the type is set to be absolute or
58+
* as overriding armor.</p>
59+
*
60+
* @return The increase in exhaustion
5861
*/
59-
interface Builder extends org.spongepowered.api.util.Builder<DamageType, Builder> {
62+
double exhaustion();
63+
64+
/**
65+
* Checks whether this damage types matches a damage type tag.
66+
*
67+
* @param tag The tag to check.
68+
* @return true if this damage type matches the damage type tag.
69+
*/
70+
boolean is(Tag<DamageType> tag);
71+
72+
/**
73+
* Returns the damage scaling.
74+
*
75+
* @return the damage scaling
76+
*/
77+
DamageScaling scaling();
78+
79+
/**
80+
* Returns the damage effect.
81+
*
82+
* @return the damage effect
83+
*/
84+
DamageEffect effect();
6085

61-
/**
62-
* Sets the name of the {@link DamageType}.
63-
*
64-
* @param name The name
65-
* @return This builder, for chaining
66-
*/
67-
Builder name(String name);
68-
}
6986
}

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

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)