  
          if (var4 < 0)
          {
-@@ -1062,8 +1169,8 @@
+             var4 = 0;
+         }
++        else if (var4 >= this.entityLists.length) //BugFix: Collision above the world
++        {
++            var4 = this.entityLists.length - 1;
++        }
+ 
+         if (var5 >= this.entityLists.length)
+         {
+             var5 = this.entityLists.length - 1;
++        }
++        else if (var5 < 0) //BugFix: Collision below the world
++        {
++            var5 = 0;
+         }
+ 
+         for (int var6 = var4; var6 <= var5; ++var6)
+@@ -1062,8 +1177,8 @@
       */
      public void getEntitiesOfTypeWithinAAAB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector)
      {

         int var5 = 0;
         boolean var6 = !this.worldObj.provider.hasNoSky;
         int var7;
@@ -1346,12 +1462,26 @@
         }
 
         this.generateHeightMap();

     }
 
     /**
@@ -1014,17 +1121,25 @@
      */
     public void getEntitiesWithinAABBForEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, List par3List)
     {
