--- ../src-base/minecraft/net/minecraft/world/SpawnerAnimals.java
+++ ../src-work/minecraft/net/minecraft/world/SpawnerAnimals.java
@@ -17,6 +17,10 @@
 import net.minecraft.util.WeightedRandom;
 import net.minecraft.world.biome.BiomeGenBase;
 import net.minecraft.world.chunk.Chunk;
+import java.util.ArrayList;
+import java.util.Collections;
+import net.minecraftforge.fml.common.eventhandler.Event.Result;
+import net.minecraftforge.event.ForgeEventFactory;
 
 public final class SpawnerAnimals
 {
@@ -80,12 +84,15 @@
 
                 if ((!enumcreaturetype.func_75599_d() || p_77192_3_) && (enumcreaturetype.func_75599_d() || p_77192_2_) && (!enumcreaturetype.func_82705_e() || p_77192_4_))
                 {
-                    i1 = p_77192_1_.func_72907_a(enumcreaturetype.func_75598_a());
+                    i1 = p_77192_1_.countEntities(enumcreaturetype, true);
                     int i4 = enumcreaturetype.func_75601_b() * i / field_180268_a;
 
                     if (i1 <= i4)
                     {
                         Iterator iterator1 = this.field_77193_b.iterator();
+                        ArrayList<ChunkCoordIntPair> tmp = new ArrayList(field_77193_b);
+                        Collections.shuffle(tmp);
+                        iterator1 = tmp.iterator();
                         label115:
 
                         while (iterator1.hasNext())
@@ -153,8 +160,10 @@
 
                                                         entityliving.func_70012_b((double)f, (double)l2, (double)f1, p_77192_1_.field_73012_v.nextFloat() * 360.0F, 0.0F);
 
-                                                        if (entityliving.func_70601_bi() && entityliving.func_70058_J())
+                                                        Result canSpawn = ForgeEventFactory.canEntitySpawn(entityliving, p_77192_1_, f, l2, f1);
+                                                        if (canSpawn == Result.ALLOW || (canSpawn == Result.DEFAULT && (entityliving.func_70601_bi() && entityliving.func_70058_J())))
                                                         {
+                                                            if (!ForgeEventFactory.doSpecialSpawn(entityliving, p_77192_1_, f1, l2, f1))
                                                             ientitylivingdata = entityliving.func_180482_a(p_77192_1_.func_175649_E(new BlockPos(entityliving)), ientitylivingdata);
 
                                                             if (entityliving.func_70058_J())
@@ -163,7 +172,7 @@
                                                                 p_77192_1_.func_72838_d(entityliving);
                                                             }
 
-                                                            if (i2 >= entityliving.func_70641_bl())
+                                                            if (i2 >= ForgeEventFactory.getMaxSpawnPackSize(entityliving))
                                                             {
                                                                 continue label115;
                                                             }
@@ -228,6 +237,8 @@
                 {
                     Block block1 = p_180267_1_.func_180495_p(blockpos1).func_177230_c();
                     boolean flag = block1 != Blocks.field_150357_h && block1 != Blocks.field_180401_cv;
+                    BlockPos down = blockpos1.func_177977_b();
+                    flag |= p_180267_1_.func_180495_p(down).func_177230_c().canCreatureSpawn(p_180267_1_, down, p_180267_0_);
                     return flag && !block.func_149721_r() && !block.func_149688_o().func_76224_d() && !p_180267_1_.func_180495_p(p_180267_2_.func_177984_a()).func_177230_c().func_149721_r();
                 }
             }
