Java源码示例:net.minecraft.entity.IRangedAttackMob

示例1
/**
 * Reset the task's internal state. Called when this task is interrupted by another one
 */
public void resetTask()
{
    super.resetTask();
    ((IRangedAttackMob)this.entity).setSwingingArms(false);
    this.seeTime = 0;
    this.setAttackTime(-1);
}
 
示例2
public EntityAIRangedAttack(IRangedAttackMob host, double moveSpeed, int minTimeBetweenAttacks, int maxTimeBetweenAttacks, float range) {
  timeUntilNextAttack = -1;

  rangedAttackEntityHost = host;
  entityHost = (EntityLiving) host;
  entityMoveSpeed = moveSpeed;
  minRangedAttackTime = minTimeBetweenAttacks;
  maxRangedAttackTime = maxTimeBetweenAttacks;
  attackRange = range;
  attackRangeSq = attackRange * attackRange;
  setMutexBits(3);
}
 
示例3
public EntityAIMountedArrowAttack(IRangedAttackMob host, double moveSpeed, double mountedEntityMoveSpeed, int minAttackTime, int maxAttackTime,
    float attackRange, boolean useRunAwayTactic) {
  timeUntilNextAttack = -1;
  rangedAttackEntityHost = host;
  entityHost = (EntityLiving) host;
  entityMoveSpeed = moveSpeed;
  this.mountedEntityMoveSpeed = mountedEntityMoveSpeed;
  minRangedAttackTime = minAttackTime;
  maxRangedAttackTime = maxAttackTime;
  this.attackRange = attackRange;
  attackRangeSq = attackRange * attackRange;
  this.useRunAwayTactic = useRunAwayTactic;
  setMutexBits(3);
}
 
示例4
/**
 * Execute a one shot task or start executing a continuous task
 */
public void startExecuting()
{
    super.startExecuting();
    ((IRangedAttackMob)this.entity).setSwingingArms(true);
}
 
示例5
/**
 * Keep ticking a continuous task that has already been started
 */
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.entity.getAttackTarget();

    if (entitylivingbase != null)
    {
        double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
        boolean flag = this.entity.getEntitySenses().canSee(entitylivingbase);
        boolean flag1 = this.seeTime > 0;

        if (flag != flag1)
        {
            this.seeTime = 0;
        }

        if (flag)
        {
            ++this.seeTime;
        }
        else
        {
            --this.seeTime;
        }

        if (d0 <= (double)this.maxAttackDistance)
        {
            this.entity.getNavigator().clearPath();
            ++this.strafingTime;
        }
        else
        {
            this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.moveSpeedAmp);
            this.strafingTime = -1;
        }

        if (this.strafingTime >= 20)
        {
            if ((double)this.entity.getRNG().nextFloat() < 0.3D)
            {
                this.strafingClockwise = !this.strafingClockwise;
            }

            if ((double)this.entity.getRNG().nextFloat() < 0.3D)
            {
                this.strafingBackwards = !this.strafingBackwards;
            }

            this.strafingTime = 0;
        }

        if (this.strafingTime > -1)
        {
            if (d0 > (double)(this.maxAttackDistance * 0.75F))
            {
                this.strafingBackwards = false;
            }
            else if (d0 < (double)(this.maxAttackDistance * 0.25F))
            {
                this.strafingBackwards = true;
            }

            this.entity.getMoveHelper().strafe(this.strafingBackwards ? -0.5F : 0.5F, this.strafingClockwise ? 0.5F : -0.5F);
            this.entity.faceEntity(entitylivingbase, 30.0F, 30.0F);
        }

        this.entity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);


            if (flag && this.seeTime > 60)
            {
                ((IRangedAttackMob)this.entity).attackEntityWithRangedAttack(entitylivingbase,0.6F);
                this.setAttackTime(this.attackCooldown);

                this.seeTime = 0;
            }

    }
}
 
示例6
public EntityAIRangedAttack(IRangedAttackMob host, double moveSpeed, int timeBetweenAttacks, float attackRange) {
  this(host, moveSpeed, timeBetweenAttacks, timeBetweenAttacks, attackRange);
}