Skip to content

Commit

Permalink
Abstract angel level to a separate interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMorpheus committed Jul 7, 2024
1 parent b4fab13 commit f77c260
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/spongepowered/api/data/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
import org.spongepowered.api.entity.ExperienceOrb;
import org.spongepowered.api.entity.FallingBlock;
import org.spongepowered.api.entity.Item;
import org.spongepowered.api.entity.Neutral;
import org.spongepowered.api.entity.Ownable;
import org.spongepowered.api.entity.ai.goal.GoalExecutorTypes;
import org.spongepowered.api.entity.display.BillboardType;
Expand Down Expand Up @@ -372,7 +373,7 @@ public final class Keys {
public static final Key<Value<SoundType>> AMBIENT_SOUND = Keys.key(ResourceKey.sponge("ambient_sound"), SoundType.class);

/**
* The anger level of a {@link ZombifiedPiglin}.
* The anger level of a {@link Neutral}.
*
* <p>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
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/org/spongepowered/api/entity/Neutral.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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 Neutral extends Entity {

/**
* {@link Keys#ANGER_LEVEL}
*
* @return The anger level, decays over time
*/
default Value.Mutable<Integer> angerLevel() {
return this.requireValue(Keys.ANGER_LEVEL).asMutable();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
package org.spongepowered.api.entity.living.animal;

import org.spongepowered.api.entity.Aerial;
import org.spongepowered.api.entity.Neutral;

/**
* Represents a Bee.
*/
public interface Bee extends Animal, Aerial {
public interface Bee extends Animal, Aerial, Neutral {
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.entity.Neutral;

/**
* Represents a Polar Bear.
*/
public interface PolarBear extends Animal {
public interface PolarBear extends Animal, Neutral {

/**
* {@link Keys#IS_STANDING}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +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.Neutral;

/**
* Represents a Wolf.
*/
public interface Wolf extends TameableAnimal {
public interface Wolf extends TameableAnimal, Neutral {

/**
* {@link Keys#IS_ANGRY}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.entity.Neutral;

/**
* Represents an Iron Golem.
*/
public interface IronGolem extends Golem {
public interface IronGolem extends Golem, Neutral {

/**
* {@link Keys#IS_PLAYER_CREATED}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.entity.Neutral;
import org.spongepowered.api.entity.living.Monster;

/**
* Represents an Enderman.
*/
public interface Enderman extends Monster {
public interface Enderman extends Monster, Neutral {

/**
* {@link Keys#IS_SCREAMING}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,12 @@

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.entity.Neutral;

/**
* Represents a Zombie Pigman.
*/
public interface ZombifiedPiglin extends Zombie {

/**
* {@link Keys#ANGER_LEVEL}
*
* @return The anger level, decays over time
*/
default Value.Mutable<Integer> angerLevel() {
return this.requireValue(Keys.ANGER_LEVEL).asMutable();
}
public interface ZombifiedPiglin extends Zombie, Neutral {

/**
* {@link Keys#IS_ANGRY}
Expand Down

0 comments on commit f77c260

Please sign in to comment.