2018-09-16 00:45:44 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
|
|
|
|
|
|
|
import com.google.common.base.Predicate;
|
|
|
|
import com.minelittlepony.unicopia.player.PlayerSpeciesList;
|
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
|
|
|
public final class Predicates {
|
|
|
|
public static final Predicate<EntityPlayer> INTERACT_WITH_CLOUDS = player -> {
|
|
|
|
return player != null && PlayerSpeciesList.instance().getPlayer(player).getPlayerSpecies().canInteractWithClouds();
|
|
|
|
};
|
2018-09-19 09:07:39 +02:00
|
|
|
|
2018-09-24 21:37:16 +02:00
|
|
|
public static final Predicate<Entity> MAGI = entity -> {
|
|
|
|
return entity instanceof EntityPlayer && PlayerSpeciesList.instance().getPlayer((EntityPlayer)entity).getPlayerSpecies().canCast();
|
2018-09-19 09:07:39 +02:00
|
|
|
};
|
|
|
|
|
2018-09-19 10:17:18 +02:00
|
|
|
public static final Predicate<Entity> ITEMS = entity -> {
|
2019-02-01 10:37:47 +01:00
|
|
|
return entity instanceof EntityItem && entity.isEntityAlive() && entity.ticksExisted > 1;
|
2018-09-19 10:17:18 +02:00
|
|
|
};
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
public static final Predicate<EntityItem> ITEM_INTERACT_WITH_CLOUDS = item -> {
|
2018-09-19 10:17:18 +02:00
|
|
|
return ITEMS.test(item) && PlayerSpeciesList.instance().getEntity(item).getPlayerSpecies().canInteractWithClouds();
|
2018-09-16 00:45:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
public static final Predicate<Entity> ENTITY_INTERACT_WITH_CLOUDS = entity -> {
|
|
|
|
return entity != null && (
|
|
|
|
(entity instanceof EntityPlayer && INTERACT_WITH_CLOUDS.test((EntityPlayer)entity))
|
|
|
|
|| (entity instanceof EntityItem && ITEM_INTERACT_WITH_CLOUDS.test((EntityItem)entity))
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2019-03-03 23:33:40 +01:00
|
|
|
public static final Predicate<Entity> BUGGY = entity -> {
|
|
|
|
return entity instanceof EntityPlayer
|
|
|
|
&& PlayerSpeciesList.instance().getPlayer((EntityPlayer)entity).getPlayerSpecies() == Race.CHANGELING;
|
|
|
|
};
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
public static EntityPlayer getPlayerFromEntity(Entity entity) {
|
|
|
|
if (entity instanceof EntityPlayer) {
|
|
|
|
return (EntityPlayer) entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entity instanceof EntityItem) {
|
|
|
|
EntityItem item = (EntityItem)entity;
|
|
|
|
if (item.getOwner() != null) {
|
|
|
|
return item.getEntityWorld().getPlayerEntityByName(item.getOwner());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|