Skip to content
Permalink
Browse files

Separated the entity selector from the trilobite class.

  • Loading branch information...
Ri5ux committed Mar 13, 2019
1 parent 34c6d08 commit e1388893fd221df2958a87aaaf2d77534991ec1a
Showing with 61 additions and 0 deletions.
  1. +61 −0 src/main/java/org/avp/entities/ai/alien/EntitySelectorTrilobite.java
@@ -0,0 +1,61 @@
package org.avp.entities.ai.alien;

import java.util.ArrayList;

import org.avp.api.parasitoidic.IParasitoid;
import org.avp.world.capabilities.IOrganism.Organism;
import org.avp.world.capabilities.IOrganism.Provider;

import com.google.common.base.Predicate;

import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;

public class EntitySelectorTrilobite implements Predicate<EntityLivingBase>
{
public static final EntitySelectorTrilobite instance = new EntitySelectorTrilobite();

@Override
public boolean apply(EntityLivingBase potentialTarget)
{
ArrayList<Class<?>> blacklist = IParasitoid.getDefaultEntityBlacklist();

for (Class<?> c : blacklist)
{
if (c.isInstance(potentialTarget))
{
return false;
}
}

Organism organism = (Organism) potentialTarget.getCapability(Provider.CAPABILITY, null);

if (organism != null && organism.hasEmbryo())
{
return false;
}

if (potentialTarget instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) potentialTarget;

if (player.capabilities.isCreativeMode)
{
return false;
}
}

if (potentialTarget instanceof EntityLiving)
{
EntityLiving living = (EntityLiving) potentialTarget;

if (living.isChild())
{
return false;
}
}

return true;
}
}

0 comments on commit e138889

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.