2020-09-22 15:11:20 +02:00
|
|
|
package com.minelittlepony.unicopia.entity;
|
2020-04-15 18:12:00 +02:00
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
public interface PonyContainer<T extends Equine<?>> {
|
2020-04-15 18:12:00 +02:00
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
Equine<?> create();
|
2020-04-15 18:12:00 +02:00
|
|
|
|
|
|
|
T get();
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
2021-03-06 22:11:17 +01:00
|
|
|
static <E extends Entity, T extends Equine<?>> Optional<PonyContainer<T>> of(@Nullable Entity entity) {
|
2020-04-15 18:12:00 +02:00
|
|
|
if (entity instanceof PonyContainer) {
|
|
|
|
return Optional.of(((PonyContainer<T>)entity));
|
|
|
|
}
|
|
|
|
return Optional.empty();
|
|
|
|
}
|
|
|
|
}
|