Program: 774
Project: 774
Buggy source:
/** 
 * Tries to find a suitable spawning point based on   {@link SurfaceHeightFacet} and {@link SeaLevelFacet}.
 * @param searchRadius the radius within a suitable spawning point will be searched
 * @param world the facet-based world
 * @param pos the desired 2D position in that world
 * @return a 3D position above the surface and sea level or <code>null</code> if none was found
 * @throws IllegalStateException if no SurfaceHeightFacet can be created.
 */
protected Vector3f findSpawnPosition(World world,Vector2i pos,int searchRadius){
  Vector3i ext=new Vector3i(searchRadius,1,searchRadius);
  Vector3i desiredPos=new Vector3i(pos.getX(),1,pos.getY());
  Region3i spawnArea=Region3i.createFromCenterExtents(desiredPos,ext);
  Region worldRegion=world.getWorldData(spawnArea);
  SurfaceHeightFacet surfaceHeightFacet=worldRegion.getFacet(SurfaceHeightFacet.class);
  if (surfaceHeightFacet == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  SeaLevelFacet seaLevelFacet=worldRegion.getFacet(SeaLevelFacet.class);
  int seaLevel=(seaLevelFacet != null) ? seaLevelFacet.getSeaLevel() : 0;
  int spiralRad=searchRadius / 2 - 1;
  SpiralIterable spiral=SpiralIterable.clockwise(pos).maxRadius(spiralRad).scale(2).build();
  for (  BaseVector2i test : spiral) {
    float val=surfaceHeightFacet.getWorld(test.getX(),test.getY());
    int height=TeraMath.floorToInt(val);
    if (height > seaLevel) {
      return new Vector3f(test.getX(),height,test.getY());
    }
  }
  float y=surfaceHeightFacet.get(pos.getX(),pos.getY());
  return new Vector3f(pos.getX(),y,pos.getY());
}

Fixed version (ground truth):
/** 
 * Tries to find a suitable spawning point based on   {@link SurfaceHeightFacet} and {@link SeaLevelFacet}.
 * @param searchRadius the radius within a suitable spawning point will be searched
 * @param world the facet-based world
 * @param pos the desired 2D position in that world
 * @return a 3D position above the surface and sea level or <code>null</code> if none was found
 * @throws IllegalStateException if no SurfaceHeightFacet can be created.
 */
protected Vector3f findSpawnPosition(World world,Vector2i pos,int searchRadius){
  Vector3i ext=new Vector3i(searchRadius,1,searchRadius);
  Vector3i desiredPos=new Vector3i(pos.getX(),1,pos.getY());
  Region3i spawnArea=Region3i.createFromCenterExtents(desiredPos,ext);
  Region worldRegion=world.getWorldData(spawnArea);
  SurfaceHeightFacet surfaceHeightFacet=worldRegion.getFacet(SurfaceHeightFacet.class);
  if (surfaceHeightFacet == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  SeaLevelFacet seaLevelFacet=worldRegion.getFacet(SeaLevelFacet.class);
  int seaLevel=(seaLevelFacet != null) ? seaLevelFacet.getSeaLevel() : 0;
  int spiralRad=searchRadius / 2 - 1;
  SpiralIterable spiral=SpiralIterable.clockwise(pos).maxRadius(spiralRad).scale(2).build();
  for (  BaseVector2i test : spiral) {
    float val=surfaceHeightFacet.getWorld(test.getX(),test.getY());
    int height=TeraMath.floorToInt(val);
    if (height >= seaLevel) {
      return new Vector3f(test.getX(),height,test.getY());
    }
  }
  float y=surfaceHeightFacet.getWorld(pos.getX(),pos.getY());
  return new Vector3f(pos.getX(),y,pos.getY());
}