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 EntityMooshroom spawnBabyAnimal(EntityAgeable par1EntityAgeable) 045 { 046 return new EntityMooshroom(this.worldObj); 047 } 048 049 public EntityAgeable func_90011_a(EntityAgeable par1EntityAgeable) 050 { 051 return this.spawnBabyAnimal(par1EntityAgeable); 052 } 053 054 @Override 055 public boolean isShearable(ItemStack item, World world, int X, int Y, int Z) 056 { 057 return getGrowingAge() >= 0; 058 } 059 060 @Override 061 public ArrayList<ItemStack> onSheared(ItemStack item, World world, int X, int Y, int Z, int fortune) 062 { 063 setDead(); 064 EntityCow entitycow = new EntityCow(worldObj); 065 entitycow.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); 066 entitycow.setEntityHealth(getHealth()); 067 entitycow.renderYawOffset = renderYawOffset; 068 worldObj.spawnEntityInWorld(entitycow); 069 worldObj.spawnParticle("largeexplode", posX, posY + (double)(height / 2.0F), posZ, 0.0D, 0.0D, 0.0D); 070 071 ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); 072 for (int x = 0; x < 5; x++) 073 { 074 ret.add(new ItemStack(Block.mushroomRed)); 075 } 076 return ret; 077 } 078 }