// Path: src/main/java/crazypants/enderzoo/vec/Point3i.java
// public class Point3i {
// 
//   public int x;
//   public int y;
//   public int z;
//   
//   public Point3i() {
//     x = 0;
//     y = 0;
//     z = 0;
//   }
// 
//   public Point3i(int x, int y, int z) {  
//     this.x = x;
//     this.y = y;
//     this.z = z;
//   }
// 
//   public Point3i(Point3i other) {
//     x = other.x;
//     y = other.y;
//     z = other.z;
//   }
//   
//   public void set(int x, int y, int z) {
//     this.x= x;
//     this.y= y;
//     this.z= z;    
//   }
// 
//   @Override
//   public String toString() {
//     return "Point3i [x=" + x + ", y=" + y + ", z=" + z + "]";
//   }
// 
//   @Override
//   public int hashCode() {
//     final int prime = 31;
//     int result = 1;
//     result = prime * result + x;
//     result = prime * result + y;
//     result = prime * result + z;
//     return result;
//   }
// 
//   @Override
//   public boolean equals(Object obj) {
//     if (this == obj)
//       return true;
//     if (obj == null)
//       return false;
//     if (getClass() != obj.getClass())
//       return false;
//     Point3i other = (Point3i) obj;
//     if (x != other.x)
//       return false;
//     if (y != other.y)
//       return false;
//     if (z != other.z)
//       return false;
//     return true;
//   }
// 
//   
// 
//   
//   
//   
// }
// 
// Path: src/main/java/crazypants/enderzoo/vec/VecUtil.java
// public class VecUtil {
// 
// 	public static BlockPos bpos(double x, double y, double z) {
// 		return bpos((int)x, (int)y, (int)z);
// 	}
// 	
//   public static BlockPos bpos(int x, int y, int z) {
// 	 return new BlockPos(x, y, z); 
//   }
// 	
//   public static Vec3d scale(Vec3d vec, double scale) {
// 	  return new Vec3d(vec.x * scale, vec.y * scale, vec.z * scale);
//   }
// 
//   public static Vec3d copy(Vec3d vec) {
//     return new Vec3d(vec.x, vec.y, vec.z);
//   }
// 
//   public static Vec3d subtract(Vec3d a, Vec3d b) {    
//     return new Vec3d(a.x - b.x, a.y - b.y, a.z - b.z);
//   }
// 
//   public static Vec3d add(Vec3d a, Vec3d b) {    
//     return new Vec3d(a.x + b.x, a.y+ b.y, a.z+ b.z);
//   }
// 
// }


import java.util.List;
import crazypants.enderzoo.vec.Point3i;
import crazypants.enderzoo.vec.VecUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
package crazypants.enderzoo.entity;



public class SpawnUtil {

  public static boolean findClearGround(World world, Point3i startingLocation, Point3i clearLocation) {
    return findClearGround(world, startingLocation, clearLocation, 2, 10, false);
  }
  
  public static boolean findClearGround(World world, Point3i startingLocation, Point3i clearLocation, int horizRange, int vertRange,
      boolean checkForLivingEntities) {
    //first find some air in the y
    boolean foundTargetSpace = false;
    for (int xOff = -horizRange; xOff <= horizRange && !foundTargetSpace; xOff++) {
      clearLocation.x = startingLocation.x + xOff;
      for (int zOff = -horizRange; zOff <= horizRange && !foundTargetSpace; zOff++) {
        clearLocation.z = startingLocation.z + zOff;
        foundTargetSpace = SpawnUtil.seachYForClearGround(clearLocation, world, vertRange, checkForLivingEntities);
        if(!foundTargetSpace) {
          clearLocation.y = startingLocation.y;
        }
      }
    }
    return foundTargetSpace;
  }
  
  public static boolean seachYForClearGround(Point3i target, World world) {
    return seachYForClearGround(target, world, 10, false);
  }
  
  public static boolean seachYForClearGround(Point3i target, World world, int searchRange, boolean checkForLivingEntities) {
    boolean foundY = false;
    for (int i = 0; i < searchRange && !foundY; i++) {
// Path: src/main/java/crazypants/enderzoo/vec/Point3i.java
// public class Point3i {
// 
//   public int x;
//   public int y;
//   public int z;
//   
//   public Point3i() {
//     x = 0;
//     y = 0;
//     z = 0;
//   }
// 
//   public Point3i(int x, int y, int z) {  
//     this.x = x;
//     this.y = y;
//     this.z = z;
//   }
// 
//   public Point3i(Point3i other) {
//     x = other.x;
//     y = other.y;
//     z = other.z;
//   }
//   
//   public void set(int x, int y, int z) {
//     this.x= x;
//     this.y= y;
//     this.z= z;    
//   }
// 
//   @Override
//   public String toString() {
//     return "Point3i [x=" + x + ", y=" + y + ", z=" + z + "]";
//   }
// 
//   @Override
//   public int hashCode() {
//     final int prime = 31;
//     int result = 1;
//     result = prime * result + x;
//     result = prime * result + y;
//     result = prime * result + z;
//     return result;
//   }
// 
//   @Override
//   public boolean equals(Object obj) {
//     if (this == obj)
//       return true;
//     if (obj == null)
//       return false;
//     if (getClass() != obj.getClass())
//       return false;
//     Point3i other = (Point3i) obj;
//     if (x != other.x)
//       return false;
//     if (y != other.y)
//       return false;
//     if (z != other.z)
//       return false;
//     return true;
//   }
// 
//   
// 
//   
//   
//   
// }
// 
// Path: src/main/java/crazypants/enderzoo/vec/VecUtil.java
// public class VecUtil {
// 
// 	public static BlockPos bpos(double x, double y, double z) {
// 		return bpos((int)x, (int)y, (int)z);
// 	}
// 	
//   public static BlockPos bpos(int x, int y, int z) {
// 	 return new BlockPos(x, y, z); 
//   }
// 	
//   public static Vec3d scale(Vec3d vec, double scale) {
// 	  return new Vec3d(vec.x * scale, vec.y * scale, vec.z * scale);
//   }
// 
//   public static Vec3d copy(Vec3d vec) {
//     return new Vec3d(vec.x, vec.y, vec.z);
//   }
// 
//   public static Vec3d subtract(Vec3d a, Vec3d b) {    
//     return new Vec3d(a.x - b.x, a.y - b.y, a.z - b.z);
//   }
// 
//   public static Vec3d add(Vec3d a, Vec3d b) {    
//     return new Vec3d(a.x + b.x, a.y+ b.y, a.z+ b.z);
//   }
// 
// }


// Path: src/main/java/crazypants/enderzoo/entity/SpawnUtil.java
import java.util.List;
import crazypants.enderzoo.vec.Point3i;
import crazypants.enderzoo.vec.VecUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;

package crazypants.enderzoo.entity;



public class SpawnUtil {

  public static boolean findClearGround(World world, Point3i startingLocation, Point3i clearLocation) {
    return findClearGround(world, startingLocation, clearLocation, 2, 10, false);
  }
  
  public static boolean findClearGround(World world, Point3i startingLocation, Point3i clearLocation, int horizRange, int vertRange,
      boolean checkForLivingEntities) {
    //first find some air in the y
    boolean foundTargetSpace = false;
    for (int xOff = -horizRange; xOff <= horizRange && !foundTargetSpace; xOff++) {
      clearLocation.x = startingLocation.x + xOff;
      for (int zOff = -horizRange; zOff <= horizRange && !foundTargetSpace; zOff++) {
        clearLocation.z = startingLocation.z + zOff;
        foundTargetSpace = SpawnUtil.seachYForClearGround(clearLocation, world, vertRange, checkForLivingEntities);
        if(!foundTargetSpace) {
          clearLocation.y = startingLocation.y;
        }
      }
    }
    return foundTargetSpace;
  }
  
  public static boolean seachYForClearGround(Point3i target, World world) {
    return seachYForClearGround(target, world, 10, false);
  }
  
  public static boolean seachYForClearGround(Point3i target, World world, int searchRange, boolean checkForLivingEntities) {
    boolean foundY = false;
    for (int i = 0; i < searchRange && !foundY; i++) {
      if(world.isAirBlock(VecUtil.bpos(target.x, target.y, target.z))) {