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