当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.getDistanceSqToEntity方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.getDistanceSqToEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.getDistanceSqToEntity方法的具体用法?Java EntityPlayer.getDistanceSqToEntity怎么用?Java EntityPlayer.getDistanceSqToEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.getDistanceSqToEntity方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNearestTargetPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:Village.java

示例2: processInteract

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:EntityOcelot.java

示例3: isUseableByPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:8,代码来源:EntityMinecartContainer.java

示例4: interact

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:50,代码来源:EntityOcelot.java

示例5: isUsableByPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:8,代码来源:EntityMinecartContainer.java

示例6: processInteract

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:42,代码来源:EntityOcelot.java

示例7: isUseableByPlayer

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:EntityMinecartContainer.java


注:本文中的net.minecraft.entity.player.EntityPlayer.getDistanceSqToEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。