Program: 134230
Project: 134230
Buggy source:
@Override public InstanceData prepareInstanceData(StructurePrepareContext context,BlockPos pos){
  WorldScriptStructureGenerator.InstanceData instanceData=null;
  Random random=context.random;
  AxisAlignedTransform2D transform=context.transform;
  if (simpleMode) {
    if (structureNames.size() > 0) {
      String structureID=structureNames.get(random.nextInt(structureNames.size()));
      StructureInfo<?> structureInfo=StructureRegistry.INSTANCE.get(structureID);
      if (structureInfo != null) {
        int rotations=structureInfo.isRotatable() ? (structureRotation != null ? transform.getRotation() + structureRotation : random.nextInt(4)) : 0;
        boolean mirrorX=structureInfo.isMirrorable() && (structureMirror != null ? transform.isMirrorX() != structureMirror : random.nextBoolean());
        AxisAlignedTransform2D strucTransform=AxisAlignedTransform2D.from(rotations,mirrorX);
        int[] strucSize=structureInfo.size();
        BlockPos strucCoord=transform.apply(structureShift,new int[]{1,1,1}).subtract(transform.apply(BlockPos.ORIGIN,strucSize)).add(pos);
        instanceData=new WorldScriptStructureGenerator.InstanceData(structureID,null,strucCoord,strucTransform,new StructureGenerator<>(structureInfo).random(random).environment(context.environment).transform(strucTransform).lowerCoord(strucCoord).asSource(context.generateAsSource).instanceData().orElse(null));
      }
    }
  }
 else {
    Collection<Pair<StructureInfo,ListGenerationInfo>> generationInfos=StructureRegistry.INSTANCE.getStructuresInList(structureListID,front);
    if (generationInfos.size() > 0) {
      Pair<StructureInfo,ListGenerationInfo> pair=WeightedSelector.select(random,generationInfos,item -> RCConfig.tweakedSpawnRate(StructureRegistry.INSTANCE.id(item.getLeft())) * item.getRight().getWeight());
      StructureInfo structureInfo=pair.getLeft();
      String structureID=StructureRegistry.INSTANCE.id(structureInfo);
      ListGenerationInfo generationInfo=pair.getRight();
      boolean mirrorX;
      int rotations;
      if (front != null) {
        EnumFacing curFront=Directions.rotate(front,transform);
        mirrorX=structureInfo.isMirrorable() && structureInfo.isRotatable() && random.nextBoolean();
        Integer neededRotations=Directions.getHorizontalClockwiseRotations(curFront,generationInfo.front,mirrorX);
        rotations=neededRotations != null ? neededRotations : 0;
      }
 else {
        mirrorX=structureInfo.isMirrorable() && random.nextBoolean();
        rotations=structureInfo.isRotatable() ? random.nextInt(4) : 0;
      }
      AxisAlignedTransform2D strucTransform=AxisAlignedTransform2D.from(rotations,mirrorX);
      int[] strucSize=structureInfo.size();
      BlockPos strucCoord=transform.apply(structureShift.add(generationInfo.shift),new int[]{1,1,1}).subtract(transform.apply(BlockPos.ORIGIN,strucSize)).add(pos);
      instanceData=new WorldScriptStructureGenerator.InstanceData(structureID,generationInfo.id(),strucCoord,strucTransform,(NBTStorable)new StructureGenerator<>(structureInfo).random(random).environment(context.environment).transform(strucTransform).asSource(context.generateAsSource).lowerCoord(strucCoord).instanceData().orElse(null));
    }
  }
  return instanceData != null ? instanceData : new WorldScriptStructureGenerator.InstanceData();
}

Fixed version (ground truth):
@Override public InstanceData prepareInstanceData(StructurePrepareContext context,BlockPos pos){
  WorldScriptStructureGenerator.InstanceData instanceData=null;
  Random random=context.random;
  AxisAlignedTransform2D transform=context.transform;
  if (simpleMode) {
    if (structureNames.size() > 0) {
      String structureID=structureNames.get(random.nextInt(structureNames.size()));
      StructureInfo<?> structureInfo=StructureRegistry.INSTANCE.get(structureID);
      if (structureInfo != null) {
        int rotations=structureInfo.isRotatable() ? (structureRotation != null ? transform.getRotation() + structureRotation : random.nextInt(4)) : 0;
        boolean mirrorX=structureInfo.isMirrorable() && (structureMirror != null ? transform.isMirrorX() != structureMirror : random.nextBoolean());
        AxisAlignedTransform2D strucTransform=AxisAlignedTransform2D.from(rotations,mirrorX);
        int[] strucSize=structureInfo.size();
        BlockPos strucCoord=transform.apply(structureShift,new int[]{1,1,1}).subtract(transform.apply(BlockPos.ORIGIN,strucSize)).add(pos);
        instanceData=new WorldScriptStructureGenerator.InstanceData(structureID,null,strucCoord,strucTransform,new StructureGenerator<>(structureInfo).random(random).environment(context.environment).transform(strucTransform).lowerCoord(strucCoord).asSource(context.generateAsSource).instanceData().orElse(null));
      }
    }
  }
 else {
    Collection<Pair<StructureInfo,ListGenerationInfo>> generationInfos=StructureRegistry.INSTANCE.getStructuresInList(structureListID,front);
    if (generationInfos.size() > 0) {
      Pair<StructureInfo,ListGenerationInfo> pair=WeightedSelector.select(random,generationInfos,item -> RCConfig.tweakedSpawnRate(StructureRegistry.INSTANCE.id(item.getLeft())) * item.getRight().getWeight());
      StructureInfo structureInfo=pair.getLeft();
      String structureID=StructureRegistry.INSTANCE.id(structureInfo);
      ListGenerationInfo generationInfo=pair.getRight();
      boolean mirrorX;
      int rotations;
      if (front != null) {
        EnumFacing curFront=Directions.rotate(front,transform);
        mirrorX=structureInfo.isMirrorable() && structureInfo.isRotatable() && random.nextBoolean();
        Integer neededRotations=RCDirections.getHorizontalClockwiseRotations(curFront,generationInfo.front,mirrorX);
        rotations=neededRotations != null ? neededRotations : 0;
      }
 else {
        mirrorX=structureInfo.isMirrorable() && random.nextBoolean();
        rotations=structureInfo.isRotatable() ? random.nextInt(4) : 0;
      }
      AxisAlignedTransform2D strucTransform=AxisAlignedTransform2D.from(rotations,mirrorX);
      int[] strucSize=structureInfo.size();
      BlockPos strucCoord=transform.apply(structureShift.add(generationInfo.shift),new int[]{1,1,1}).subtract(transform.apply(BlockPos.ORIGIN,strucSize)).add(pos);
      instanceData=new WorldScriptStructureGenerator.InstanceData(structureID,generationInfo.id(),strucCoord,strucTransform,(NBTStorable)new StructureGenerator<>(structureInfo).random(random).environment(context.environment).transform(strucTransform).asSource(context.generateAsSource).lowerCoord(strucCoord).instanceData().orElse(null));
    }
  }
  return instanceData != null ? instanceData : new WorldScriptStructureGenerator.InstanceData();
}