Here's some of my code, this one spawns my custom mob when i place a block. I don't know how to make a mob spawn in the way that cows or sheep do but there are plenty tutorials for that on youtube.
public int onBlockPlaced(World world, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
{
if (!world.isRemote){
EntityCitizen entitycitizen = new EntityCitizen(world);
entitycitizen.setPosition( par2 +2, par3, par4);
{
world.spawnEntityInWorld(entitycitizen);
}
}
return par9;
}