| 1 | package net.minecraft.util;
|
| 2 |
|
| 3 | import com.google.common.base.Predicate;
|
| 4 | import net.minecraft.entity.Entity;
|
| 5 | import net.minecraft.entity.EntityLiving;
|
| 6 | import net.minecraft.entity.EntityLivingBase;
|
| 7 | import net.minecraft.entity.item.EntityArmorStand;
|
| 8 | import net.minecraft.entity.player.EntityPlayer;
|
| 9 | import net.minecraft.inventory.IInventory;
|
| 10 | import net.minecraft.item.ItemStack;
|
| 11 |
|
| 12 | public final class EntitySelectors
|
| 13 | {
|
| 14 | public static final Predicate<Entity> selectAnything = new Predicate<Entity>()
|
| 15 | {
|
| 16 | public boolean apply(Entity p_apply_1_)
|
| 17 | {
|
| 18 | return p_apply_1_.isEntityAlive();
|
| 19 | }
|
| 20 | };
|
| 21 | public static final Predicate<Entity> IS_STANDALONE = new Predicate<Entity>()
|
| 22 | {
|
| 23 | public boolean apply(Entity p_apply_1_)
|
| 24 | {
|
| 25 | return p_apply_1_.isEntityAlive() && p_apply_1_.riddenByEntity == null && p_apply_1_.ridingEntity == null;
|
| 26 | }
|
| 27 | };
|
| 28 | public static final Predicate<Entity> selectInventories = new Predicate<Entity>()
|
| 29 | {
|
| 30 | public boolean apply(Entity p_apply_1_)
|
| 31 | {
|
| 32 | return p_apply_1_ instanceof IInventory && p_apply_1_.isEntityAlive();
|
| 33 | }
|
| 34 | };
|
| 35 | public static final Predicate<Entity> NOT_SPECTATING = new Predicate<Entity>()
|
| 36 | {
|
| 37 | public boolean apply(Entity p_apply_1_)
|
| 38 | {
|
| 39 | return !(p_apply_1_ instanceof EntityPlayer) || !((EntityPlayer)p_apply_1_).isSpectator();
|
| 40 | }
|
| 41 | };
|
| 42 |
|
| 43 | public static class ArmoredMob implements Predicate<Entity>
|
| 44 | {
|
| 45 | private final ItemStack armor;
|
| 46 |
|
| 47 | public ArmoredMob(ItemStack armor)
|
| 48 | {
|
| 49 | this.armor = armor;
|
| 50 | }
|
| 51 |
|
| 52 | public boolean apply(Entity p_apply_1_)
|
| 53 | {
|
| 54 | if (!p_apply_1_.isEntityAlive())
|
| 55 | {
|
| 56 | return false;
|
| 57 | }
|
| 58 | else if (!(p_apply_1_ instanceof EntityLivingBase))
|
| 59 | {
|
| 60 | return false;
|
| 61 | }
|
| 62 | else
|
| 63 | {
|
| 64 | EntityLivingBase entitylivingbase = (EntityLivingBase)p_apply_1_;
|
| 65 | return entitylivingbase.getEquipmentInSlot(EntityLiving.getArmorPosition(this.armor)) != null ? false : (entitylivingbase instanceof EntityLiving ? ((EntityLiving)entitylivingbase).canPickUpLoot() : (entitylivingbase instanceof EntityArmorStand ? true : entitylivingbase instanceof EntityPlayer));
|
| 66 | }
|
| 67 | }
|
| 68 | }
|
| 69 | }
|
| 70 |
|