/** Updates the task */ @Override public void updateTask() { double d = 25D; // 5 blocks away double d1 = entityHost.getDistanceSq( attackTarget.posX, attackTarget.boundingBox.minY, attackTarget.posZ); boolean flag = entityHost.getEntitySenses().canSee(attackTarget); if (flag) { stuckTime++; } else { stuckTime = 0; } if (d1 > d || stuckTime < 20) { entityHost.getNavigator().tryMoveToEntityLiving(attackTarget, moveSpeed); } else { entityHost.getNavigator().clearPathEntity(); } entityHost.getLookHelper().setLookPositionWithEntity(attackTarget, 30F, 30F); rangedAttackTime = Math.max(rangedAttackTime - 1, 0); if (rangedAttackTime > 0) { return; } if (d1 > d || !flag) { return; } else { doRangedAttack(); rangedAttackTime = maxRangedAttackTime; return; } }
@Override public void updateTask() { EntityLivingBase entitylivingbase = attacker.getAttackTarget(); attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F); if ((longMemory && attacker.getHealth() <= 150 || attacker.getEntitySenses().canSee(entitylivingbase)) && --findAttemptCount <= 0 && attacker.getHealth() <= 150) { findAttemptCount = failedPathFindingPenalty + 4 + attacker.getRNG().nextInt(7); attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, speedTowardsTarget); if (attacker.getNavigator().getPath() != null) { PathPoint finalPathPoint = attacker.getNavigator().getPath().getFinalPathPoint(); if (finalPathPoint != null && entitylivingbase.getDistanceSq( finalPathPoint.xCoord, finalPathPoint.yCoord, finalPathPoint.zCoord) < 1D) failedPathFindingPenalty = 0; else failedPathFindingPenalty += 10; } else failedPathFindingPenalty += 10; } attackTick = Math.max(attackTick - 1, 0); double d0 = attacker.width * 1F * attacker.width * 1F + entitylivingbase.width; if (attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) <= d0) if (attackTick <= 0) { attackTick = 10; attacker.attackEntityAsMob(entitylivingbase); entitylivingbase.attackEntityFrom(DamageSource.causeMobDamage(attacker), 4.0F); entitylivingbase.addVelocity( -MathHelper.sin(attacker.rotationYaw * 3.141593F / 180.0F) * 0.5F, 0.1D, MathHelper.cos(attacker.rotationYaw * 3.141593F / 180.0F) * 0.5F); } if (attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) > d0 + 1D && attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) < d0 + 256.0D && attacker.getHealth() < 150) if (attackTick <= 0) { ++shouldDo; if (shouldDo == 1) attackTick = 40; else if (shouldDo <= 2) attackTick = 20; else { attackTick = 20; shouldDo = 0; } if (shouldDo == 1) { Vec3 look = attacker.getLookVec(); double direction = Math.toRadians(attacker.renderYawOffset); EntityPoisonJet jet = new EntityPoisonJet(worldObj, attacker); jet.setPosition( attacker.posX + -Math.sin(direction) * 3.5D, attacker.posY + attacker.height * 0.5, attacker.posZ + Math.cos(direction) * 3.5D); jet.motionX = look.xCoord * 1.0; jet.motionY = look.yCoord * 2.2; jet.motionZ = look.zCoord * 1.0; worldObj.spawnEntityInWorld(jet); } } if (attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) > d0 + 9D && attacker.getDistanceSq( entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ) < d0 + 256.0D && attacker.getHealth() > 150) { if (attackTick <= 0) { ++shouldDo; if (shouldDo == 1) attackTick = 200; else if (shouldDo <= 2) attackTick = 20; else { attackTick = 40; shouldDo = 0; } if (shouldDo == 1) { Vec3 look = attacker.getLookVec(); double direction = Math.toRadians(attacker.renderYawOffset); EntityTarantulaEgg babyEgg = new EntityTarantulaEgg(worldObj, attacker); babyEgg.setPosition( attacker.posX + -Math.sin(direction) * 3.5D, attacker.posY + attacker.height, attacker.posZ + Math.cos(direction) * 3.5D); babyEgg.motionX = look.xCoord * 1.0; babyEgg.motionY = look.yCoord * 2.2; babyEgg.motionZ = look.zCoord * 1.0; worldObj.spawnEntityInWorld(babyEgg); } if (worldObj.rand.nextInt(3) == 1) { attackTick = 30; attacker.motionY = 0.61999998688697815D; jumpAttack = true; } } if (jumpAttack && attacker.motionY == -0.0784000015258789D) { areaOfEffect(); ((EntityTarantulaMiniboss) attacker).spawnBlamParticles(); jumpAttack = false; } } }