2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2020-04-26 14:46:03 +02:00
|
|
|
import java.util.function.Predicate;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2020-10-04 12:58:01 +02:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
2020-09-25 20:24:48 +02:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.Spell;
|
2020-09-22 15:11:20 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.Equine;
|
2020-09-25 20:24:48 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
2021-02-18 21:30:43 +01:00
|
|
|
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
2020-04-26 19:51:30 +02:00
|
|
|
|
2021-02-18 21:30:43 +01:00
|
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
2021-02-18 21:30:43 +01:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
2020-01-16 12:35:46 +01:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
public interface EquinePredicates {
|
2020-04-26 14:46:03 +02:00
|
|
|
Predicate<Entity> IS_PLAYER = e -> e instanceof PlayerEntity;
|
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
Predicate<Entity> RACE_INTERACT_WITH_CLOUDS = entity -> Equine.of(entity).getSpecies().canInteractWithClouds();
|
2020-04-26 14:46:03 +02:00
|
|
|
|
2020-09-25 20:24:48 +02:00
|
|
|
Predicate<Entity> PLAYER_EARTH = IS_PLAYER.and(entity -> Equine.of(entity).getSpecies() == Race.EARTH);
|
|
|
|
Predicate<Entity> PLAYER_BAT = IS_PLAYER.and(entity -> Equine.of(entity).getSpecies() == Race.BAT);
|
2020-09-22 15:11:20 +02:00
|
|
|
Predicate<Entity> PLAYER_UNICORN = IS_PLAYER.and(entity -> Equine.of(entity).getSpecies().canCast());
|
|
|
|
Predicate<Entity> PLAYER_CHANGELING = IS_PLAYER.and(entity -> Equine.of(entity).getSpecies() == Race.CHANGELING);
|
2020-04-26 14:46:03 +02:00
|
|
|
Predicate<Entity> PLAYER_PEGASUS = IS_PLAYER.and(entity -> ((PlayerEntity)entity).abilities.creativeMode || RACE_INTERACT_WITH_CLOUDS.test(entity));
|
|
|
|
|
2020-10-04 12:58:01 +02:00
|
|
|
Predicate<Entity> IS_CASTER = e -> !e.removed && (e instanceof Caster || PLAYER_UNICORN.test(e));
|
|
|
|
|
2021-02-18 21:30:43 +01:00
|
|
|
Predicate<LivingEntity> HAS_WANT_IT_NEED_IT = e -> EnchantmentHelper.getEquipmentLevel(UEnchantments.WANT_IT_NEED_IT, e) > 0;
|
|
|
|
|
2020-09-25 20:24:48 +02:00
|
|
|
static Predicate<Entity> carryingSpell(Class<? extends Spell> type) {
|
|
|
|
return IS_PLAYER.and(entity -> Pony.of((PlayerEntity)entity).getSpellOrEmpty(type, false).isPresent());
|
|
|
|
}
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|