Program: 169466
Project: 169466
Buggy source:
public static BundledConnection getBundledNeighbor(IBundledDevice device,ForgeDirection side){
  ForgeDirection face=ForgeDirection.UNKNOWN;
  if (device instanceof IFace)   face=((IFace)device).getFace();
  do {
    Vec3i loc=new Vec3i(device);
    IBundledDevice dev=RedstoneApi.getInstance().getBundledDevice(loc.getWorld(),loc.getX(),loc.getY(),loc.getZ(),side,face == ForgeDirection.UNKNOWN ? side.getOpposite() : face);
    if (dev == null)     break;
    ConnectionType type=(!(device instanceof IFace) || !(dev instanceof IFace)) && !(device instanceof IFace == dev instanceof IFace) ? ConnectionType.STRAIGHT : ConnectionType.CLOSED_CORNER;
    if (device.canConnect(side,dev,type) && dev.canConnect(face,device,type))     return RedstoneApi.getInstance().createConnection(device,dev,side,face,type);
  }
 while (false);
  if (face != ForgeDirection.UNKNOWN) {
    do {
      Vec3i loc=new Vec3i(device).add(face).add(side);
      IBundledDevice dev=RedstoneApi.getInstance().getBundledDevice(loc.getWorld(),loc.getX(),loc.getY(),loc.getZ(),side.getOpposite(),face.getOpposite());
      if (dev == null)       break;
      Vec3i block=new Vec3i(device).add(side);
      if (block.getBlock().isNormalCube(block.getWorld(),block.getX(),block.getY(),block.getZ()))       break;
      if (OcclusionHelper.microblockOcclusionTest(block,MicroblockShape.EDGE,1,face,side.getOpposite()))       break;
      if (device.canConnect(side,dev,ConnectionType.OPEN_CORNER) && dev.canConnect(face.getOpposite(),device,ConnectionType.OPEN_CORNER))       return RedstoneApi.getInstance().createConnection(device,dev,side,face.getOpposite(),ConnectionType.OPEN_CORNER);
    }
 while (false);
  }
  do {
    Vec3i loc=new Vec3i(device).add(side);
    IBundledDevice dev=RedstoneApi.getInstance().getBundledDevice(loc.getWorld(),loc.getX(),loc.getY(),loc.getZ(),face,side.getOpposite());
    if (dev == null)     break;
    if (device.canConnect(side,dev,ConnectionType.STRAIGHT) && dev.canConnect(side.getOpposite(),device,ConnectionType.STRAIGHT))     return RedstoneApi.getInstance().createConnection(device,dev,side,side.getOpposite(),ConnectionType.STRAIGHT);
  }
 while (false);
  return null;
}

Fixed version (ground truth):
public static BundledConnection getBundledNeighbor(IBundledDevice device,ForgeDirection side){
  ForgeDirection face=ForgeDirection.UNKNOWN;
  if (device instanceof IFace)   face=((IFace)device).getFace();
  do {
    Vec3i loc=new Vec3i(device);
    IBundledDevice dev=RedstoneApi.getInstance().getBundledDevice(loc.getWorld(),loc.getX(),loc.getY(),loc.getZ(),side,face == ForgeDirection.UNKNOWN ? side.getOpposite() : face);
    if (dev == null)     break;
    ConnectionType type=(!(device instanceof IFace) || !(dev instanceof IFace)) && !(device instanceof IFace == dev instanceof IFace) ? ConnectionType.STRAIGHT : ConnectionType.CLOSED_CORNER;
    if (device.canConnect(side,dev,type) && dev.canConnect(face,device,type))     return RedstoneApi.getInstance().createConnection(device,dev,side,face,type);
  }
 while (false);
  if (face != ForgeDirection.UNKNOWN) {
    do {
      Vec3i loc=new Vec3i(device).add(face).add(side);
      IBundledDevice dev=RedstoneApi.getInstance().getBundledDevice(loc.getWorld(),loc.getX(),loc.getY(),loc.getZ(),side.getOpposite(),face.getOpposite());
      if (dev == null)       break;
      Vec3i block=new Vec3i(device).add(side);
      if (block.getBlock().isNormalCube(block.getWorld(),block.getX(),block.getY(),block.getZ()))       break;
      if (OcclusionHelper.microblockOcclusionTest(block,MicroblockShape.EDGE,1,face,side.getOpposite()))       break;
      if (device.canConnect(side,dev,ConnectionType.OPEN_CORNER) && dev.canConnect(face.getOpposite(),device,ConnectionType.OPEN_CORNER))       return RedstoneApi.getInstance().createConnection(device,dev,side,face.getOpposite(),ConnectionType.OPEN_CORNER);
    }
 while (false);
  }
  do {
    Vec3i loc=new Vec3i(device).add(side);
    IBundledDevice dev=RedstoneApi.getInstance().getBundledDevice(loc.getWorld(),loc.getX(),loc.getY(),loc.getZ(),face,side.getOpposite());
    if (dev == null) {
      dev=RedstoneApi.getInstance().getBundledDevice(loc.getWorld(),loc.getX(),loc.getY(),loc.getZ(),side.getOpposite(),side.getOpposite());
      if (dev == null && face == ForgeDirection.UNKNOWN) {
        for (        ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
          if (d != side && d != side.getOpposite()) {
            dev=RedstoneApi.getInstance().getBundledDevice(loc.getWorld(),loc.getX(),loc.getY(),loc.getZ(),d,side.getOpposite());
            if (dev != null)             break;
          }
        }
      }
    }
    if (dev == null)     break;
    if (device.canConnect(side,dev,ConnectionType.STRAIGHT) && dev.canConnect(side.getOpposite(),device,ConnectionType.STRAIGHT))     return RedstoneApi.getInstance().createConnection(device,dev,side,side.getOpposite(),ConnectionType.STRAIGHT);
  }
 while (false);
  return null;
}