Java Code Examples for net.minecraft.entity.player.EntityPlayer.canEntityBeSeen()

The following are Jave code examples for showing how to use canEntityBeSeen() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: BaseClient   File: EntityEnderman.java   View Source Code Vote up 7 votes
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.armorInventory[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
    {
        return false;
    }
    else
    {
        Vec3 vec3 = player.getLook(1.0F).normalize();
        Vec3 vec31 = new Vec3(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec31.lengthVector();
        vec31 = vec31.normalize();
        double d1 = vec3.dotProduct(vec31);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
Example 2
Project: DecompiledMinecraft   File: EntityEnderman.java   View Source Code Vote up 6 votes
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.armorInventory[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
    {
        return false;
    }
    else
    {
        Vec3 vec3 = player.getLook(1.0F).normalize();
        Vec3 vec31 = new Vec3(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec31.lengthVector();
        vec31 = vec31.normalize();
        double d1 = vec3.dotProduct(vec31);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
Example 3
Project: DecompiledMinecraft   File: EntityEnderman.java   View Source Code Vote up 6 votes
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.armorInventory[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
    {
        return false;
    }
    else
    {
        Vec3 vec3 = player.getLook(1.0F).normalize();
        Vec3 vec31 = new Vec3(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec31.lengthVector();
        vec31 = vec31.normalize();
        double d1 = vec3.dotProduct(vec31);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
Example 4
Project: BaseClient   File: EntityEnderman.java   View Source Code Vote up 6 votes
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.armorInventory[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
    {
        return false;
    }
    else
    {
        Vec3 vec3 = player.getLook(1.0F).normalize();
        Vec3 vec31 = new Vec3(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)(this.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec31.lengthVector();
        vec31 = vec31.normalize();
        double d1 = vec3.dotProduct(vec31);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
Example 5
Project: Backmemed   File: EntityEnderman.java   View Source Code Vote up 6 votes
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = (ItemStack)player.inventory.armorInventory.get(3);

    if (itemstack.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN))
    {
        return false;
    }
    else
    {
        Vec3d vec3d = player.getLook(1.0F).normalize();
        Vec3d vec3d1 = new Vec3d(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)this.getEyeHeight() - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec3d1.lengthVector();
        vec3d1 = vec3d1.normalize();
        double d1 = vec3d.dotProduct(vec3d1);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
Example 6
Project: CustomWorldGen   File: EntityEnderman.java   View Source Code Vote up 6 votes
/**
 * Checks to see if this enderman should be attacking this player
 */
private boolean shouldAttackPlayer(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.armorInventory[3];

    if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN))
    {
        return false;
    }
    else
    {
        Vec3d vec3d = player.getLook(1.0F).normalize();
        Vec3d vec3d1 = new Vec3d(this.posX - player.posX, this.getEntityBoundingBox().minY + (double)this.getEyeHeight() - (player.posY + (double)player.getEyeHeight()), this.posZ - player.posZ);
        double d0 = vec3d1.lengthVector();
        vec3d1 = vec3d1.normalize();
        double d1 = vec3d.dotProduct(vec3d1);
        return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
    }
}
 
Example 7
Project: Zombe-Modpack   File: Dig.java   View Source Code Vote up 5 votes
private static boolean checkReachUse(Entity ent) {
    if (!optCheckReach) return true;
    EntityPlayer player = getPlayer();
    if (player == null || ent == null || player == ent) return false;
    boolean seen = player.canEntityBeSeen(ent);
    float reach = seen ? getReachUseSq(36) : 9f;
    double dx = player.posX - ent.posX;
    double dy = player.posY - ent.posY;
    double dz = player.posZ - ent.posZ;
    double dist = dx*dx + dy*dy + dz*dz;
    return dist < reach;
}
 
Example 8
Project: EndermanEvolution   File: EntityEvolvedEnderman.java   View Source Code Vote up 5 votes
private boolean shouldAttackPlayer(EntityPlayer player) {
	ItemStack itemstack = player.inventory.armorInventory.get(3);

	if (itemstack.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN) || itemstack.getItem() instanceof ItemSkullBase) {
		return false;
	}
	else {
		Vec3d vec3d = player.getLook(1.0F).normalize();
		Vec3d vec3d1 = new Vec3d(posX - player.posX, getEntityBoundingBox().minY + getEyeHeight() - (player.posY + player.getEyeHeight()), posZ - player.posZ);
		double d0 = vec3d1.lengthVector();
		vec3d1 = vec3d1.normalize();
		double d1 = vec3d.dotProduct(vec3d1);
		return d1 > 1.0D - 0.025D / d0 ? player.canEntityBeSeen(this) : false;
	}
}
 
Example 9
Project: Mods   File: SpinToWin.java   View Source Code Vote up 5 votes
public static boolean isSuitableTarget(EntityPlayer attacker, @Nullable EntityLivingBase target, boolean includeInvincibles, boolean checkSight)
{
    if (target == null)
    {
        return false;
    }
    else if (target == attacker)
    {
        return false;
    }
    else if (!target.isEntityAlive())
    {
        return false;
    }
    else if (target instanceof EntityPlayer && !attacker.canAttackPlayer((EntityPlayer) target))
    {
        return false;
    }
    else
    {
        if (attacker instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId() != null)
        {
            if (target instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId().equals(target.getUniqueID()))
            {
                return false;
            }

            if (target == ((IEntityOwnable)attacker).getOwner())
            {
                return false;
            }
        }
        else if (target instanceof EntityPlayer && !includeInvincibles && ((EntityPlayer)target).capabilities.disableDamage)
        {
            return false;
        }

        return !checkSight || attacker.canEntityBeSeen(target);
    }
}