nus-yam/ex-repair huggingface dataset:
Program: 1315
Project: 1315
Buggy source:
/** 
 * Generates the terrain within this chunk.
 */
public void generate(){
  clear();
  int xOffset=(int)_position.x * (int)CHUNK_DIMENSIONS.x;
  int yOffset=(int)_position.y * (int)CHUNK_DIMENSIONS.y;
  int zOffset=(int)_position.z * (int)CHUNK_DIMENSIONS.z;
  for (int x=0; x < Chunk.CHUNK_DIMENSIONS.x; x++) {
    for (int z=0; z < Chunk.CHUNK_DIMENSIONS.z; z++) {
      int height=(int)(calcTerrainElevation(x + xOffset,z + zOffset) + (calcTerrainRoughness(x + xOffset,z + zOffset) * calcTerrainDetail(x + xOffset,z + zOffset)) * 64) + 64;
      for (int i=(int)CHUNK_DIMENSIONS.y; i > 0; i--) {
        if (calcCaveDensityAt(x + xOffset,i,z + zOffset) < 0.5 && calcCanyonDensity(x + xOffset,i + yOffset,z + zOffset) < 0.5) {
          if (i == height) {
            if (i != 36) {
              setBlock(x,i,z,0x1);
            }
 else {
              setBlock(x,i,z,0x7);
            }
          }
 else           if (i < height) {
            if (i < height * 0.75f) {
              setBlock(x,i,z,0x3);
            }
 else {
              setBlock(x,i,z,0x2);
            }
            if (i <= 36 && i >= 32) {
              setBlock(x,i,z,0x7);
            }
          }
        }
        if (i <= 32) {
          if (getBlock(x,i,z) == 0) {
            setBlock(x,i,z,0x4);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void generate(){
  if (_fresh) {
    generateTerrain();
    populate();
    calcSunlight();
    _fresh=false;
  }
}
Program: 1316
Project: 1316
Buggy source:
/** 
 * Init. the textures used within chunks.
 */
public static void init(){
  try {
    _textureMap=TextureLoader.getTexture("String_Node_Str",new FileInputStream(Chunk.class.getResource("String_Node_Str").getPath()),GL_NEAREST);
    _textureMap.bind();
  }
 catch (  IOException ex) {
    Logger.getLogger(Chunk.class.getName()).log(Level.SEVERE,null,ex);
  }
}

Fixed version (ground truth):
/** 
 * Init. the textures used within chunks.
 */
public static void init(){
  try {
    _textureMap=TextureLoader.getTexture("String_Node_Str",new FileInputStream(Chunk.class.getResource("String_Node_Str").getPath()),GL_NEAREST);
  }
 catch (  IOException ex) {
    Logger.getLogger(Chunk.class.getName()).log(Level.SEVERE,null,ex);
  }
}
Program: 1317
Project: 1317
Buggy source:
/** 
 * Generates the display list from the precalculated arrays.
 */
public void generateDisplayList(){
  if (_chunkID == -1) {
    _chunkID=maxChunkID + 1;
    maxChunkID++;
    _displayList=glGenLists(1);
  }
  FloatBuffer cb=null;
  FloatBuffer tb=null;
  FloatBuffer vb=null;
  vb=BufferUtils.createFloatBuffer(_quads.size());
  for (  Float f : _quads) {
    vb.put(f);
  }
  tb=BufferUtils.createFloatBuffer(_tex.size());
  for (  Float f : _tex) {
    tb.put(f);
  }
  _tex.clear();
  cb=BufferUtils.createFloatBuffer(_color.size());
  for (  Float f : _color) {
    cb.put(f);
  }
  _color.clear();
  vb.flip();
  tb.flip();
  cb.flip();
  glNewList(_displayList,GL_COMPILE);
  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  glEnableClientState(GL_COLOR_ARRAY);
  glTexCoordPointer(2,0,tb);
  glColorPointer(3,0,cb);
  glVertexPointer(3,0,vb);
  glDrawArrays(GL_QUADS,0,_quads.size() / 3);
  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  glDisableClientState(GL_VERTEX_ARRAY);
  glEndList();
  _quads.clear();
  vb=null;
  tb=null;
  cb=null;
}

Fixed version (ground truth):
/** 
 * Generates the display list from the precalculated arrays.
 */
public synchronized void generateDisplayList(){
  if (_chunkID == -1) {
    _chunkID=maxChunkID + 1;
    maxChunkID++;
    _displayList=glGenLists(1);
  }
  FloatBuffer cb=null;
  FloatBuffer tb=null;
  FloatBuffer vb=null;
  vb=BufferUtils.createFloatBuffer(_quads.size());
  for (  Float f : _quads) {
    vb.put(f);
  }
  tb=BufferUtils.createFloatBuffer(_tex.size());
  for (  Float f : _tex) {
    tb.put(f);
  }
  cb=BufferUtils.createFloatBuffer(_color.size());
  for (  Float f : _color) {
    cb.put(f);
  }
  vb.flip();
  tb.flip();
  cb.flip();
  glNewList(_displayList,GL_COMPILE);
  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  glEnableClientState(GL_COLOR_ARRAY);
  glTexCoordPointer(2,0,tb);
  glColorPointer(3,0,cb);
  glVertexPointer(3,0,vb);
  glDrawArrays(GL_QUADS,0,_quads.size() / 3);
  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  glDisableClientState(GL_VERTEX_ARRAY);
  glEndList();
  vb=null;
  tb=null;
  cb=null;
}
Program: 1318
Project: 1318
Buggy source:
/** 
 * Init. the chunk.
 */
public Chunk(World p,Vector3f position){
  this._position=position;
  _parent=p;
  clear();
  generate();
}

Fixed version (ground truth):
/** 
 * Init. the chunk.
 */
public Chunk(World p,Vector3f position){
  this._position=position;
  _parent=p;
  _blocks=new int[(int)CHUNK_DIMENSIONS.x][(int)CHUNK_DIMENSIONS.y][(int)CHUNK_DIMENSIONS.z];
  _light=new float[(int)CHUNK_DIMENSIONS.x][(int)CHUNK_DIMENSIONS.y][(int)CHUNK_DIMENSIONS.z];
}
Program: 1320
Project: 1320
Buggy source:
/** 
 * Populates the chunk (e.g. placement of trees etc.).
 */
public void populate(){
  for (int x=0; x < Chunk.CHUNK_DIMENSIONS.x; x++) {
    for (int z=0; z < Chunk.CHUNK_DIMENSIONS.z; z++) {
      for (int y=32; y < Chunk.CHUNK_DIMENSIONS.y; y++) {
        if (_parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z)) == 0x1 && _rand.nextFloat() < 0.009f) {
          if (_rand.nextBoolean()) {
            _parent.generateTree(getBlockWorldPosX(x),getBlockWorldPosY((int)y) + 1,getBlockWorldPosZ(z));
          }
 else {
            _parent.generatePineTree(getBlockWorldPosX(x),getBlockWorldPosY((int)y) + 1,getBlockWorldPosZ(z));
          }
          return;
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Populates the chunk (e.g. placement of trees etc.).
 */
public void populate(){
  for (int y=0; y < Chunk.CHUNK_DIMENSIONS.y; y++) {
    for (int x=0; x < Chunk.CHUNK_DIMENSIONS.x; x++) {
      for (int z=0; z < Chunk.CHUNK_DIMENSIONS.z; z++) {
        float dens=calcForestDensity(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z));
        if (dens > 0.55 && dens < 0.7f && _parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z)) == 0x1 && y > 32) {
          _parent.generateTree(getBlockWorldPosX(x),getBlockWorldPosY((int)y) + 1,getBlockWorldPosZ(z),false);
          return;
        }
 else         if (dens >= 0.7f && _parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z)) == 0x1 && y > 32) {
          _parent.generatePineTree(getBlockWorldPosX(x),getBlockWorldPosY((int)y) + 1,getBlockWorldPosZ(z),false);
          return;
        }
      }
    }
  }
}
Program: 1321
Project: 1321
Buggy source:
void calcLight(){
  for (int ite=0; ite < 16; ite++) {
    for (int x=0; x < (int)CHUNK_DIMENSIONS.x; x++) {
      for (int z=0; z < (int)CHUNK_DIMENSIONS.z; z++) {
        for (int y=(int)CHUNK_DIMENSIONS.y - 1; y > 0; y--) {
          if (getLight(x,y,z) == MAX_LIGHT - ite * 0.0625f && getBlock(x,y,z) == 0) {
            floodLight(x,y,z);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void calcLight(){
  for (int ite=0; ite < 16; ite++) {
    for (int x=0; x < (int)CHUNK_DIMENSIONS.x; x++) {
      for (int z=0; z < (int)CHUNK_DIMENSIONS.z; z++) {
        for (int y=(int)CHUNK_DIMENSIONS.y - 1; y > 0; y--) {
          if (getLight(x,y,z) == MAX_LIGHT - ite * 0.0625f && getBlock(x,y,z) == 0) {
            floodLight(x,y,z);
          }
        }
      }
    }
  }
}
Program: 1322
Project: 1322
Buggy source:
@Override public String toString(){
  return String.format("String_Node_Str",_chunkID,blockCount());
}

Fixed version (ground truth):
@Override public String toString(){
  return String.format("String_Node_Str",_chunkID,blockCount(),_position);
}
Program: 1323
Project: 1323
Buggy source:
public Vector3f getColorOffsetFor(int type,SIDE side){
switch (type) {
case 0x1:
    if (side == SIDE.TOP) {
      return new Vector3f(204f / 255f,255f / 255f,25f / 255f);
    }
  break;
case 0x6:
return new Vector3f(80f / 255f,176f / 255f,7f / 255f);
}
return new Vector3f(1.0f,1.0f,1.0f);
}

Fixed version (ground truth):
public Vector3f getColorOffsetFor(int type,SIDE side){
switch (type) {
case 0x1:
    if (side == SIDE.TOP) {
      return new Vector3f(204f / 255f,255f / 255f,25f / 255f);
    }
  break;
case 0x6:
return new Vector3f(159f / 255f,235f / 255f,89f / 255f);
}
return new Vector3f(1.0f,1.0f,1.0f);
}
Program: 1324
Project: 1324
Buggy source:
private float maxLightFromNeighbors(int x,int y,int z){
  float intens=0.0f;
  for (int x1=0; x1 <= 16; ++x1) {
    float tempInt=parent.getSunlight(getBlockWorldPosX(x + x1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) / Math.abs(x1);
    if (tempInt > intens) {
      intens=tempInt;
    }
    if (parent.getBlock(getBlockWorldPosX(x + x1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0) {
      break;
    }
  }
  for (int x1=0; x1 >= -16; --x1) {
    float tempInt=parent.getSunlight(getBlockWorldPosX(x + x1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) / Math.abs(x1);
    if (tempInt > intens) {
      intens=tempInt;
    }
    if (parent.getBlock(getBlockWorldPosX(x + x1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0) {
      break;
    }
  }
  for (int z1=0; z1 <= 16; ++z1) {
    float tempInt=parent.getSunlight(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + z1)) / Math.abs(z1);
    if (tempInt > intens) {
      intens=tempInt;
    }
    if (parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + z1)) > 0) {
      break;
    }
  }
  for (int z1=0; z1 >= -16; --z1) {
    float tempInt=parent.getSunlight(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + z1)) / Math.abs(z1);
    if (tempInt > intens) {
      intens=tempInt;
    }
    if (parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + z1)) > 0) {
      break;
    }
  }
  return intens;
}

Fixed version (ground truth):
private float maxLightFromNeighbors(int x,int y,int z){
  float intens=0.0f;
  for (int x1=0; x1 <= 16; ++x1) {
    float tempInt=parent.getSunlight(getBlockWorldPosX(x + x1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) / (Math.abs(x1) + 1);
    if (tempInt > intens) {
      intens=tempInt;
    }
    if (parent.getBlock(getBlockWorldPosX(x + x1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0) {
      break;
    }
  }
  for (int x1=0; x1 >= -16; --x1) {
    float tempInt=parent.getSunlight(getBlockWorldPosX(x + x1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) / (Math.abs(x1) + 1);
    if (tempInt > intens) {
      intens=tempInt;
    }
    if (parent.getBlock(getBlockWorldPosX(x + x1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0) {
      break;
    }
  }
  for (int z1=0; z1 <= 16; ++z1) {
    float tempInt=parent.getSunlight(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + z1)) / (Math.abs(z1) + 1);
    if (tempInt > intens) {
      intens=tempInt;
    }
    if (parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + z1)) > 0) {
      break;
    }
  }
  for (int z1=0; z1 >= -16; --z1) {
    float tempInt=parent.getSunlight(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + z1)) / (Math.abs(z1) + 1);
    if (tempInt > intens) {
      intens=tempInt;
    }
    if (parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + z1)) > 0) {
      break;
    }
  }
  return intens;
}
Program: 1325
Project: 1325
Buggy source:
public void calcSunlight(){
  sunlight=new float[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  for (int x=0; x < (int)chunkDimensions.x; x++) {
    for (int z=0; z < (int)chunkDimensions.z; z++) {
      for (int y=(int)chunkDimensions.y - 1; y > 0; y--) {
        if (blocks[x][y][z] == 0) {
          setSunlight(x,y,z,MAX_LIGHT);
        }
 else {
          setSunlight(x,y,z,MAX_LIGHT);
          break;
        }
      }
    }
  }
}

Fixed version (ground truth):
public void calcSunlight(){
  sunlight=new float[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  for (int x=0; x < (int)chunkDimensions.x; x++) {
    for (int z=0; z < (int)chunkDimensions.z; z++) {
      for (int y=(int)chunkDimensions.y - 1; y > 0; y--) {
        if (blocks[x][y][z] == 0) {
          setSunlight(x,y,z,MAX_LIGHT);
        }
 else {
          break;
        }
      }
    }
  }
}
Program: 1326
Project: 1326
Buggy source:
public float getLight(int x,int y,int z){
  float result=0f;
  try {
    result=light[x][y][z];
    if (result == 0.0f) {
      result=sunlight[x][y][z];
    }
  }
 catch (  Exception e) {
  }
  if (result == 0f) {
    result=MIN_LIGHT;
  }
  return result;
}

Fixed version (ground truth):
public float getLight(int x,int y,int z){
  float result=0f;
  try {
    result=light[x][y][z];
    if (result == 0.0f) {
      result=sunlight[x][y][z];
    }
  }
 catch (  Exception e) {
  }
  if (result < 0.2f) {
    result=MIN_LIGHT;
  }
  return result;
}
Program: 1327
Project: 1327
Buggy source:
public void calcLight(){
  light=new float[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  for (int x=0; x < (int)chunkDimensions.x; x++) {
    for (int z=0; z < (int)chunkDimensions.z; z++) {
      for (int y=0; y < (int)chunkDimensions.y; y++) {
        if (blocks[x][y][z] == 0 && sunlight[x][y][z] == 0) {
          setLight(x,y,z,maxLightFromNeighbors(x,y,z));
        }
      }
    }
  }
}

Fixed version (ground truth):
public void calcLight(){
  light=new float[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  for (int x=0; x < (int)chunkDimensions.x; x++) {
    for (int z=0; z < (int)chunkDimensions.z; z++) {
      for (int y=0; y < (int)chunkDimensions.y; y++) {
        if (blocks[x][y][z] == 0 && sunlight[x][y][z] == 0) {
          float sunl=maxLightFromNeighbors(x,y,z);
          setLight(x,y,z,sunl);
        }
 else         if (blocks[x][y][z] == 0 && sunlight[x][y][z] > 0f) {
          float dimming=0.0f;
          dimming+=(parent.getBlock(getBlockWorldPosX(x + 1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0) ? DIMMING_INTENS : 0.0f;
          dimming+=(parent.getBlock(getBlockWorldPosX(x - 1),getBlockWorldPosY(y),getBlockWorldPosZ(z)) > 0) ? DIMMING_INTENS : 0.0f;
          dimming+=(parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z + 1)) > 0) ? DIMMING_INTENS : 0.0f;
          dimming+=(parent.getBlock(getBlockWorldPosX(x),getBlockWorldPosY(y),getBlockWorldPosZ(z - 1)) > 0) ? DIMMING_INTENS : 0.0f;
          dimming+=(parent.getBlock(getBlockWorldPosX(x + 1),getBlockWorldPosY(y),getBlockWorldPosZ(z + 1)) > 0) ? DIMMING_INTENS : 0.0f;
          dimming+=(parent.getBlock(getBlockWorldPosX(x - 1),getBlockWorldPosY(y),getBlockWorldPosZ(z - 1)) > 0) ? DIMMING_INTENS : 0.0f;
          dimming+=(parent.getBlock(getBlockWorldPosX(x - 1),getBlockWorldPosY(y),getBlockWorldPosZ(z + 1)) > 0) ? DIMMING_INTENS : 0.0f;
          dimming+=(parent.getBlock(getBlockWorldPosX(x + 1),getBlockWorldPosY(y),getBlockWorldPosZ(z - 1)) > 0) ? DIMMING_INTENS : 0.0f;
          setLight(x,y,z,Math.max(sunlight[x][y][z] - dimming,0f));
        }
      }
    }
  }
}
Program: 1328
Project: 1328
Buggy source:
/** 
 * Returns true if the given position is filled with a block.
 */
public boolean isHitting(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=chunks[chunkPosX][chunkPosY][chunkPosZ];
    return (c.getBlock(blockPosX,blockPosY,blockPosZ) > 0);
  }
 catch (  Exception e) {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Returns true if the given position is filled with a block.
 */
public boolean isHitting(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=getChunk(chunkPosX,chunkPosY,chunkPosZ);
    return (c.getBlock(blockPosX,blockPosY,blockPosZ) > 0);
  }
 catch (  Exception e) {
    return false;
  }
}
Program: 1329
Project: 1329
Buggy source:
/** 
 * Sets the type of a block at a given position.
 */
public final void setBlock(int x,int y,int z,int type){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=chunks[chunkPosX][chunkPosY][chunkPosZ];
    if (c.getPosition().x != calcChunkPosX(x) || c.getPosition().y != calcChunkPosY(y) || c.getPosition().z != calcChunkPosZ(z)) {
      return;
    }
    c.setBlock(blockPosX,blockPosY,blockPosZ,type);
    queueChunkForUpdate(c);
  }
 catch (  Exception e) {
    return;
  }
}

Fixed version (ground truth):
/** 
 * Sets the type of a block at a given position.
 */
public final void setBlock(int x,int y,int z,int type){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=getChunk(chunkPosX,chunkPosY,chunkPosZ);
    if (c.getPosition().x != calcChunkPosX(x) || c.getPosition().y != calcChunkPosY(y) || c.getPosition().z != calcChunkPosZ(z)) {
      return;
    }
    c.setBlock(blockPosX,blockPosY,blockPosZ,type);
    queueChunkForUpdate(c);
  }
 catch (  Exception e) {
    return;
  }
}
Program: 1330
Project: 1330
Buggy source:
@Override public void run(){
  while (true) {
    updateInfWorld();
    if (Helper.getInstance().getTime() - daylightTimer > 20000) {
      daylight-=0.2;
      if (daylight <= 0.4f) {
        daylight=1.0f;
      }
      daylightTimer=Helper.getInstance().getTime();
      updateAllChunks();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (true) {
    updateInfWorld();
    if (Helper.getInstance().getTime() - daylightTimer > 120000) {
      daylight-=0.2;
      if (daylight <= 0.4f) {
        daylight=1.0f;
      }
      daylightTimer=Helper.getInstance().getTime();
      updateAllChunks();
    }
  }
}
Program: 1332
Project: 1332
Buggy source:
public final float getSunlight(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=chunks[chunkPosX][chunkPosY][chunkPosZ];
    if (c.getPosition().x == calcChunkPosX(x) && c.getPosition().y == calcChunkPosY(y) && c.getPosition().z == calcChunkPosZ(z)) {
      return c.getSunlight(blockPosX,blockPosY,blockPosZ);
    }
  }
 catch (  Exception e) {
  }
  return -1f;
}

Fixed version (ground truth):
public final float getSunlight(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=getChunk(chunkPosX,chunkPosY,chunkPosZ);
    if (c.getPosition().x == calcChunkPosX(x) && c.getPosition().y == calcChunkPosY(y) && c.getPosition().z == calcChunkPosZ(z)) {
      return c.getSunlight(blockPosX,blockPosY,blockPosZ);
    }
  }
 catch (  Exception e) {
  }
  return -1f;
}
Program: 1333
Project: 1333
Buggy source:
@Override public void render(){
  glPushMatrix();
  glDisable(GL_FOG);
  glTranslatef(Configuration.viewingDistanceInChunks.x * Chunk.chunkDimensions.x * 1.5f + player.getPosition().x,Configuration.viewingDistanceInChunks.y * Chunk.chunkDimensions.y + player.getPosition().y,Configuration.viewingDistanceInChunks.z * Chunk.chunkDimensions.z * 1.5f + player.getPosition().z);
  glCallList(displayListSun);
  glEnable(GL_FOG);
  glPopMatrix();
  for (int x=0; x < Configuration.viewingDistanceInChunks.x; x++) {
    for (int y=0; y < Configuration.viewingDistanceInChunks.y; y++) {
      for (int z=0; z < Configuration.viewingDistanceInChunks.z; z++) {
        Chunk c=chunks[x][y][z];
        if (c != null) {
          c.render();
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void render(){
  glPushMatrix();
  glDisable(GL_FOG);
  glTranslatef(Configuration.viewingDistanceInChunks.x * Chunk.chunkDimensions.x * 1.5f + player.getPosition().x,Configuration.viewingDistanceInChunks.y * Chunk.chunkDimensions.y + player.getPosition().y,Configuration.viewingDistanceInChunks.z * Chunk.chunkDimensions.z * 1.5f + player.getPosition().z);
  glCallList(displayListSun);
  glEnable(GL_FOG);
  glPopMatrix();
  for (int x=0; x < Configuration.viewingDistanceInChunks.x; x++) {
    for (int y=0; y < Configuration.viewingDistanceInChunks.y; y++) {
      for (int z=0; z < Configuration.viewingDistanceInChunks.z; z++) {
        Chunk c=getChunk(x,y,z);
        if (c != null) {
          c.render();
        }
      }
    }
  }
}
Program: 1334
Project: 1334
Buggy source:
/** 
 * TODO.
 */
public final float getLight(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=chunks[chunkPosX][chunkPosY][chunkPosZ];
    if (c.getPosition().x == calcChunkPosX(x) && c.getPosition().y == calcChunkPosY(y) && c.getPosition().z == calcChunkPosZ(z)) {
      return c.getLight(blockPosX,blockPosY,blockPosZ);
    }
  }
 catch (  Exception e) {
  }
  return -1f;
}

Fixed version (ground truth):
/** 
 * TODO.
 */
public final float getLight(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=getChunk(chunkPosX,chunkPosY,chunkPosZ);
    if (c.getPosition().x == calcChunkPosX(x) && c.getPosition().y == calcChunkPosY(y) && c.getPosition().z == calcChunkPosZ(z)) {
      return c.getLight(blockPosX,blockPosY,blockPosZ);
    }
  }
 catch (  Exception e) {
  }
  return -1f;
}
Program: 1335
Project: 1335
Buggy source:
/** 
 * Returns a block at a position by looking up the containing chunk.
 */
public final int getBlock(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=chunks[chunkPosX][chunkPosY][chunkPosZ];
    if (c.getPosition().x == calcChunkPosX(x) && c.getPosition().y == calcChunkPosY(y) && c.getPosition().z == calcChunkPosZ(z)) {
      return c.getBlock(blockPosX,blockPosY,blockPosZ);
    }
  }
 catch (  Exception e) {
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Returns a block at a position by looking up the containing chunk.
 */
public final int getBlock(int x,int y,int z){
  int chunkPosX=calcChunkPosX(x) % (int)Configuration.viewingDistanceInChunks.x;
  int chunkPosY=calcChunkPosY(y) % (int)Configuration.viewingDistanceInChunks.y;
  int chunkPosZ=calcChunkPosZ(z) % (int)Configuration.viewingDistanceInChunks.z;
  int blockPosX=calcBlockPosX(x,chunkPosX);
  int blockPosY=calcBlockPosY(y,chunkPosY);
  int blockPosZ=calcBlockPosZ(z,chunkPosZ);
  try {
    Chunk c=getChunk(chunkPosX,chunkPosY,chunkPosZ);
    if (c.getPosition().x == calcChunkPosX(x) && c.getPosition().y == calcChunkPosY(y) && c.getPosition().z == calcChunkPosZ(z)) {
      return c.getBlock(blockPosX,blockPosY,blockPosZ);
    }
  }
 catch (  Exception e) {
  }
  return -1;
}
Program: 1336
Project: 1336
Buggy source:
private void queueChunkForUpdate(Chunk c){
  if (c != null) {
    ArrayList<Chunk> cs=new ArrayList<Chunk>();
    cs.add(c);
    try {
      cs.add(chunks[(int)c.getPosition().x + 1][(int)c.getPosition().y][(int)c.getPosition().z]);
    }
 catch (    Exception e) {
    }
    try {
      cs.add(chunks[(int)c.getPosition().x - 1][(int)c.getPosition().y][(int)c.getPosition().z]);
    }
 catch (    Exception e) {
    }
    try {
      cs.add(chunks[(int)c.getPosition().x][(int)c.getPosition().y][(int)c.getPosition().z + 1]);
    }
 catch (    Exception e) {
    }
    try {
      cs.add(chunks[(int)c.getPosition().x][(int)c.getPosition().y][(int)c.getPosition().z - 1]);
    }
 catch (    Exception e) {
    }
synchronized (chunkUpdateQueueDL) {
      for (      Chunk cc : cs) {
        if (!chunkUpdateQueue.contains(cc) && cc != null) {
          chunkUpdateQueue.add(cc);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void queueChunkForUpdate(Chunk c){
  if (c != null) {
    ArrayList<Chunk> cs=new ArrayList<Chunk>();
    cs.add(c);
    try {
      cs.add(getChunk((int)c.getPosition().x + 1,(int)c.getPosition().y,(int)c.getPosition().z));
    }
 catch (    Exception e) {
    }
    try {
      cs.add(getChunk((int)c.getPosition().x - 1,(int)c.getPosition().y,(int)c.getPosition().z));
    }
 catch (    Exception e) {
    }
    try {
      cs.add(getChunk((int)c.getPosition().x,(int)c.getPosition().y,(int)c.getPosition().z + 1));
    }
 catch (    Exception e) {
    }
    try {
      cs.add(getChunk((int)c.getPosition().x,(int)c.getPosition().y,(int)c.getPosition().z - 1));
    }
 catch (    Exception e) {
    }
synchronized (chunkUpdateQueueDL) {
      for (      Chunk cc : cs) {
        if (!chunkUpdateQueue.contains(cc) && cc != null) {
          chunkUpdateQueue.add(cc);
        }
      }
    }
  }
}
Program: 1337
Project: 1337
Buggy source:
private void updateInfWorld(){
  for (int x=0; x < Configuration.viewingDistanceInChunks.x; x++) {
    for (int y=0; y < Configuration.viewingDistanceInChunks.y; y++) {
      for (int z=0; z < Configuration.viewingDistanceInChunks.z; z++) {
        Chunk c=chunks[x][y][z];
        if (c != null) {
          Vector3f pos=new Vector3f(x,y,z);
          int multZ=(int)calcPlayerChunkOffsetZ() / (int)Configuration.viewingDistanceInChunks.z + 1;
          if (z < calcPlayerChunkOffsetZ() % Configuration.viewingDistanceInChunks.z) {
            pos.z+=Configuration.viewingDistanceInChunks.z * multZ;
          }
 else {
            pos.z+=Configuration.viewingDistanceInChunks.z * (multZ - 1);
          }
          int multX=(int)calcPlayerChunkOffsetX() / (int)Configuration.viewingDistanceInChunks.x + 1;
          if (x < calcPlayerChunkOffsetX() % Configuration.viewingDistanceInChunks.x) {
            pos.x+=Configuration.viewingDistanceInChunks.x * multX;
          }
 else {
            pos.x+=Configuration.viewingDistanceInChunks.x * (multX - 1);
          }
          if (c.getPosition().x != pos.x || c.getPosition().z != pos.z) {
            c.setPosition(pos);
            c.generate();
            c.populate();
            queueChunkForUpdate(c);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void updateInfWorld(){
  ArrayList<Chunk> chunksToUpdate=new ArrayList<Chunk>();
  for (int x=0; x < Configuration.viewingDistanceInChunks.x; x++) {
    for (int y=0; y < Configuration.viewingDistanceInChunks.y; y++) {
      for (int z=0; z < Configuration.viewingDistanceInChunks.z; z++) {
        Chunk c=getChunk(x,y,z);
        if (c != null) {
          Vector3f pos=new Vector3f(x,y,z);
          int multZ=(int)calcPlayerChunkOffsetZ() / (int)Configuration.viewingDistanceInChunks.z + 1;
          if (z < calcPlayerChunkOffsetZ() % Configuration.viewingDistanceInChunks.z) {
            pos.z+=Configuration.viewingDistanceInChunks.z * multZ;
          }
 else {
            pos.z+=Configuration.viewingDistanceInChunks.z * (multZ - 1);
          }
          int multX=(int)calcPlayerChunkOffsetX() / (int)Configuration.viewingDistanceInChunks.x + 1;
          if (x < calcPlayerChunkOffsetX() % Configuration.viewingDistanceInChunks.x) {
            pos.x+=Configuration.viewingDistanceInChunks.x * multX;
          }
 else {
            pos.x+=Configuration.viewingDistanceInChunks.x * (multX - 1);
          }
          if (c.getPosition().x != pos.x || c.getPosition().z != pos.z) {
            c.setPosition(pos);
            c.generate();
            c.populate();
            c.calcSunlight();
            chunksToUpdate.add(c);
          }
        }
      }
    }
  }
  for (  Chunk c : chunksToUpdate) {
    queueChunkForUpdate(c);
  }
}
Program: 1338
Project: 1338
Buggy source:
public void updateAllChunks(){
  for (int x=0; x < Configuration.viewingDistanceInChunks.x; x++) {
    for (int y=0; y < Configuration.viewingDistanceInChunks.y; y++) {
      for (int z=0; z < Configuration.viewingDistanceInChunks.z; z++) {
        Chunk c=chunks[x][y][z];
        queueChunkForUpdate(c);
      }
    }
  }
}

Fixed version (ground truth):
public void updateAllChunks(){
  for (int x=0; x < Configuration.viewingDistanceInChunks.x; x++) {
    for (int y=0; y < Configuration.viewingDistanceInChunks.y; y++) {
      for (int z=0; z < Configuration.viewingDistanceInChunks.z; z++) {
        Chunk c=getChunk(x,y,z);
        queueChunkForUpdate(c);
      }
    }
  }
}
Program: 1339
Project: 1339
Buggy source:
public Chunk(World p,Vector3f position){
  this.position=position;
  if (Chunk.parent == null) {
    Chunk.parent=p;
  }
  blocks=new int[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  light=new float[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  generate();
}

Fixed version (ground truth):
public Chunk(World p,Vector3f position){
  this.position=position;
  if (Chunk.parent == null) {
    Chunk.parent=p;
  }
  blocks=new int[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  light=new float[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  if (position.y == 0) {
    generate();
  }
}
Program: 1340
Project: 1340
Buggy source:
/** 
 * Returns the base elevation for the terrain.
 */
private float calcTerrainElevation(float x,float z){
  float result=0.0f;
  result+=pGen1.noise(0.0009f * x,0.0009f,0.00009f * z) * 64.0f;
  return Math.abs(result);
}

Fixed version (ground truth):
/** 
 * Returns the base elevation for the terrain.
 */
private float calcTerrainElevation(float x,float z){
  float result=0.0f;
  result+=pGen1.noise(0.002f * x,0.002f,0.002f * z) * 90.0f;
  return Math.abs(result);
}
Program: 1342
Project: 1342
Buggy source:
public void resizeGL(){
  glViewport(0,0,(int)DISPLAY_WIDTH,(int)DISPLAY_HEIGHT);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(64.0f,DISPLAY_WIDTH / DISPLAY_HEIGHT,0.1f,1000f);
  glPushMatrix();
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glPushMatrix();
}

Fixed version (ground truth):
public void resizeGL(){
  glViewport(0,0,(int)DISPLAY_WIDTH,(int)DISPLAY_HEIGHT);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(64.0f,DISPLAY_WIDTH / DISPLAY_HEIGHT,0.01f,1000f);
  glPushMatrix();
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glPushMatrix();
}
Program: 1344
Project: 1344
Buggy source:
private boolean isPlayerStandingOnGround(){
  if (getParent() != null) {
    return getParent().isHitting(new Vector3f(getPosition().x,getPosition().y - PLAYER_HEIGHT,getPosition().z));
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
private boolean isPlayerStandingOnGround(){
  if (getParent() != null) {
    return getParent().isHitting(new Vector3f(getPosition().x + 0.5f,getPosition().y - PLAYER_HEIGHT,getPosition().z + 0.5f));
  }
 else {
    return false;
  }
}
Program: 1345
Project: 1345
Buggy source:
public Vector3f calcViewBlockPosition(){
  Vector3f blockPosition=new Vector3f(position);
  Vector2f viewingDirectionHorizontal=new Vector2f((float)Math.sin(Math.toRadians(yaw)),-1f * (float)Math.cos(Math.toRadians(yaw)));
  Vector2f viewingDirectionVertical=new Vector2f(-1f * (float)Math.sin(Math.toRadians(pitch)),(float)Math.cos(Math.toRadians(pitch)));
  blockPosition.x+=4f * viewingDirectionHorizontal.x;
  blockPosition.y+=4f * viewingDirectionVertical.x;
  blockPosition.z+=4f * viewingDirectionHorizontal.y;
  return blockPosition;
}

Fixed version (ground truth):
public Vector3f calcViewBlockPosition(){
  Vector3f blockPosition=new Vector3f(position);
  Vector2f viewingDirectionHorizontal=new Vector2f((float)Math.sin(Math.toRadians(yaw)),-1f * (float)Math.cos(Math.toRadians(yaw)));
  Vector2f viewingDirectionVertical=new Vector2f(-1f * (float)Math.sin(Math.toRadians(pitch)),(float)Math.cos(Math.toRadians(pitch)));
  for (int z=0; z < 4; z++) {
    blockPosition.x+=viewingDirectionHorizontal.x * viewingDirectionVertical.y;
    blockPosition.y+=viewingDirectionVertical.x;
    blockPosition.z+=viewingDirectionHorizontal.y * viewingDirectionVertical.y;
    if (parent.getBlock(blockPosition) != 0) {
      return blockPosition;
    }
  }
  return null;
}
Program: 1346
Project: 1346
Buggy source:
private void processMovement(long delta){
  if (getParent() != null) {
    if (Keyboard.isKeyDown(Keyboard.KEY_R)) {
      resetPlayer();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_T)) {
      parent.generateTrees();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
      walkForward();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
      walkBackwards();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
      strafeLeft();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
      strafeRight();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
      jump();
    }
    if (!parent.isHitting(new Vector3f(getPosition().x,getPosition().y - PLAYER_HEIGHT,getPosition().z))) {
      if (gravity > -MAX_GRAVITY) {
        gravity-=1;
      }
      getPosition().y+=(gravity / 1000.0f) * delta;
    }
 else     if (gravity > 0.0f) {
      getPosition().y+=(gravity / 1000.0f) * delta;
    }
    if (isObjectInFrontOfPlayer()) {
      accX=0;
      accZ=0;
    }
    getPosition().x+=(accX / 1000.0f) * delta;
    getPosition().z+=(accZ / 1000.0f) * delta;
    accX=0;
    accZ=0;
  }
}

Fixed version (ground truth):
private void processMovement(long delta){
  if (getParent() != null) {
    if (Keyboard.isKeyDown(Keyboard.KEY_R)) {
      resetPlayer();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_T)) {
      parent.generateTrees();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
      walkForward();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
      walkBackwards();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
      strafeLeft();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
      strafeRight();
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
      jump();
    }
    boolean hitting=parent.isHitting(new Vector3f(getPosition().x + 0.5f,getPosition().y - PLAYER_HEIGHT,getPosition().z + 0.5f));
    if (!hitting) {
      if (gravity > -MAX_GRAVITY) {
        gravity-=0.5f;
      }
      getPosition().y+=(gravity / 1000.0f) * delta;
    }
 else     if (gravity > 0.0f) {
      getPosition().y+=(gravity / 1000.0f) * delta;
    }
 else {
      gravity=0.0f;
    }
    Vector2f dir=new Vector2f((float)accX,(float)accZ);
    try {
      dir.normalise();
    }
 catch (    Exception e) {
    }
    if (checkForCollision(new Vector3f(getPosition().x + dir.x * 0.1f,getPosition().y - PLAYER_HEIGHT + 1,getPosition().z + dir.y * 0.1f))) {
      accX=0;
      accZ=0;
    }
    getPosition().x+=(accX / 1000.0f) * delta;
    getPosition().z+=(accZ / 1000.0f) * delta;
    accX=0;
    accZ=0;
  }
}
Program: 1347
Project: 1347
Buggy source:
public void init(){
  updateThread.start();
  Sphere s=new Sphere();
  displayListSun=glGenLists(1);
  glNewList(displayListSun,GL_COMPILE);
  glColor4f(1.0f,0.8f,0.0f,1.0f);
  s.draw(120.0f,16,32);
  glEndList();
}

Fixed version (ground truth):
public void init(){
  updateThread.start();
  Sphere s=new Sphere();
  displayListSun=glGenLists(1);
  glNewList(displayListSun,GL_COMPILE);
  glColor4f(1.0f,0.8f,0.0f,1.0f);
  s.draw(256.0f,16,32);
  glEndList();
}
Program: 1348
Project: 1348
Buggy source:
/** 
 * @return the player
 */
public Player getPlayer(){
  return player;
}

Fixed version (ground truth):
/** 
 * TODO
 */
public Player getPlayer(){
  return player;
}
Program: 1349
Project: 1349
Buggy source:
/** 
 * Sets the type of a block at a given position.
 * @param pos
 * @param type
 */
public final void setBlock(Vector3f pos,int type){
  Vector3f chunkPos=calcChunkPos(pos);
  Vector3f blockCoord=calcBlockPos(pos,chunkPos);
  try {
    Chunk c=chunks[(int)chunkPos.x][(int)chunkPos.y][(int)chunkPos.z];
    if (c == null) {
      c=new Chunk(this,new Vector3f(chunkPos.x,chunkPos.y,chunkPos.z));
      chunks[(int)chunkPos.x][(int)chunkPos.y][(int)chunkPos.z]=c;
    }
    c.setBlock(blockCoord,type,true);
    chunkUpdateQueue.add(c);
  }
 catch (  Exception e) {
    return;
  }
}

Fixed version (ground truth):
/** 
 * Sets the type of a block at a given position.
 */
public final void setBlock(Vector3f pos,int type){
  Vector3f chunkPos=calcChunkPos(pos);
  Vector3f blockCoord=calcBlockPos(pos,chunkPos);
  try {
    Chunk c=chunks[(int)chunkPos.x][(int)chunkPos.y][(int)chunkPos.z];
    Chunk c1=chunks[(int)chunkPos.x - 1][(int)chunkPos.y][(int)chunkPos.z];
    Chunk c2=chunks[(int)chunkPos.x + 1][(int)chunkPos.y][(int)chunkPos.z];
    Chunk c3=chunks[(int)chunkPos.x][(int)chunkPos.y][(int)chunkPos.z - 1];
    Chunk c4=chunks[(int)chunkPos.x][(int)chunkPos.y][(int)chunkPos.z + 1];
    c.setBlock(blockCoord,type,true);
    if ((int)blockCoord.x == 0) {
      c1.dirty=true;
      chunkUpdateQueue.add(c1);
    }
 else     if ((int)blockCoord.x == (int)Chunk.chunkDimensions.x - 1) {
      c2.dirty=true;
      chunkUpdateQueue.add(c2);
    }
    if ((int)blockCoord.z == 0) {
      c3.dirty=true;
      chunkUpdateQueue.add(c3);
    }
 else     if ((int)blockCoord.z == (int)Chunk.chunkDimensions.z - 1) {
      c4.dirty=true;
      chunkUpdateQueue.add(c4);
    }
    chunkUpdateQueue.add(c);
  }
 catch (  Exception e) {
    return;
  }
}
Program: 1350
Project: 1350
Buggy source:
/** 
 * Calculate the position of a world-block within a specific chunk.
 */
private Vector3f calcBlockPos(Vector3f pos,Vector3f chunkPos){
  return new Vector3f(pos.x - (chunkPos.x * Chunk.chunkDimensions.x),pos.y - (chunkPos.y * Chunk.chunkDimensions.y),pos.z - (chunkPos.z * Chunk.chunkDimensions.z));
}

Fixed version (ground truth):
/** 
 * Calculate the position of a world-block within a specific chunk.
 */
private Vector3f calcBlockPos(Vector3f pos,Vector3f chunkPos){
  if (pos != null && chunkPos != null) {
    return new Vector3f(pos.x - (chunkPos.x * Chunk.chunkDimensions.x),pos.y - (chunkPos.y * Chunk.chunkDimensions.y),pos.z - (chunkPos.z * Chunk.chunkDimensions.z));
  }
  return null;
}
Program: 1351
Project: 1351
Buggy source:
/** 
 * Calculate the corresponding chunk for a given position within the world.
 */
private Vector3f calcChunkPos(Vector3f pos){
  return new Vector3f((int)(pos.x / Chunk.chunkDimensions.x),(int)(pos.y / Chunk.chunkDimensions.y),(int)(pos.z / Chunk.chunkDimensions.z));
}

Fixed version (ground truth):
/** 
 * Calculate the corresponding chunk for a given position within the world.
 */
private Vector3f calcChunkPos(Vector3f pos){
  if (pos != null) {
    return new Vector3f((int)(pos.x / Chunk.chunkDimensions.x),(int)(pos.y / Chunk.chunkDimensions.y),(int)(pos.z / Chunk.chunkDimensions.z));
  }
  return null;
}
Program: 1352
Project: 1352
Buggy source:
@Override public void render(){
  glPushMatrix();
  glDisable(GL_FOG);
  glTranslatef(Configuration.viewingDistanceInChunks.x * Chunk.chunkDimensions.x,Configuration.viewingDistanceInChunks.y * Chunk.chunkDimensions.y * 2f,Configuration.viewingDistanceInChunks.z * Chunk.chunkDimensions.z);
  glCallList(displayListSun);
  glEnable(GL_FOG);
  glPopMatrix();
  for (int x=0; x < Configuration.viewingDistanceInChunks.x; x++) {
    for (int y=0; y < Configuration.viewingDistanceInChunks.y; y++) {
      for (int z=0; z < Configuration.viewingDistanceInChunks.z; z++) {
        Chunk c=chunks[x][y][z];
        if (c != null) {
          c.render();
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void render(){
  glPushMatrix();
  glDisable(GL_FOG);
  glTranslatef(Configuration.viewingDistanceInChunks.x * Chunk.chunkDimensions.x * 1.5f,Configuration.viewingDistanceInChunks.y * Chunk.chunkDimensions.y,Configuration.viewingDistanceInChunks.z * Chunk.chunkDimensions.z * 1.5f);
  glCallList(displayListSun);
  glEnable(GL_FOG);
  glPopMatrix();
  for (int x=0; x < Configuration.viewingDistanceInChunks.x; x++) {
    for (int y=0; y < Configuration.viewingDistanceInChunks.y; y++) {
      for (int z=0; z < Configuration.viewingDistanceInChunks.z; z++) {
        Chunk c=chunks[x][y][z];
        if (c != null) {
          c.render();
        }
      }
    }
  }
}
Program: 1353
Project: 1353
Buggy source:
public Chunk(World p,Vector3f position){
  this.position=position;
  if (Chunk.parent == null) {
    Chunk.parent=p;
  }
  blocks=new int[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  light=new float[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  generate();
}

Fixed version (ground truth):
public Chunk(World p,Vector3f position){
  this.position=position;
  if (Chunk.parent == null) {
    Chunk.parent=p;
  }
  blocks=new int[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  light=new float[(int)chunkDimensions.x][(int)chunkDimensions.y][(int)chunkDimensions.z];
  if (position.y == 0) {
    generate();
  }
}
Program: 1354
Project: 1354
Buggy source:
/** 
 * Returns the base elevation for the terrain.
 */
private float calcTerrainElevation(float x,float z){
  float result=0.0f;
  result+=pGen1.noise(0.0009f * x,0.0009f,0.00009f * z) * 64.0f;
  return Math.abs(result);
}

Fixed version (ground truth):
/** 
 * Returns the base elevation for the terrain.
 */
private float calcTerrainElevation(float x,float z){
  float result=0.0f;
  result+=pGen1.noise(0.002f * x,0.002f,0.002f * z) * 90.0f;
  return Math.abs(result);
}
Program: 1356
Project: 1356
Buggy source:
public void resizeGL(){
  glViewport(0,0,(int)DISPLAY_WIDTH,(int)DISPLAY_HEIGHT);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(64.0f,DISPLAY_WIDTH / DISPLAY_HEIGHT,0.1f,1000f);
  glPushMatrix();
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glPushMatrix();
}

Fixed version (ground truth):
public void resizeGL(){
  glViewport(0,0,(int)DISPLAY_WIDTH,(int)DISPLAY_HEIGHT);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(64.0f,DISPLAY_WIDTH / DISPLAY_HEIGHT,0.01f,1000f);
  glPushMatrix();
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glPushMatrix();
}
Program: 1358
Project: 1358
Buggy source:
private boolean isPlayerStandingOnGround(){
  if (getParent() != null) {
    return getParent().isHitting(new Vector3f(getPosition().x,getPosition().y - PLAYER_HEIGHT,getPosition().z));
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
private boolean isPlayerStandingOnGround(){
  if (getParent() != null) {
    return getParent().isHitting(new Vector3f(getPosition().x + 0.5f,getPosition().y - PLAYER_HEIGHT,getPosition().z + 0.5f));
  }
 else {
    return false;
  }
}
Program: 1359
Project: 1359
Buggy source:
public Vector3f calcViewBlockPosition(){
  Vector3f blockPosition=new Vector3f(position);
  Vector2f viewingDirectionHorizontal=new Vector2f((float)Math.sin(Math.toRadians(yaw)),-1f * (float)Math.cos(Math.toRadians(yaw)));
  Vector2f viewingDirectionVertical=new Vector2f(-1f * (float)Math.sin(Math.toRadians(pitch)),(float)Math.cos(Math.toRadians(pitch)));
  blockPosition.x+=4f * viewingDirectionHorizontal.x;
  blockPosition.y+=4f * viewingDirectionVertical.x;
  blockPosition.z+=4f * viewingDirectionHorizontal.y;
  return blockPosition;
}

Fixed version (ground truth):
public Vector3f calcViewBlockPosition(){
  Vector3f blockPosition=new Vector3f(position);
  Vector2f viewingDirectionHorizontal=new Vector2f((float)Math.sin(Math.toRadians(yaw)),-1f * (float)Math.cos(Math.toRadians(yaw)));
  Vector2f viewingDirectionVertical=new Vector2f(-1f * (float)Math.sin(Math.toRadians(pitch)),(float)Math.cos(Math.toRadians(pitch)));
  for (int z=0; z < 4; z++) {
    blockPosition.x+=viewingDirectionHorizontal.x * viewingDirectionVertical.y;
    blockPosition.y+=viewingDirectionVertical.x;
    blockPosition.z+=viewingDirectionHorizontal.y * viewingDirectionVertical.y;
    if (parent.getBlock(blockPosition) != 0) {
      return blockPosition;
    }
  }
  return null;
}