package com.minelittlepony.unicopia.entity; import java.util.Optional; import javax.annotation.Nullable; import com.minelittlepony.unicopia.ability.magic.Caster; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; public interface PonyContainer> { Equine create(); T get(); @SuppressWarnings("unchecked") @Nullable default Caster getCaster() { T ientity = get(); if (ientity instanceof Caster) { return (Caster)ientity; } return null; } @SuppressWarnings("unchecked") static > Optional> of(Entity entity) { if (entity instanceof PonyContainer) { return Optional.of(((PonyContainer)entity)); } return Optional.empty(); } }