package com.minelittlepony.unicopia.entity; import java.util.Optional; import java.util.function.Predicate; import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.EntityConvertable; import com.minelittlepony.unicopia.EquineContext; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.projectile.ProjectileImpactListener; import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.Tickable; import net.minecraft.entity.Entity; public interface Equine extends NbtSerialisable, Tickable, ProjectileImpactListener, EntityConvertable, EquineContext { Physics getPhysics(); void setSpecies(Race race); /** * Called at the beginning of an update cycle. */ boolean beforeUpdate(); @SuppressWarnings("unchecked") static > Optional of(@Nullable E entity) { return entity instanceof Container ? Optional.of(((Container)entity).get()) : Optional.empty(); } @SuppressWarnings("unchecked") static Optional of(@Nullable E entity, Predicate typeCheck) { return entity instanceof Container ? (Optional)Optional.of((Object)((Container)entity).get()).filter(typeCheck) : Optional.empty(); } interface Container> { Equine create(); T get(); } }