@Override
  public boolean isInside(BlockRegion block) {
    Vector point = new Vector(block.getX(), block.getY(), block.getZ());
    if (point.getY() >= origin.getY() && point.getY() <= origin.getY() + height) {
      return Math.pow(point.getX() - origin.getX(), 2.0D)
              + Math.pow(point.getZ() - origin.getZ(), 2.0D)
          < (radius * radius);
    }

    return false;

    /*
    if(infinite) {
    	return matchesXZ(block);
    }

    BlockRegion check = new BlockRegion(block.getStringX(), values.get(0).getStringY(), block.getStringZ());
    double max = check.getDoubleY() + height;

    for(BlockRegion region : getValues()) {
    	if(region.isInside(check) && block.getDoubleY() <= max) {
    		return true;
    	}
    }

    return false;
    */
  }
Example #2
0
 @Override
 public boolean isInside(BlockRegion block) {
   Vector point = new Vector(block.getX(), block.getY(), block.getZ());
   return Math.pow(point.getX() - origin.getX(), 2.0D)
           + Math.pow(point.getZ() - origin.getZ(), 2.0D)
       < (radius * radius);
 }
  public boolean isBelow(BlockRegion region) {
    if (infinite || !matchesXZ(region)) {
      return false;
    }

    CuboidRegion cube =
        new CuboidRegion(
            region, new BlockRegion(region.getX(), region.getY() + height, region.getZ()));
    return cube.isBelow(region);
  }
  @Override
  public BlockRegion getRandom() {
    int minX = min.getBlockX(), maxX = max.getBlockX();
    int minY = min.getBlockY(), maxY = max.getBlockY();
    int minZ = min.getBlockZ(), maxZ = max.getBlockZ();

    int x = OtherUtil.getRandom(minX, maxX);
    int y = OtherUtil.getRandom(minY, maxY);
    int z = OtherUtil.getRandom(minZ, maxZ);
    return new BlockRegion(null, x, y, z);
  }
 public boolean matchesXZ(BlockRegion region) {
   BlockRegion block = new BlockRegion(region.getX(), center.getY(), region.getZ());
   CylinderRegion cyl = new CylinderRegion(center, radius, 1, hollow);
   return cyl.isInside(block);
 }
  public CylinderRegion(
      String name, BlockRegion center, double radius, double height, boolean hollow) {
    super(name);
    this.values = new ArrayList<>();
    if (!(center.isXInfinite() || center.isYInfinite() || center.isZInfinite())) {
      this.values = RegionUtil.cylinder(center, radius, height, hollow, false);
    } else if (center.isYInfinite() && !(center.isXInfinite() || center.isZInfinite())) {
      this.values =
          RegionUtil.cylinder(
              new BlockRegion(center.getX() + "", "@", center.getZ() + ""),
              radius,
              1,
              hollow,
              false);
      this.infinite = true;
    }

    this.center = center;
    this.origin = new Vector(center.getX(), center.getY(), center.getZ());

    this.radius = radius;
    this.height = height;
    this.hollow = hollow;
  }
Example #7
0
 @Override
 public double distance(BlockRegion block) {
   BlockRegion center =
       new BlockRegion(this.center.getStringX(), block.getStringY(), this.center.getStringZ());
   return center.distance(block) - radius;
 }
  @Override
  public boolean isInside(BlockRegion region) {
    int minX = min.getBlockX(), maxX = max.getBlockX();
    int minY = min.getBlockY(), maxY = max.getBlockY();
    int minZ = min.getBlockZ(), maxZ = max.getBlockZ();

    boolean x = minX <= region.getBlockX() && region.getBlockX() <= maxX;
    boolean y = minY <= region.getBlockY() && region.getBlockY() <= maxY;
    boolean z = minZ <= region.getBlockZ() && region.getBlockZ() <= maxZ;
    return x && y && z;
  }
  private void update(BlockRegion a, BlockRegion b) {
    int minX = a.getBlockX(), maxX = a.getBlockX();
    int minY = a.getBlockY(), maxY = a.getBlockY();
    int minZ = a.getBlockZ(), maxZ = a.getBlockZ();

    if (b.getBlockX() > maxX) {
      maxX = b.getBlockX();
    } else {
      minX = b.getBlockX();
    }

    if (b.getBlockY() > maxY) {
      maxY = b.getBlockY();
    } else {
      minY = b.getBlockY();
    }

    if (b.getBlockZ() > maxZ) {
      maxZ = b.getBlockZ();
    } else {
      minZ = b.getBlockZ();
    }

    this.min = new BlockRegion(null, minX, minY, minZ);
    maxX--;
    maxY--;
    maxZ--;
    this.max = new BlockRegion(null, maxX, maxY, maxZ);
  }
Example #10
0
 public CircleRegion(String name, BlockRegion centre, double radius, boolean hollow) {
   super(
       name, new BlockRegion(centre.getStringX(), "-oo", centre.getStringZ()), radius, 1, hollow);
 }