001package net.minecraft.entity.passive; 002 003import net.minecraft.block.Block; 004import net.minecraft.entity.EntityAgeable; 005import net.minecraft.entity.item.EntityItem; 006import net.minecraft.entity.player.EntityPlayer; 007import net.minecraft.item.Item; 008import net.minecraft.item.ItemStack; 009import net.minecraft.world.World; 010 011import java.util.ArrayList; 012 013import net.minecraftforge.common.IShearable; 014 015public 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 itemstack = par1EntityPlayer.inventory.getCurrentItem(); 030 031 if (itemstack != null && itemstack.itemID == Item.bowlEmpty.itemID && this.getGrowingAge() >= 0) 032 { 033 if (itemstack.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 public EntityMooshroom func_94900_c(EntityAgeable par1EntityAgeable) 050 { 051 return new EntityMooshroom(this.worldObj); 052 } 053 054 /** 055 * This function is used when two same-species animals in 'love mode' breed to generate the new baby animal. 056 */ 057 public EntityCow spawnBabyAnimal(EntityAgeable par1EntityAgeable) 058 { 059 return this.func_94900_c(par1EntityAgeable); 060 } 061 062 public EntityAgeable createChild(EntityAgeable par1EntityAgeable) 063 { 064 return this.func_94900_c(par1EntityAgeable); 065 } 066 067 @Override 068 public boolean isShearable(ItemStack item, World world, int X, int Y, int Z) 069 { 070 return getGrowingAge() >= 0; 071 } 072 073 @Override 074 public ArrayList<ItemStack> onSheared(ItemStack item, World world, int X, int Y, int Z, int fortune) 075 { 076 setDead(); 077 EntityCow entitycow = new EntityCow(worldObj); 078 entitycow.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); 079 entitycow.setEntityHealth(getHealth()); 080 entitycow.renderYawOffset = renderYawOffset; 081 worldObj.spawnEntityInWorld(entitycow); 082 worldObj.spawnParticle("largeexplode", posX, posY + (double)(height / 2.0F), posZ, 0.0D, 0.0D, 0.0D); 083 084 ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); 085 for (int x = 0; x < 5; x++) 086 { 087 ret.add(new ItemStack(Block.mushroomRed)); 088 } 089 return ret; 090 } 091}