package hmggirlfront.entity;

import java.util.List;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;

public class DollAI_AutoSkill {
	public static void load(EntityDoll doll) {
		
		if(doll.getPledge() != 0){
			{
				List llist = doll.world.getEntitiesWithinAABB(EntityLivingBase.class,
						doll.getEntityBoundingBox().grow(20.0D));
				if (llist != null) {
					for (int lj = 0; lj < llist.size(); lj++) {
						Entity entity1 = (Entity) llist.get(lj);
						if (entity1.canBeCollidedWith() && entity1 != null) {
							if (entity1 instanceof EntityLivingBase) {
								EntityLivingBase living = (EntityLivingBase) entity1;
								if (living instanceof EntityPlayer || living == doll) {
									//if(living.isPotionActive(Potion.getPotionById(17)))
									if (doll.gun_class == 0) {
										if (!living.isPotionActive(MobEffects.ABSORPTION))
											living.addPotionEffect(
													new PotionEffect(MobEffects.ABSORPTION, 100, 1, false, false));
										if (!living.isPotionActive(MobEffects.JUMP_BOOST))
											living.addPotionEffect(
													new PotionEffect(MobEffects.JUMP_BOOST, 100, 1, false, false));
										if (!living.isPotionActive(MobEffects.SPEED))
											living.addPotionEffect(
													new PotionEffect(MobEffects.SPEED, 100, 3, false, false));
									}
									if (doll.gun_class == 1) {
										if (!living.isPotionActive(MobEffects.ABSORPTION))
											living.addPotionEffect(
													new PotionEffect(MobEffects.ABSORPTION, 100, 3, false, false));
										if (!living.isPotionActive(MobEffects.SPEED))
											living.addPotionEffect(
													new PotionEffect(MobEffects.SPEED, 100, 1, false, false));
									}
									if (doll.gun_class == 2) {
										if (!living.isPotionActive(MobEffects.ABSORPTION))
											living.addPotionEffect(
													new PotionEffect(MobEffects.ABSORPTION, 100, 1, false, false));
										if (!living.isPotionActive(MobEffects.STRENGTH))
											living.addPotionEffect(
													new PotionEffect(MobEffects.STRENGTH, 100, 1, false, false));
										if (!living.isPotionActive(MobEffects.REGENERATION))
											living.addPotionEffect(
													new PotionEffect(MobEffects.REGENERATION, 100, 1, false, false));
									}
									if (doll.gun_class == 3) {
										if (!living.isPotionActive(MobEffects.ABSORPTION))
											living.addPotionEffect(
													new PotionEffect(MobEffects.ABSORPTION, 100, 1, false, false));
										if (!living.isPotionActive(MobEffects.STRENGTH))
											living.addPotionEffect(
													new PotionEffect(MobEffects.STRENGTH, 100, 40, false, false));
										if (!living.isPotionActive(MobEffects.INVISIBILITY))
											living.addPotionEffect(
													new PotionEffect(MobEffects.INVISIBILITY, 100, 1, false, false));
									}
									if (doll.gun_class == 4) {
										if (!living.isPotionActive(MobEffects.STRENGTH))
											living.addPotionEffect(
													new PotionEffect(MobEffects.STRENGTH, 100, 2, false, false));
										if (!living.isPotionActive(MobEffects.ABSORPTION))
											living.addPotionEffect(
													new PotionEffect(MobEffects.ABSORPTION, 100, 3, false, false));
									}
									if (doll.gun_class == 5) {
										if (!living.isPotionActive(MobEffects.ABSORPTION))
											living.addPotionEffect(
													new PotionEffect(MobEffects.ABSORPTION, 100, 1, false, false));
										if (!living.isPotionActive(MobEffects.RESISTANCE))
											living.addPotionEffect(
													new PotionEffect(MobEffects.RESISTANCE, 100, 40, false, false));
									}
									if (doll.gun_class == 6) {
										if (!living.isPotionActive(MobEffects.ABSORPTION))
											living.addPotionEffect(
													new PotionEffect(MobEffects.ABSORPTION, 100, 1, false, false));
										if (!living.isPotionActive(MobEffects.STRENGTH))
											living.addPotionEffect(
													new PotionEffect(MobEffects.STRENGTH, 100, 40, false, false));
										if (!living.isPotionActive(MobEffects.FIRE_RESISTANCE))
											living.addPotionEffect(
													new PotionEffect(MobEffects.FIRE_RESISTANCE, 100, 1, false, false));
									}
								}
							}
						}
					}
				}
			}
		}
		
		if(doll.doll_autoskill != 0){
			/*
			{
				List llist = doll.world.getEntitiesWithinAABBExcludingEntity(doll,
						doll.getEntityBoundingBox().grow(20.0D));
				if (llist != null) {
					for (int lj = 0; lj < llist.size(); lj++) {
						Entity entity1 = (Entity) llist.get(lj);
						if (entity1.canBeCollidedWith() && entity1 != null) {
							if (entity1 instanceof EntityLivingBase) {
								EntityLivingBase living = (EntityLivingBase) entity1;
								if (living instanceof EntityPlayer || living instanceof EntityDoll) {
									if(doll.doll_autoskill == 1){
										if(living.isPotionActive(MobEffects.HEALTH_BOOST))
										living.addPotionEffect(new PotionEffect(MobEffects.HEALTH_BOOST, 40, 1, false, false));//時間/レベル/パーテクル/右上
									}
									if(doll.doll_autoskill == 2){
										if(living.isPotionActive(MobEffects.FIRE_RESISTANCE))
										living.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 40, 1, false, false));
									}
									if(doll.doll_autoskill == 3){
										if(living.isPotionActive(MobEffects.STRENGTH))
										living.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 40, 1, false, false));
									}
								}
							}
						}
					}
				}
			}
			*/
    	}
	}
	
}
