Unicopia/src/main/java/com/minelittlepony/unicopia/entity/PonyContainer.java
2021-08-04 15:38:03 +02:00

22 lines
549 B
Java

package com.minelittlepony.unicopia.entity;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import net.minecraft.entity.Entity;
public interface PonyContainer<T extends Equine<?>> {
Equine<?> create();
T get();
@SuppressWarnings("unchecked")
static <E extends Entity, T extends Equine<?>> Optional<PonyContainer<T>> of(@Nullable Entity entity) {
if (entity instanceof PonyContainer) {
return Optional.of(((PonyContainer<T>)entity));
}
return Optional.empty();
}
}