net.minecraft.entity.IRangedAttackMob Java Examples

The following examples show how to use net.minecraft.entity.IRangedAttackMob. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityAIAttackMoveRanged.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: EntityAIRangedAttack.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
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);
}
 
Example #3
Source File: EntityAIMountedArrowAttack.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
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);
}
 
Example #4
Source File: EntityAIAttackMoveRanged.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * Execute a one shot task or start executing a continuous task
 */
public void startExecuting()
{
    super.startExecuting();
    ((IRangedAttackMob)this.entity).setSwingingArms(true);
}
 
Example #5
Source File: EntityAIAttackMoveRanged.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * 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;
            }

    }
}
 
Example #6
Source File: EntityAIRangedAttack.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public EntityAIRangedAttack(IRangedAttackMob host, double moveSpeed, int timeBetweenAttacks, float attackRange) {
  this(host, moveSpeed, timeBetweenAttacks, timeBetweenAttacks, attackRange);
}