001    package net.minecraft.entity.passive;
002    
003    import net.minecraft.block.Block;
004    import net.minecraft.entity.EntityAgeable;
005    import net.minecraft.entity.item.EntityItem;
006    import net.minecraft.entity.player.EntityPlayer;
007    import net.minecraft.item.Item;
008    import net.minecraft.item.ItemStack;
009    import net.minecraft.world.World;
010    
011    import java.util.ArrayList;
012    
013    import net.minecraftforge.common.IShearable;
014    
015    public class EntityMooshroom extends EntityCow implements IShearable
016    {
017        public EntityMooshroom(World par1World)
018        {
019            super(par1World);
020            this.texture = "/mob/redcow.png";
021            this.setSize(0.9F, 1.3F);
022        }
023    
024        /**
025         * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
026         */
027        public boolean interact(EntityPlayer par1EntityPlayer)
028        {
029            ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem();
030    
031            if (var2 != null && var2.itemID == Item.bowlEmpty.itemID && this.getGrowingAge() >= 0)
032            {
033                if (var2.stackSize == 1)
034                {
035                    par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Item.bowlSoup));
036                    return true;
037                }
038    
039                if (par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bowlSoup)) && !par1EntityPlayer.capabilities.isCreativeMode)
040                {
041                    par1EntityPlayer.inventory.decrStackSize(par1EntityPlayer.inventory.currentItem, 1);
042                    return true;
043                }
044            }
045    
046            return super.interact(par1EntityPlayer);
047        }
048    
049        /**
050         * This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
051         */
052        public EntityMooshroom spawnBabyAnimal(EntityAgeable par1EntityAgeable)
053        {
054            return new EntityMooshroom(this.worldObj);
055        }
056    
057        public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
058        {
059            return this.spawnBabyAnimal(par1EntityAgeable);
060        }
061    
062        @Override
063        public boolean isShearable(ItemStack item, World world, int X, int Y, int Z)
064        {
065            return getGrowingAge() >= 0;
066        }
067    
068        @Override
069        public ArrayList<ItemStack> onSheared(ItemStack item, World world, int X, int Y, int Z, int fortune)
070        {
071            setDead();
072            EntityCow entitycow = new EntityCow(worldObj);
073            entitycow.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
074            entitycow.setEntityHealth(getHealth());
075            entitycow.renderYawOffset = renderYawOffset;
076            worldObj.spawnEntityInWorld(entitycow);
077            worldObj.spawnParticle("largeexplode", posX, posY + (double)(height / 2.0F), posZ, 0.0D, 0.0D, 0.0D);
078    
079            ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
080            for (int x = 0; x < 5; x++)
081            {
082                ret.add(new ItemStack(Block.mushroomRed));
083            }
084            return ret;
085        }
086    }