Program: 11765
Project: 11765
Buggy source:
public void paint(){
  if (terrainPopulated == 0x01) {
    return;
  }
  List<AbstractOverlayBrush> brushes=world.loader().brushes();
  AbstractOverlayBrush.ChunkManipulator manipulator=new AbstractOverlayBrush.ChunkManipulator(){
    @Override public void manipulate(    int relX,    int y,    int relZ,    Substance substance,    byte data){
      if (relX >= 0 && relX <= 15 && relZ >= 0 && relZ <= 15) {
        setAt(relX,y,relZ,substance,data,(byte)255,(byte)15);
        return;
      }
      int cx=location.x();
      int cz=location.z();
      int xMinDiff=Math.max(relX,0) - Math.min(relX,0);
      int xMaxDiff=Math.max(relX,15) - Math.min(relX,15);
      int zMinDiff=Math.max(relZ,0) - Math.min(relZ,0);
      int zMaxDiff=Math.max(relZ,15) - Math.min(relZ,15);
      int chunkX=location.x();
      int chunkZ=location.z();
      int newX=relX;
      int newZ=relZ;
      if (relX < 0) {
        newX=16 - xMinDiff;
        chunkX=cx - up(xMinDiff / 16) - 1;
      }
 else       if (relX > 15) {
        newX=xMaxDiff - 1;
        chunkX=cx + up(xMaxDiff / 16) + 1;
      }
      if (relZ < 0) {
        newZ=16 - zMinDiff;
        chunkZ=cz - up(zMinDiff / 16) - 1;
      }
 else       if (relZ > 15) {
        newZ=zMaxDiff - 1;
        chunkZ=cz + up(zMaxDiff / 16) + 1;
      }
      ChunkLocation loc=ChunkLocation.create(chunkX,chunkZ);
      TridentChunk chunk=rawChunk(loc);
      chunk.setAt(newX,y,newZ,substance,data,(byte)255,(byte)15);
    }
    @Override public Block blockAt(    int relX,    int y,    int relZ){
      if (relX >= 0 && relX <= 15 && relZ >= 0 && relZ <= 15) {
        return TridentChunk.this.blockAt(relX,y,relZ);
      }
      int cx=location.x();
      int cz=location.z();
      int xMinDiff=Math.max(relX,0) - Math.min(relX,0);
      int xMaxDiff=Math.max(relX,15) - Math.min(relX,15);
      int zMinDiff=Math.max(relZ,0) - Math.min(relZ,0);
      int zMaxDiff=Math.max(relZ,15) - Math.min(relZ,15);
      int chunkX=location.x();
      int chunkZ=location.z();
      int newX=relX;
      int newZ=relZ;
      if (relX < 0) {
        newX=16 - xMinDiff;
        chunkX=cx - up(xMinDiff / 16) - 1;
      }
 else       if (relX > 15) {
        newX=xMaxDiff - 1;
        chunkX=cx + up(xMaxDiff / 16) + 1;
      }
      if (relZ < 0) {
        newZ=16 - zMinDiff;
        chunkZ=cz - up(zMinDiff / 16) - 1;
      }
 else       if (relZ > 15) {
        newZ=zMaxDiff - 1;
        chunkZ=cz + up(zMaxDiff / 16) + 1;
      }
      ChunkLocation loc=ChunkLocation.create(chunkX,chunkZ);
      TridentChunk chunk=rawChunk(loc);
      return chunk.blockAt(newX,y,newZ);
    }
  }
;
  for (int i=0; i < 16; i++) {
    for (int j=0; j < 16; j++) {
      for (      AbstractOverlayBrush brush : brushes) {
        brush.brush(location,i,j,world.random(),heights,manipulator);
      }
    }
  }
  terrainPopulated=0x01;
}

Fixed version (ground truth):
public void paint(){
  if (terrainPopulated == 0x01) {
    return;
  }
  List<AbstractOverlayBrush> brushes=world.loader().brushes();
  AbstractOverlayBrush.ChunkManipulator manipulator=new AbstractOverlayBrush.ChunkManipulator(){
    @Override public void manipulate(    int relX,    int y,    int relZ,    Substance substance,    byte data){
      if (relX >= 0 && relX <= 15 && relZ >= 0 && relZ <= 15) {
        setAt(relX,y,relZ,substance,data,(byte)255,(byte)15);
        return;
      }
      int cx=location.x();
      int cz=location.z();
      int xMinDiff=Math.max(relX,0) - Math.min(relX,0);
      int xMaxDiff=Math.max(relX,15) - Math.min(relX,15);
      int zMinDiff=Math.max(relZ,0) - Math.min(relZ,0);
      int zMaxDiff=Math.max(relZ,15) - Math.min(relZ,15);
      int chunkX=location.x();
      int chunkZ=location.z();
      int newX=relX;
      int newZ=relZ;
      if (relX < 0) {
        newX=16 - xMinDiff;
        chunkX=cx - up(xMinDiff / 16) - 1;
      }
 else       if (relX > 15) {
        newX=xMaxDiff - 1;
        chunkX=cx + up(xMaxDiff / 16) + 1;
      }
      if (relZ < 0) {
        newZ=16 - zMinDiff;
        chunkZ=cz - up(zMinDiff / 16) - 1;
      }
 else       if (relZ > 15) {
        newZ=zMaxDiff - 1;
        chunkZ=cz + up(zMaxDiff / 16) + 1;
      }
      ChunkLocation loc=ChunkLocation.create(chunkX,chunkZ);
      TridentChunk chunk=rawChunk(loc);
      chunk.setAt(newX,y,newZ,substance,data,(byte)255,(byte)15);
    }
    @Override public Block blockAt(    int relX,    int y,    int relZ){
      if (relX >= 0 && relX <= 15 && relZ >= 0 && relZ <= 15) {
        return TridentChunk.this.blockAt(relX,y,relZ);
      }
      int cx=location.x();
      int cz=location.z();
      int xMinDiff=Math.max(relX,0) - Math.min(relX,0);
      int xMaxDiff=Math.max(relX,15) - Math.min(relX,15);
      int zMinDiff=Math.max(relZ,0) - Math.min(relZ,0);
      int zMaxDiff=Math.max(relZ,15) - Math.min(relZ,15);
      int chunkX=location.x();
      int chunkZ=location.z();
      int newX=relX;
      int newZ=relZ;
      if (relX < 0) {
        newX=16 - xMinDiff;
        chunkX=cx - up(xMinDiff / 16) - 1;
      }
 else       if (relX > 15) {
        newX=xMaxDiff - 1;
        chunkX=cx + up(xMaxDiff / 16) + 1;
      }
      if (relZ < 0) {
        newZ=16 - zMinDiff;
        chunkZ=cz - up(zMinDiff / 16) - 1;
      }
 else       if (relZ > 15) {
        newZ=zMaxDiff - 1;
        chunkZ=cz + up(zMaxDiff / 16) + 1;
      }
      ChunkLocation loc=ChunkLocation.create(chunkX,chunkZ);
      TridentChunk chunk=rawChunk(loc);
      return chunk.blockAt(newX,y,newZ);
    }
  }
;
  executor.execute(() -> {
    for (int i=0; i < 16; i++) {
      for (int j=0; j < 16; j++) {
        for (        AbstractOverlayBrush brush : brushes) {
          brush.brush(location,i,j,world.random(),heights,manipulator);
        }
      }
    }
  }
);
  terrainPopulated=0x01;
}