use of org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource in project Skree by Skelril.
the class DefensiveClusterListener method getSource.
public Optional<Living> getSource(Cause cause) {
Optional<EntityDamageSource> optEntityDamageSource = cause.first(EntityDamageSource.class);
if (!optEntityDamageSource.isPresent()) {
return Optional.empty();
}
EntityDamageSource damageSource = optEntityDamageSource.get();
Entity source;
if (damageSource instanceof IndirectEntityDamageSource) {
source = ((IndirectEntityDamageSource) damageSource).getIndirectSource();
} else {
source = damageSource.getSource();
}
if (!(source instanceof Living)) {
return Optional.empty();
}
return Optional.of((Living) source);
}
Aggregations