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

The following are Jave code examples for showing how to use getDistanceSqToEntity() 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: DecompiledMinecraft   File: Village.java   View Source Code Vote up 6 votes
public EntityPlayer getNearestTargetPlayer(EntityLivingBase villageDefender)
{
    double d0 = Double.MAX_VALUE;
    EntityPlayer entityplayer = null;

    for (String s : this.playerReputation.keySet())
    {
        if (this.isPlayerReputationTooLow(s))
        {
            EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(s);

            if (entityplayer1 != null)
            {
                double d1 = entityplayer1.getDistanceSqToEntity(villageDefender);

                if (d1 <= d0)
                {
                    entityplayer = entityplayer1;
                    d0 = d1;
                }
            }
        }
    }

    return entityplayer;
}
 
Example 2
Project: DecompiledMinecraft   File: Village.java   View Source Code Vote up 6 votes
public EntityPlayer getNearestTargetPlayer(EntityLivingBase villageDefender)
{
    double d0 = Double.MAX_VALUE;
    EntityPlayer entityplayer = null;

    for (String s : this.playerReputation.keySet())
    {
        if (this.isPlayerReputationTooLow(s))
        {
            EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(s);

            if (entityplayer1 != null)
            {
                double d1 = entityplayer1.getDistanceSqToEntity(villageDefender);

                if (d1 <= d0)
                {
                    entityplayer = entityplayer1;
                    d0 = d1;
                }
            }
        }
    }

    return entityplayer;
}
 
Example 3
Project: BaseClient   File: Village.java   View Source Code Vote up 6 votes
public EntityPlayer getNearestTargetPlayer(EntityLivingBase villageDefender)
{
    double d0 = Double.MAX_VALUE;
    EntityPlayer entityplayer = null;

    for (String s : this.playerReputation.keySet())
    {
        if (this.isPlayerReputationTooLow(s))
        {
            EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(s);

            if (entityplayer1 != null)
            {
                double d1 = entityplayer1.getDistanceSqToEntity(villageDefender);

                if (d1 <= d0)
                {
                    entityplayer = entityplayer1;
                    d0 = d1;
                }
            }
        }
    }

    return entityplayer;
}
 
Example 4
Project: BaseClient   File: Village.java   View Source Code Vote up 6 votes
public EntityPlayer getNearestTargetPlayer(EntityLivingBase villageDefender)
{
    double d0 = Double.MAX_VALUE;
    EntityPlayer entityplayer = null;

    for (String s : this.playerReputation.keySet())
    {
        if (this.isPlayerReputationTooLow(s))
        {
            EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(s);

            if (entityplayer1 != null)
            {
                double d1 = entityplayer1.getDistanceSqToEntity(villageDefender);

                if (d1 <= d0)
                {
                    entityplayer = entityplayer1;
                    d0 = d1;
                }
            }
        }
    }

    return entityplayer;
}
 
Example 5
Project: Backmemed   File: Village.java   View Source Code Vote up 6 votes
public EntityPlayer getNearestTargetPlayer(EntityLivingBase villageDefender)
{
    double d0 = Double.MAX_VALUE;
    EntityPlayer entityplayer = null;

    for (String s : this.playerReputation.keySet())
    {
        if (this.isPlayerReputationTooLow(s))
        {
            EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(s);

            if (entityplayer1 != null)
            {
                double d1 = entityplayer1.getDistanceSqToEntity(villageDefender);

                if (d1 <= d0)
                {
                    entityplayer = entityplayer1;
                    d0 = d1;
                }
            }
        }
    }

    return entityplayer;
}
 
Example 6
Project: CustomWorldGen   File: Village.java   View Source Code Vote up 6 votes
public EntityPlayer getNearestTargetPlayer(EntityLivingBase villageDefender)
{
    double d0 = Double.MAX_VALUE;
    EntityPlayer entityplayer = null;

    for (String s : this.playerReputation.keySet())
    {
        if (this.isPlayerReputationTooLow(s))
        {
            EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(s);

            if (entityplayer1 != null)
            {
                double d1 = entityplayer1.getDistanceSqToEntity(villageDefender);

                if (d1 <= d0)
                {
                    entityplayer = entityplayer1;
                    d0 = d1;
                }
            }
        }
    }

    return entityplayer;
}
 
Example 7
Project: CustomWorldGen   File: EntityOcelot.java   View Source Code Vote up 5 votes
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
    if (this.isTamed())
    {
        if (this.isOwner(player) && !this.worldObj.isRemote && !this.isBreedingItem(stack))
        {
            this.aiSit.setSitting(!this.isSitting());
        }
    }
    else if ((this.aiTempt == null || this.aiTempt.isRunning()) && stack != null && stack.getItem() == Items.FISH && player.getDistanceSqToEntity(this) < 9.0D)
    {
        if (!player.capabilities.isCreativeMode)
        {
            --stack.stackSize;
        }

        if (!this.worldObj.isRemote)
        {
            if (this.rand.nextInt(3) == 0)
            {
                this.setTamed(true);
                this.setTameSkin(1 + this.worldObj.rand.nextInt(3));
                this.setOwnerId(player.getUniqueID());
                this.playTameEffect(true);
                this.aiSit.setSitting(true);
                this.worldObj.setEntityState(this, (byte)7);
            }
            else
            {
                this.playTameEffect(false);
                this.worldObj.setEntityState(this, (byte)6);
            }
        }

        return true;
    }

    return super.processInteract(player, hand, stack);
}
 
Example 8
Project: DecompiledMinecraft   File: EntityMinecartContainer.java   View Source Code Vote up 4 votes
/**
 * Do not make give this method the name canInteractWith because it clashes with Container
 */
public boolean isUseableByPlayer(EntityPlayer player)
{
    return this.isDead ? false : player.getDistanceSqToEntity(this) <= 64.0D;
}
 
Example 9
Project: DecompiledMinecraft   File: EntityOcelot.java   View Source Code Vote up 4 votes
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (this.isTamed())
    {
        if (this.isOwner(player) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
        {
            this.aiSit.setSitting(!this.isSitting());
        }
    }
    else if (this.aiTempt.isRunning() && itemstack != null && itemstack.getItem() == Items.fish && player.getDistanceSqToEntity(this) < 9.0D)
    {
        if (!player.capabilities.isCreativeMode)
        {
            --itemstack.stackSize;
        }

        if (itemstack.stackSize <= 0)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
        }

        if (!this.worldObj.isRemote)
        {
            if (this.rand.nextInt(3) == 0)
            {
                this.setTamed(true);
                this.setTameSkin(1 + this.worldObj.rand.nextInt(3));
                this.setOwnerId(player.getUniqueID().toString());
                this.playTameEffect(true);
                this.aiSit.setSitting(true);
                this.worldObj.setEntityState(this, (byte)7);
            }
            else
            {
                this.playTameEffect(false);
                this.worldObj.setEntityState(this, (byte)6);
            }
        }

        return true;
    }

    return super.interact(player);
}
 
Example 10
Project: DecompiledMinecraft   File: EntityMinecartContainer.java   View Source Code Vote up 4 votes
/**
 * Do not make give this method the name canInteractWith because it clashes with Container
 */
public boolean isUseableByPlayer(EntityPlayer player)
{
    return this.isDead ? false : player.getDistanceSqToEntity(this) <= 64.0D;
}
 
Example 11
Project: DecompiledMinecraft   File: EntityOcelot.java   View Source Code Vote up 4 votes
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (this.isTamed())
    {
        if (this.isOwner(player) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
        {
            this.aiSit.setSitting(!this.isSitting());
        }
    }
    else if (this.aiTempt.isRunning() && itemstack != null && itemstack.getItem() == Items.fish && player.getDistanceSqToEntity(this) < 9.0D)
    {
        if (!player.capabilities.isCreativeMode)
        {
            --itemstack.stackSize;
        }

        if (itemstack.stackSize <= 0)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
        }

        if (!this.worldObj.isRemote)
        {
            if (this.rand.nextInt(3) == 0)
            {
                this.setTamed(true);
                this.setTameSkin(1 + this.worldObj.rand.nextInt(3));
                this.setOwnerId(player.getUniqueID().toString());
                this.playTameEffect(true);
                this.aiSit.setSitting(true);
                this.worldObj.setEntityState(this, (byte)7);
            }
            else
            {
                this.playTameEffect(false);
                this.worldObj.setEntityState(this, (byte)6);
            }
        }

        return true;
    }

    return super.interact(player);
}
 
Example 12
Project: BaseClient   File: EntityMinecartContainer.java   View Source Code Vote up 4 votes
/**
 * Do not make give this method the name canInteractWith because it clashes with Container
 */
public boolean isUseableByPlayer(EntityPlayer player)
{
    return this.isDead ? false : player.getDistanceSqToEntity(this) <= 64.0D;
}
 
Example 13
Project: BaseClient   File: EntityOcelot.java   View Source Code Vote up 4 votes
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (this.isTamed())
    {
        if (this.isOwner(player) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
        {
            this.aiSit.setSitting(!this.isSitting());
        }
    }
    else if (this.aiTempt.isRunning() && itemstack != null && itemstack.getItem() == Items.fish && player.getDistanceSqToEntity(this) < 9.0D)
    {
        if (!player.capabilities.isCreativeMode)
        {
            --itemstack.stackSize;
        }

        if (itemstack.stackSize <= 0)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
        }

        if (!this.worldObj.isRemote)
        {
            if (this.rand.nextInt(3) == 0)
            {
                this.setTamed(true);
                this.setTameSkin(1 + this.worldObj.rand.nextInt(3));
                this.setOwnerId(player.getUniqueID().toString());
                this.playTameEffect(true);
                this.aiSit.setSitting(true);
                this.worldObj.setEntityState(this, (byte)7);
            }
            else
            {
                this.playTameEffect(false);
                this.worldObj.setEntityState(this, (byte)6);
            }
        }

        return true;
    }

    return super.interact(player);
}
 
Example 14
Project: BaseClient   File: EntityMinecartContainer.java   View Source Code Vote up 4 votes
/**
 * Do not make give this method the name canInteractWith because it clashes with Container
 */
public boolean isUseableByPlayer(EntityPlayer player)
{
    return this.isDead ? false : player.getDistanceSqToEntity(this) <= 64.0D;
}
 
Example 15
Project: BaseClient   File: EntityOcelot.java   View Source Code Vote up 4 votes
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (this.isTamed())
    {
        if (this.isOwner(player) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
        {
            this.aiSit.setSitting(!this.isSitting());
        }
    }
    else if (this.aiTempt.isRunning() && itemstack != null && itemstack.getItem() == Items.fish && player.getDistanceSqToEntity(this) < 9.0D)
    {
        if (!player.capabilities.isCreativeMode)
        {
            --itemstack.stackSize;
        }

        if (itemstack.stackSize <= 0)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
        }

        if (!this.worldObj.isRemote)
        {
            if (this.rand.nextInt(3) == 0)
            {
                this.setTamed(true);
                this.setTameSkin(1 + this.worldObj.rand.nextInt(3));
                this.setOwnerId(player.getUniqueID().toString());
                this.playTameEffect(true);
                this.aiSit.setSitting(true);
                this.worldObj.setEntityState(this, (byte)7);
            }
            else
            {
                this.playTameEffect(false);
                this.worldObj.setEntityState(this, (byte)6);
            }
        }

        return true;
    }

    return super.interact(player);
}
 
Example 16
Project: Backmemed   File: EntityMinecartContainer.java   View Source Code Vote up 4 votes
/**
 * Don't rename this method to canInteractWith due to conflicts with Container
 */
public boolean isUsableByPlayer(EntityPlayer player)
{
    return this.isDead ? false : player.getDistanceSqToEntity(this) <= 64.0D;
}
 
Example 17
Project: Backmemed   File: EntityOcelot.java   View Source Code Vote up 4 votes
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (this.isTamed())
    {
        if (this.isOwner(player) && !this.world.isRemote && !this.isBreedingItem(itemstack))
        {
            this.aiSit.setSitting(!this.isSitting());
        }
    }
    else if ((this.aiTempt == null || this.aiTempt.isRunning()) && itemstack.getItem() == Items.FISH && player.getDistanceSqToEntity(this) < 9.0D)
    {
        if (!player.capabilities.isCreativeMode)
        {
            itemstack.func_190918_g(1);
        }

        if (!this.world.isRemote)
        {
            if (this.rand.nextInt(3) == 0)
            {
                this.setTamed(true);
                this.setTameSkin(1 + this.world.rand.nextInt(3));
                this.setOwnerId(player.getUniqueID());
                this.playTameEffect(true);
                this.aiSit.setSitting(true);
                this.world.setEntityState(this, (byte)7);
            }
            else
            {
                this.playTameEffect(false);
                this.world.setEntityState(this, (byte)6);
            }
        }

        return true;
    }

    return super.processInteract(player, hand);
}
 
Example 18
Project: CustomWorldGen   File: EntityMinecartContainer.java   View Source Code Vote up 4 votes
/**
 * Don't rename this method to canInteractWith due to conflicts with Container
 */
public boolean isUseableByPlayer(EntityPlayer player)
{
    return this.isDead ? false : player.getDistanceSqToEntity(this) <= 64.0D;
}