2020-09-22 15:11:20 +02:00
|
|
|
package com.minelittlepony.unicopia.entity;
|
2020-01-16 12:35:46 +01:00
|
|
|
|
2021-02-14 16:53:44 +01:00
|
|
|
import java.util.Optional;
|
|
|
|
|
2020-04-15 18:12:00 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2020-04-15 14:22:03 +02:00
|
|
|
import com.minelittlepony.unicopia.Race;
|
2021-03-06 10:58:44 +01:00
|
|
|
import com.minelittlepony.unicopia.projectile.ProjectileImpactListener;
|
2020-04-15 18:12:00 +02:00
|
|
|
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
2020-01-16 12:35:46 +01:00
|
|
|
|
2020-04-15 18:12:00 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
2021-02-14 16:53:44 +01:00
|
|
|
import net.minecraft.entity.damage.DamageSource;
|
2020-01-16 12:35:46 +01:00
|
|
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
2020-05-10 17:18:45 +02:00
|
|
|
import net.minecraft.util.Tickable;
|
2020-01-16 12:35:46 +01:00
|
|
|
|
2021-03-06 10:58:44 +01:00
|
|
|
public interface Equine<T extends Entity> extends NbtSerialisable, Tickable, ProjectileImpactListener {
|
2020-01-16 12:35:46 +01:00
|
|
|
Race getSpecies();
|
|
|
|
|
2020-05-10 17:18:45 +02:00
|
|
|
Physics getPhysics();
|
2020-01-16 12:35:46 +01:00
|
|
|
|
2020-05-10 17:18:45 +02:00
|
|
|
void setSpecies(Race race);
|
2020-01-16 12:35:46 +01:00
|
|
|
|
2021-03-06 13:27:52 +01:00
|
|
|
/**
|
|
|
|
* Gets the last magical entity to attack us.
|
|
|
|
*/
|
|
|
|
Entity getAttacker();
|
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
/**
|
|
|
|
* Returns true if this player is fully invisible.
|
|
|
|
* Held items and other effects will be hidden as well.
|
|
|
|
*/
|
|
|
|
default boolean isInvisible() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether this player should be invisible.
|
|
|
|
*/
|
|
|
|
default void setInvisible(boolean invisible) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-01-27 11:05:22 +01:00
|
|
|
* Called at the beginning of an update cycle.
|
2020-01-16 12:35:46 +01:00
|
|
|
*/
|
2020-01-27 17:37:22 +01:00
|
|
|
default boolean beforeUpdate() {
|
|
|
|
return false;
|
|
|
|
}
|
2020-01-16 12:35:46 +01:00
|
|
|
|
|
|
|
/**
|
2020-01-27 11:05:22 +01:00
|
|
|
* Event triggered when this entity is hit by a projectile.
|
2020-01-16 12:35:46 +01:00
|
|
|
*/
|
2021-03-06 10:58:44 +01:00
|
|
|
@Override
|
2020-01-16 12:35:46 +01:00
|
|
|
default boolean onProjectileImpact(ProjectileEntity projectile) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when this entity jumps
|
|
|
|
*/
|
|
|
|
default void onJump() {
|
|
|
|
|
|
|
|
}
|
2020-04-15 18:12:00 +02:00
|
|
|
|
2021-02-14 16:53:44 +01:00
|
|
|
/**
|
|
|
|
* Called when an entity is harmed.
|
|
|
|
*/
|
|
|
|
default Optional<Boolean> onDamage(DamageSource source, float amount) {
|
|
|
|
return Optional.empty();
|
|
|
|
}
|
|
|
|
|
2020-04-15 18:12:00 +02:00
|
|
|
@Nullable
|
2020-09-22 15:11:20 +02:00
|
|
|
static <T extends Equine<?>> T of(Entity entity) {
|
2020-04-15 18:12:00 +02:00
|
|
|
return PonyContainer.<Entity, T>of(entity)
|
|
|
|
.map(PonyContainer::get)
|
|
|
|
.orElse(null);
|
|
|
|
}
|
2020-01-16 12:35:46 +01:00
|
|
|
}
|