Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 75 additions & 2 deletions src/main/java/org/spongepowered/api/entity/living/Living.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.attribute.Attribute;
import org.spongepowered.api.entity.attribute.AttributeHolder;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.projectile.source.EntityProjectileSource;
import org.spongepowered.api.scoreboard.TeamMember;
import org.spongepowered.math.imaginary.Quaterniond;
Expand All @@ -46,6 +47,22 @@
*/
public interface Living extends AttributeHolder, Entity, EntityProjectileSource, TeamMember {

/**
* {@link Keys#ABSORPTION}
* @return The amount of {@link org.spongepowered.api.effect.potion.PotionEffectTypes#ABSORPTION}
*/
default Value.Mutable<Double> absorption() {
return this.requireValue(Keys.ABSORPTION).asMutable();
}

/**
* {@link Keys#ACTIVE_ITEM}
* @return The active item, such as food being eaten
*/
default Value.Mutable<ItemStackSnapshot> activeItem() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabizou

Can you give some guidance on how the Values in these interfaces should be returned to consumers?

Like, should they always be Value.Mutable? Just Value? Does it depend on what it is returning and what you can do with it in the game?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am preferring they're always Mutable from entities. It does make sense that they are reflective of their Key variables, but at the end of the day, the developer is likely to want to mutate the value and maybe offer it back, or present it to another entity after mutation.

return this.requireValue(Keys.ACTIVE_ITEM).asMutable();
}

/**
* {@link Keys#HEALTH}
* @return The health value
Expand Down Expand Up @@ -78,12 +95,68 @@ default Value.Mutable<Vector3d> headRotation() {
return this.requireValue(Keys.HEAD_ROTATION).asMutable();
}

/**
* {@link Keys#EYE_HEIGHT}
* @return The height of the eyes
*/
default Value<Double> eyeHeight() {
return this.requireValue(Keys.EYE_HEIGHT);
}

/**
* {@link Keys#EYE_POSITION}
* @return The position of the eyes
*/
default Value<Vector3d> eyePosition() {
return this.requireValue(Keys.EYE_POSITION);
}

/**
* {@link Keys#LAST_DAMAGE_RECEIVED}
* @return The last damage received
*/
default Optional<Value.Immutable<Double>> lastDamageReceived() {
return this.getValue(Keys.LAST_DAMAGE_RECEIVED).map(Value::asImmutable);
default Optional<Value<Double>> lastDamageReceived() {
return this.getValue(Keys.LAST_DAMAGE_RECEIVED);
}

/**
* {@link Keys#FALL_DISTANCE}
* @return The fall distance
*/
default Value.Mutable<Double> fallDistance() {
return this.requireValue(Keys.FALL_DISTANCE).asMutable();
}

/**
* {@link Keys#MAX_AIR}
* @return The max air supply
*/
default Value.Mutable<Integer> maxAir() {
return this.requireValue(Keys.MAX_AIR).asMutable();
}

/**
* {@link Keys#REMAINING_AIR}
* @return The remaining air supply
*/
default Value.Mutable<Integer> remainingAir() {
return this.requireValue(Keys.REMAINING_AIR).asMutable();
}

/**
* {@link Keys#STUCK_ARROWS}
* @return The amount of stuck arrows
*/
default Value.Mutable<Integer> stuckArrows() {
return this.requireValue(Keys.STUCK_ARROWS).asMutable();
}

/**
* {@link Keys#WALKING_SPEED}
* @return The base walking speed
*/
default Value.Mutable<Double> walkingSpeed() {
return this.requireValue(Keys.WALKING_SPEED).asMutable();
}

/**
Expand Down