本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}