Program: 174495
Project: 174495
Buggy source:
@Override public void run(EntityBismuth gem){
  if (this.lastBlockPlace > 20) {
    if (this.startedBuilding) {
      boolean placed=false;
      BlockPos nextPos=gem.getPosition();
      for (int y=0; y < this.height; ++y) {
        if (!gem.world.getBlockState(nextPos.up(y)).getBlock().isTopSolid(gem.world.getBlockState(nextPos.up(y)))) {
          placed=gem.placeBlock(this.bridgeBlock,nextPos.up(y));
          if (placed) {
            gem.setPosition(nextPos.getX(),nextPos.getY() + y + 1,nextPos.getZ());
            this.placeStack.shrink(1);
            if (this.placeStack.isEmpty()) {
              this.getBlock(gem);
            }
          }
 else {
            break;
          }
        }
      }
      this.startedBuilding=false;
      this.lastBlockPlace=0;
      this.limit=this.width;
    }
 else {
      if (this.sidePlaced < 4) {
        if (this.offset < this.limit) {
          boolean placed=false;
          BlockPos nextPos=gem.getPosition().add(this.direction[0],-this.height,this.direction[1]);
          gem.lookAt(nextPos.add(this.direction[0],0,this.direction[1]));
          for (int y=0; y < this.height; ++y) {
            if (!gem.world.getBlockState(nextPos.up(y)).getBlock().isTopSolid(gem.world.getBlockState(nextPos.up(y)))) {
              placed=gem.placeBlock(this.bridgeBlock,nextPos.up(y));
              if (placed) {
                this.placeStack.shrink(1);
                if (this.placeStack.isEmpty()) {
                  this.getBlock(gem);
                }
              }
            }
          }
          gem.tryToMoveTo(nextPos.up(this.height));
          this.lastBlockPlace=0;
          ++this.offset;
        }
 else {
          this.changeDirection(gem);
          this.offset=0;
          ++this.sidePlaced;
          if (this.sidePlaced % 2 == 0) {
            this.limit=this.width;
          }
 else {
            this.limit=this.depth;
          }
        }
      }
 else {
        this.stillBuilding=false;
      }
    }
  }
  ++this.lastBlockPlace;
}

Fixed version (ground truth):
@Override public void run(EntityBismuth gem){
  if (this.lastBlockPlace > 20) {
    if (this.startedBuilding) {
      boolean placed=false;
      BlockPos nextPos=gem.getPosition();
      for (int y=0; y < this.height; ++y) {
        if (!gem.world.getBlockState(nextPos.up(y)).getBlock().isTopSolid(gem.world.getBlockState(nextPos.up(y)))) {
          placed=gem.placeBlock(this.bridgeBlock,nextPos.up(y));
          if (placed) {
            gem.setPosition(nextPos.getX(),nextPos.getY() + y + 1,nextPos.getZ());
            this.placeStack.shrink(1);
            if (this.placeStack.isEmpty()) {
              placed=this.getBlock(gem) && placed;
              if (!placed) {
                break;
              }
            }
          }
 else {
            break;
          }
        }
      }
      this.startedBuilding=false;
      this.lastBlockPlace=0;
      this.limit=this.width;
    }
 else {
      if (this.sidePlaced < 4) {
        if (this.offset < this.limit) {
          boolean placed=false;
          BlockPos nextPos=gem.getPosition().add(this.direction[0],-this.height,this.direction[1]);
          gem.lookAt(nextPos.add(this.direction[0],0,this.direction[1]));
          for (int y=0; y < this.height; ++y) {
            if (!gem.world.getBlockState(nextPos.up(y)).getBlock().isTopSolid(gem.world.getBlockState(nextPos.up(y)))) {
              placed=gem.placeBlock(this.bridgeBlock,nextPos.up(y));
              if (placed) {
                this.placeStack.shrink(1);
                if (this.placeStack.isEmpty()) {
                  this.getBlock(gem);
                }
              }
            }
          }
          gem.tryToMoveTo(nextPos.up(this.height));
          this.lastBlockPlace=0;
          ++this.offset;
        }
 else {
          this.changeDirection(gem);
          this.offset=0;
          ++this.sidePlaced;
          if (this.sidePlaced % 2 == 0) {
            this.limit=this.width;
          }
 else {
            this.limit=this.depth;
          }
        }
      }
 else {
        this.stillBuilding=false;
      }
    }
  }
  ++this.lastBlockPlace;
}