package net.minecraft.entity.passive;

import java.util.ArrayList;

import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;

public class EntityMooshroom extends EntityCow implements IShearable
{
	private static final String __OBFID = "CL_00001645";

	public EntityMooshroom(World par1World)
	{
		super(par1World);
		this.setSize(0.9F, 1.3F);
	}

	public boolean interact(EntityPlayer par1EntityPlayer)
	{
		ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

		if (itemstack != null && itemstack.getItem() == Items.bowl && this.getGrowingAge() >= 0)
		{
			if (itemstack.stackSize == 1)
			{
				par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Items.mushroom_stew));
				return true;
			}

			if (par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.mushroom_stew)) && !par1EntityPlayer.capabilities.isCreativeMode)
			{
				par1EntityPlayer.inventory.decrStackSize(par1EntityPlayer.inventory.currentItem, 1);
				return true;
			}
		}

		{
			return super.interact(par1EntityPlayer);
		}
	}

	public EntityMooshroom createChild(EntityAgeable par1EntityAgeable)
	{
		return new EntityMooshroom(this.worldObj);
	}

	@Override
	public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z)
	{
		return getGrowingAge() >= 0;
	}

	@Override
	public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune)
	{
		setDead();
		EntityCow entitycow = new EntityCow(worldObj);
		entitycow.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
		entitycow.setHealth(this.getHealth());
		entitycow.renderYawOffset = renderYawOffset;
		worldObj.spawnEntityInWorld(entitycow);
		worldObj.spawnParticle("largeexplode", posX, posY + (double)(height / 2.0F), posZ, 0.0D, 0.0D, 0.0D);

		ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
		for (int i = 0; i < 5; i++)
		{
			ret.add(new ItemStack(Blocks.red_mushroom));
		}
		playSound("mob.sheep.shear", 1.0F, 1.0F);
		return ret;
	}
}