package hmggirlfront.entity;

import java.util.List;

import gvclib.item.ItemMagazine;
import hmggirlfront.mod_GirlFront;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.SoundEvents;

public class DollAI_ItemCatch {
	public static void load(EntityDoll doll) {
		{
			List llist = doll.world.getEntitiesWithinAABB(EntityItem.class, doll.getEntityBoundingBox()
	        		.expand(doll.motionX, doll.motionY, doll.motionZ).grow(3.0D));
			if (llist != null) {
				for (int lj = 0; lj < llist.size(); lj++) {
					EntityItem entity1 = (EntityItem) llist.get(lj);
					if (entity1 != null) {
						
						if (entity1.getItem().getItem() == mod_GirlFront.idoll_food && !entity1.getItem().isEmpty()) {
							if (!doll.world.isRemote) {
							doll.setRemain_A(doll.getRemain_A() + entity1.getItem().getCount());
							doll.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 1.0F);
								entity1.setDead();
							}
							break;
						}else 
						if (entity1.getItem().getItem() == doll.bullet_type && !entity1.getItem().isEmpty()) {
							if (!doll.world.isRemote) {
							doll.setRemain_S(doll.getRemain_S() + 1 * entity1.getItem().getCount());
							doll.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 1.0F);
								entity1.setDead();
							}
							break;
						}else 
						if (entity1.getItem().getItem() instanceof ItemMagazine && !entity1.getItem().isEmpty()) {
							ItemMagazine mag = (ItemMagazine) entity1.getItem().getItem();
							if(mag.magazine_tab.equals(doll.bullet_type_tab)) {
								if (!doll.world.isRemote) {
									doll.setRemain_S(doll.getRemain_S() + 1 * entity1.getItem().getCount());
									doll.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 1.0F);
										entity1.setDead();
									}
									break;
							}
						}
					}
				}
			}
		}
	}
	
	public static void load(EntityDoll_Dummy doll) {
		{
			List llist = doll.world.getEntitiesWithinAABB(EntityItem.class, doll.getEntityBoundingBox()
	        		.expand(doll.motionX, doll.motionY, doll.motionZ).grow(3.0D));
			if (llist != null) {
				for (int lj = 0; lj < llist.size(); lj++) {
					EntityItem entity1 = (EntityItem) llist.get(lj);
					if (entity1 != null) {
						
						if (entity1.getItem().getItem() == mod_GirlFront.idoll_food && !entity1.getItem().isEmpty()) {
							if (!doll.world.isRemote) {
							doll.setRemain_A(doll.getRemain_A() + entity1.getItem().getCount());
							doll.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 1.0F);
								entity1.setDead();
							}
							break;
						}else 
						if (entity1.getItem().getItem() == doll.bullet_type && !entity1.getItem().isEmpty()) {
							if (!doll.world.isRemote) {
							doll.setRemain_S(doll.getRemain_S() + 1 * entity1.getItem().getCount());
							doll.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 1.0F);
								entity1.setDead();
							}
							break;
						}else 
						if (entity1.getItem().getItem() instanceof ItemMagazine && !entity1.getItem().isEmpty()) {
							ItemMagazine mag = (ItemMagazine) entity1.getItem().getItem();
							if(mag.magazine_tab.equals(doll.bullet_type_tab)) {
								if (!doll.world.isRemote) {
									doll.setRemain_S(doll.getRemain_S() + 1 * entity1.getItem().getCount());
									doll.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 1.0F);
										entity1.setDead();
									}
									break;
							}
						}
					}
				}
			}
		}
	}
}
