package hmggirlfront.items;

import java.util.List;

import javax.annotation.Nullable;

import hmggirlfront.mod_GirlFront;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;

public class ItemDrone_Random extends Item {
		
	public String text1 = null;
	public String text2 = null;
	public String text3 = null;
	
	    public ItemDrone_Random()
	    {
	    	super();
	    }

	    public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn)
		  {
	    	if(text1 != null) {
	    		TextComponentTranslation information = new TextComponentTranslation(text1, new Object[0]);
	    		tooltip.add(TextFormatting.WHITE + information.getFormattedText());//0
	    	}
	    	if(text2 != null) {
	    		TextComponentTranslation information = new TextComponentTranslation(text2, new Object[0]);
	    		tooltip.add(TextFormatting.WHITE + information.getFormattedText());//0
	    	}
	    	if(text3 != null) {
	    		TextComponentTranslation information = new TextComponentTranslation(text3, new Object[0]);
	    		tooltip.add(TextFormatting.WHITE + information.getFormattedText());//0
	    	}
	    	
		  }
	    
	    
	    public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) {
			super.onUpdate(itemstack, world, entity, i, flag);
			if(!itemstack.isEmpty() && entity != null && entity instanceof EntityPlayer) {
				EntityPlayer player = (EntityPlayer) entity;
				
				if(flag) {
					if(!world.isRemote) {
						Item drone = null;
						int ran = world.rand.nextInt(5);
						switch (ran) {
						case 1:
							drone = mod_GirlFront.drone_mortar;
							break;
						case 2:
							drone = mod_GirlFront.drone_airborne;
							break;
						case 3:
							drone = mod_GirlFront.drone_bomber;
							break;
						case 4:
							drone = mod_GirlFront.drone_decoy;
							break;
						default:
							drone = mod_GirlFront.drone_command;
							break;
						}
						if(drone != null)player.inventory.setInventorySlotContents(i, new ItemStack(drone));
					}
				}
				
				
			}
	    }
}
