本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getDistanceSq方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getDistanceSq方法的具体用法?Java EntityLivingBase.getDistanceSq怎么用?Java EntityLivingBase.getDistanceSq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getDistanceSq方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTask
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Updates the task
*/
public void updateTask()
{
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
--this.delayCounter;
if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
{
this.targetX = entitylivingbase.posX;
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
this.targetZ = entitylivingbase.posZ;
this.delayCounter = 4 + this.attacker.getRNG().nextInt(7);
if (d0 > 1024.0D)
{
this.delayCounter += 10;
}
else if (d0 > 256.0D)
{
this.delayCounter += 5;
}
if (!this.attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
{
this.delayCounter += 15;
}
}
this.attackTick = Math.max(this.attackTick - 1, 0);
this.checkAndPerformAttack(entitylivingbase, d0);
}
示例2: updateTask
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Updates the task
*/
public void updateTask()
{
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
double d1 = this.func_179512_a(entitylivingbase);
--this.delayCounter;
if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
{
this.targetX = entitylivingbase.posX;
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
this.targetZ = entitylivingbase.posZ;
this.delayCounter = 4 + this.attacker.getRNG().nextInt(7);
if (d0 > 1024.0D)
{
this.delayCounter += 10;
}
else if (d0 > 256.0D)
{
this.delayCounter += 5;
}
if (!this.attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
{
this.delayCounter += 15;
}
}
this.attackTick = Math.max(this.attackTick - 1, 0);
if (d0 <= d1 && this.attackTick <= 0)
{
this.attackTick = 20;
if (this.attacker.getHeldItem() != null)
{
this.attacker.swingItem();
}
this.attacker.attackEntityAsMob(entitylivingbase);
}
}
示例3: updateTask
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Updates the task
*/
public void updateTask()
{
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
--this.delayCounter;
if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && this.delayCounter <= 0 && (this.targetX == 0.0D && this.targetY == 0.0D && this.targetZ == 0.0D || entitylivingbase.getDistanceSq(this.targetX, this.targetY, this.targetZ) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F))
{
this.targetX = entitylivingbase.posX;
this.targetY = entitylivingbase.getEntityBoundingBox().minY;
this.targetZ = entitylivingbase.posZ;
this.delayCounter = 4 + this.attacker.getRNG().nextInt(7);
if (this.canPenalize)
{
this.delayCounter += failedPathFindingPenalty;
if (this.attacker.getNavigator().getPath() != null)
{
net.minecraft.pathfinding.PathPoint finalPathPoint = this.attacker.getNavigator().getPath().getFinalPathPoint();
if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.xCoord, finalPathPoint.yCoord, finalPathPoint.zCoord) < 1)
failedPathFindingPenalty = 0;
else
failedPathFindingPenalty += 10;
}
else
{
failedPathFindingPenalty += 10;
}
}
if (d0 > 1024.0D)
{
this.delayCounter += 10;
}
else if (d0 > 256.0D)
{
this.delayCounter += 5;
}
if (!this.attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget))
{
this.delayCounter += 15;
}
}
this.attackTick = Math.max(this.attackTick - 1, 0);
this.checkAndPerformAttack(entitylivingbase, d0);
}
示例4: compare
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public int compare(EntityLivingBase arg0, EntityLivingBase arg1) {
double d1 = arg0.getDistanceSq(base);
double d2 = arg1.getDistanceSq(base);
return (d1 < d2) ? -1 : (d1 > d2) ? 1 : 0;
}