diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 59871ac3a9..cc9a70bc0a 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -110,6 +110,7 @@ import org.spongepowered.api.effect.sound.SoundType; import org.spongepowered.api.effect.sound.music.MusicDisc; import org.spongepowered.api.entity.Ageable; +import org.spongepowered.api.entity.Angerable; import org.spongepowered.api.entity.AreaEffectCloud; import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.EntityArchetype; @@ -372,7 +373,7 @@ public final class Keys { public static final Key> AMBIENT_SOUND = Keys.key(ResourceKey.sponge("ambient_sound"), SoundType.class); /** - * The anger level of a {@link ZombifiedPiglin}. + * The anger level of a {@link Angerable}. * *

Unlike {@link Keys#IS_ANGRY}, the aggressiveness represented by this key may * fade over time and the entity will become peaceful again once its anger @@ -1551,8 +1552,7 @@ public final class Keys { public static final Key> IS_AI_ENABLED = Keys.key(ResourceKey.sponge("is_ai_enabled"), Boolean.class); /** - * Whether an entity is currently aggressive. - * e.g. {@link Wolf wolves} or {@link ZombifiedPiglin} + * Whether a {@link Angerable} is currently aggressive. */ public static final Key> IS_ANGRY = Keys.key(ResourceKey.sponge("is_angry"), Boolean.class); diff --git a/src/main/java/org/spongepowered/api/entity/Angerable.java b/src/main/java/org/spongepowered/api/entity/Angerable.java new file mode 100644 index 0000000000..a6f9d97528 --- /dev/null +++ b/src/main/java/org/spongepowered/api/entity/Angerable.java @@ -0,0 +1,49 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.entity; + +import org.spongepowered.api.data.Keys; +import org.spongepowered.api.data.value.Value; + +public interface Angerable extends Entity { + + /** + * {@link Keys#IS_ANGRY} + * + * @return Whether this entity is currently angry + */ + default Value.Mutable angry() { + return this.requireValue(Keys.IS_ANGRY).asMutable(); + } + + /** + * {@link Keys#ANGER_LEVEL} + * + * @return The anger level, decays over time + */ + default Value.Mutable angerLevel() { + return this.requireValue(Keys.ANGER_LEVEL).asMutable(); + } +} diff --git a/src/main/java/org/spongepowered/api/entity/living/animal/Bee.java b/src/main/java/org/spongepowered/api/entity/living/animal/Bee.java index ea611d361f..9ab0a7378b 100644 --- a/src/main/java/org/spongepowered/api/entity/living/animal/Bee.java +++ b/src/main/java/org/spongepowered/api/entity/living/animal/Bee.java @@ -25,9 +25,10 @@ package org.spongepowered.api.entity.living.animal; import org.spongepowered.api.entity.Aerial; +import org.spongepowered.api.entity.Angerable; /** * Represents a Bee. */ -public interface Bee extends Animal, Aerial { +public interface Bee extends Animal, Aerial, Angerable { } diff --git a/src/main/java/org/spongepowered/api/entity/living/animal/PolarBear.java b/src/main/java/org/spongepowered/api/entity/living/animal/PolarBear.java index 1f520ccc96..613bf9f45e 100644 --- a/src/main/java/org/spongepowered/api/entity/living/animal/PolarBear.java +++ b/src/main/java/org/spongepowered/api/entity/living/animal/PolarBear.java @@ -26,11 +26,12 @@ import org.spongepowered.api.data.Keys; import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.Angerable; /** * Represents a Polar Bear. */ -public interface PolarBear extends Animal { +public interface PolarBear extends Animal, Angerable { /** * {@link Keys#IS_STANDING} diff --git a/src/main/java/org/spongepowered/api/entity/living/animal/Wolf.java b/src/main/java/org/spongepowered/api/entity/living/animal/Wolf.java index aeb90abc0f..20a31a6a89 100644 --- a/src/main/java/org/spongepowered/api/entity/living/animal/Wolf.java +++ b/src/main/java/org/spongepowered/api/entity/living/animal/Wolf.java @@ -27,20 +27,12 @@ import org.spongepowered.api.data.Keys; import org.spongepowered.api.data.type.DyeColor; import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.Angerable; /** * Represents a Wolf. */ -public interface Wolf extends TameableAnimal { - - /** - * {@link Keys#IS_ANGRY} - * - * @return Whether this wolf is currently aggressive - */ - default Value.Mutable angry() { - return this.requireValue(Keys.IS_ANGRY).asMutable(); - } +public interface Wolf extends TameableAnimal, Angerable { /** * {@link Keys#DYE_COLOR} diff --git a/src/main/java/org/spongepowered/api/entity/living/golem/IronGolem.java b/src/main/java/org/spongepowered/api/entity/living/golem/IronGolem.java index f13a1ccd37..5fec98caae 100644 --- a/src/main/java/org/spongepowered/api/entity/living/golem/IronGolem.java +++ b/src/main/java/org/spongepowered/api/entity/living/golem/IronGolem.java @@ -26,11 +26,12 @@ import org.spongepowered.api.data.Keys; import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.Angerable; /** * Represents an Iron Golem. */ -public interface IronGolem extends Golem { +public interface IronGolem extends Golem, Angerable { /** * {@link Keys#IS_PLAYER_CREATED} diff --git a/src/main/java/org/spongepowered/api/entity/living/monster/Enderman.java b/src/main/java/org/spongepowered/api/entity/living/monster/Enderman.java index 7b9d1207ff..4045485009 100644 --- a/src/main/java/org/spongepowered/api/entity/living/monster/Enderman.java +++ b/src/main/java/org/spongepowered/api/entity/living/monster/Enderman.java @@ -26,12 +26,13 @@ import org.spongepowered.api.data.Keys; import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.Angerable; import org.spongepowered.api.entity.living.Monster; /** * Represents an Enderman. */ -public interface Enderman extends Monster { +public interface Enderman extends Monster, Angerable { /** * {@link Keys#IS_SCREAMING}. diff --git a/src/main/java/org/spongepowered/api/entity/living/monster/zombie/ZombifiedPiglin.java b/src/main/java/org/spongepowered/api/entity/living/monster/zombie/ZombifiedPiglin.java index 1700698811..c1e5f6bece 100644 --- a/src/main/java/org/spongepowered/api/entity/living/monster/zombie/ZombifiedPiglin.java +++ b/src/main/java/org/spongepowered/api/entity/living/monster/zombie/ZombifiedPiglin.java @@ -24,30 +24,10 @@ */ package org.spongepowered.api.entity.living.monster.zombie; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.entity.Angerable; /** * Represents a Zombie Pigman. */ -public interface ZombifiedPiglin extends Zombie { - - /** - * {@link Keys#ANGER_LEVEL} - * - * @return The anger level, decays over time - */ - default Value.Mutable angerLevel() { - return this.requireValue(Keys.ANGER_LEVEL).asMutable(); - } - - /** - * {@link Keys#IS_ANGRY} - * - * @return Whether this zombified piglin is currently aggressive - */ - default Value.Mutable angry() { - return this.requireValue(Keys.IS_ANGRY).asMutable(); - } - +public interface ZombifiedPiglin extends Zombie, Angerable { }