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


Java EntityLivingBase.getDistanceSq方法代码示例

本文整理汇总了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);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:36,代码来源:EntityAIAttackMelee.java

示例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);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:48,代码来源:EntityAIAttackOnCollide.java

示例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);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:53,代码来源:EntityAIAttackMelee.java

示例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;
}
 
开发者ID:sblectric,项目名称:AdvancedCombat,代码行数:7,代码来源:EntityDistanceSorter.java


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